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
|
||||
else:
|
||||
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.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
|
||||
# detailed further on page 166, equation 3 here:
|
||||
# https://www.ncbi.nlm.nih.gov/pmc/articles/PMC5978482/pdf/10.1177_0146621615613308.pdf
|
||||
|
@ -85,8 +85,7 @@ class LoftService(Base):
|
||||
problem_objective_functions = []
|
||||
|
||||
# dummy objective function, because it just makes things easier™
|
||||
problem += lpSum(
|
||||
[items[item.id] for item in self.solver_run.items])
|
||||
problem += lpSum([items[item.id] for item in self.solver_run.items])
|
||||
|
||||
# constraints
|
||||
# problem += lpSum([items[item.id]
|
||||
@ -128,10 +127,10 @@ class LoftService(Base):
|
||||
sense=0,
|
||||
name=f'tif theta ({target.theta}) @{target.value}',
|
||||
rhs=target.value)
|
||||
elastized_constraint = constraint.makeElasticSubProblem(
|
||||
penalty=1, proportionFreeBound=0.25)
|
||||
if int(target.value) == 20: print(elastized_constraint)
|
||||
problem.extend(elastized_constraint)
|
||||
|
||||
elasticized_constraint = solver_helper.elasticize_constraint(constraint)
|
||||
problem.extend(elasticized_constraint)
|
||||
# if int(target.value) == 20: print(elasticized_constraint)
|
||||
for target in self.solver_run.objective_function.tcc_targets:
|
||||
tcc = lpSum([
|
||||
bundle.trf(self.solver_run.irt_model, target.theta) *
|
||||
@ -141,6 +140,7 @@ class LoftService(Base):
|
||||
for item in self.solver_run.items
|
||||
])
|
||||
problem_objective_functions.append(tcc)
|
||||
|
||||
e = LpAffineExpression(
|
||||
[(bundles[bundle.id],
|
||||
bundle.trf(self.solver_run.irt_model, target.theta))
|
||||
@ -152,9 +152,9 @@ class LoftService(Base):
|
||||
sense=0,
|
||||
name=f'tcc theta ({target.theta}) @{target.value}',
|
||||
rhs=target.value)
|
||||
elastized_constraint = constraint.makeElasticSubProblem(
|
||||
penalty=1, proportionFreeBound=0.25)
|
||||
problem.extend(elastized_constraint)
|
||||
|
||||
elasticized_constraint = solver_helper.elasticize_constraint(constraint)
|
||||
problem.extend(elasticized_constraint)
|
||||
|
||||
# solve problem
|
||||
logging.info('Solving...')
|
||||
@ -164,8 +164,7 @@ class LoftService(Base):
|
||||
logging.info('Solved...generating form and adding to solution')
|
||||
|
||||
# add return items and create as a form
|
||||
form_items = service_helper.solution_items(problem.variables(),
|
||||
self.solver_run)
|
||||
form_items = service_helper.solution_items(problem.variables(), self.solver_run)
|
||||
|
||||
# add form to solution
|
||||
solution.forms.append(
|
||||
|
Loading…
x
Reference in New Issue
Block a user