extract to the helper so we can easily toggle the knobs
This commit is contained in:
parent
ef63ef4e02
commit
bacc478b3e
@ -82,3 +82,9 @@ def get_random_bundles(total_form_items: int,
|
|||||||
return selected_bundles
|
return selected_bundles
|
||||||
else:
|
else:
|
||||||
return get_random_bundles(total_form_items, total_bundles - 1, bundles)
|
return get_random_bundles(total_form_items, total_bundles - 1, bundles)
|
||||||
|
|
||||||
|
def elasticize_constraint(lp_constraint, parameters = {}):
|
||||||
|
penalty = parameters.get('penalty', 1) # could be a 100% penalty
|
||||||
|
proportionFreeBound = parameters.get('proportionFreeBound', 0.25)
|
||||||
|
|
||||||
|
return lp_constraint.makeElasticSubProblem(penalty=penalty, proportionFreeBound=proportionFreeBound)
|
||||||
|
@ -8,7 +8,7 @@ class TestResponseFunction():
|
|||||||
self.irt_model = irt_model
|
self.irt_model = irt_model
|
||||||
self.irf = ItemResponseFunction(irt_model)
|
self.irf = ItemResponseFunction(irt_model)
|
||||||
|
|
||||||
# determins the probably of an inidividual
|
# determine the probability of an individual
|
||||||
# at a certain theta (ability level) would get a sum of questions correct
|
# at a certain theta (ability level) would get a sum of questions correct
|
||||||
# detailed further on page 166, equation 3 here:
|
# detailed further on page 166, equation 3 here:
|
||||||
# https://www.ncbi.nlm.nih.gov/pmc/articles/PMC5978482/pdf/10.1177_0146621615613308.pdf
|
# https://www.ncbi.nlm.nih.gov/pmc/articles/PMC5978482/pdf/10.1177_0146621615613308.pdf
|
||||||
|
@ -85,8 +85,7 @@ class LoftService(Base):
|
|||||||
problem_objective_functions = []
|
problem_objective_functions = []
|
||||||
|
|
||||||
# dummy objective function, because it just makes things easier™
|
# dummy objective function, because it just makes things easier™
|
||||||
problem += lpSum(
|
problem += lpSum([items[item.id] for item in self.solver_run.items])
|
||||||
[items[item.id] for item in self.solver_run.items])
|
|
||||||
|
|
||||||
# constraints
|
# constraints
|
||||||
# problem += lpSum([items[item.id]
|
# problem += lpSum([items[item.id]
|
||||||
@ -128,10 +127,10 @@ class LoftService(Base):
|
|||||||
sense=0,
|
sense=0,
|
||||||
name=f'tif theta ({target.theta}) @{target.value}',
|
name=f'tif theta ({target.theta}) @{target.value}',
|
||||||
rhs=target.value)
|
rhs=target.value)
|
||||||
elastized_constraint = constraint.makeElasticSubProblem(
|
|
||||||
penalty=1, proportionFreeBound=0.25)
|
elasticized_constraint = solver_helper.elasticize_constraint(constraint)
|
||||||
if int(target.value) == 20: print(elastized_constraint)
|
problem.extend(elasticized_constraint)
|
||||||
problem.extend(elastized_constraint)
|
# if int(target.value) == 20: print(elasticized_constraint)
|
||||||
for target in self.solver_run.objective_function.tcc_targets:
|
for target in self.solver_run.objective_function.tcc_targets:
|
||||||
tcc = lpSum([
|
tcc = lpSum([
|
||||||
bundle.trf(self.solver_run.irt_model, target.theta) *
|
bundle.trf(self.solver_run.irt_model, target.theta) *
|
||||||
@ -141,6 +140,7 @@ class LoftService(Base):
|
|||||||
for item in self.solver_run.items
|
for item in self.solver_run.items
|
||||||
])
|
])
|
||||||
problem_objective_functions.append(tcc)
|
problem_objective_functions.append(tcc)
|
||||||
|
|
||||||
e = LpAffineExpression(
|
e = LpAffineExpression(
|
||||||
[(bundles[bundle.id],
|
[(bundles[bundle.id],
|
||||||
bundle.trf(self.solver_run.irt_model, target.theta))
|
bundle.trf(self.solver_run.irt_model, target.theta))
|
||||||
@ -152,9 +152,9 @@ class LoftService(Base):
|
|||||||
sense=0,
|
sense=0,
|
||||||
name=f'tcc theta ({target.theta}) @{target.value}',
|
name=f'tcc theta ({target.theta}) @{target.value}',
|
||||||
rhs=target.value)
|
rhs=target.value)
|
||||||
elastized_constraint = constraint.makeElasticSubProblem(
|
|
||||||
penalty=1, proportionFreeBound=0.25)
|
elasticized_constraint = solver_helper.elasticize_constraint(constraint)
|
||||||
problem.extend(elastized_constraint)
|
problem.extend(elasticized_constraint)
|
||||||
|
|
||||||
# solve problem
|
# solve problem
|
||||||
logging.info('Solving...')
|
logging.info('Solving...')
|
||||||
@ -164,8 +164,7 @@ class LoftService(Base):
|
|||||||
logging.info('Solved...generating form and adding to solution')
|
logging.info('Solved...generating form and adding to solution')
|
||||||
|
|
||||||
# add return items and create as a form
|
# add return items and create as a form
|
||||||
form_items = service_helper.solution_items(problem.variables(),
|
form_items = service_helper.solution_items(problem.variables(), self.solver_run)
|
||||||
self.solver_run)
|
|
||||||
|
|
||||||
# add form to solution
|
# add form to solution
|
||||||
solution.forms.append(
|
solution.forms.append(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user