return results whether optimized or not, add status to returned csv
This commit is contained in:
@ -34,7 +34,8 @@ def solution_to_file(buffer, total_form_items, forms):
|
||||
|
||||
# write header row for first row utilizing the total items all forms will have
|
||||
# fill the rows with the targets and cut score then the items
|
||||
header = []
|
||||
header = ['status']
|
||||
|
||||
for result in forms[0].tif_results:
|
||||
header += [f'tif @ {round(result.theta, 2)}']
|
||||
|
||||
@ -46,7 +47,7 @@ def solution_to_file(buffer, total_form_items, forms):
|
||||
|
||||
# add each form as row to processed csv
|
||||
for form in forms:
|
||||
row = []
|
||||
row = [form.status]
|
||||
|
||||
for result in form.tif_results:
|
||||
row += [f'value - {result.value}\nresult - {round(result.result, 2)}']
|
||||
|
@ -13,12 +13,14 @@ class Form(BaseModel):
|
||||
cut_score: float
|
||||
tif_results: List[Target]
|
||||
tcc_results: List[Target]
|
||||
status: str = 'Not Optimized'
|
||||
|
||||
@classmethod
|
||||
def create(cls, items, solver_run):
|
||||
def create(cls, items, solver_run, status):
|
||||
return cls(
|
||||
items=items,
|
||||
cut_score=TestResponseFunction(solver_run.irt_model).calculate(items, theta=solver_run.theta_cut_score),
|
||||
tif_results=irt_helper.generate_tif_results(items, solver_run),
|
||||
tcc_results=irt_helper.generate_tcc_results(items, solver_run)
|
||||
tcc_results=irt_helper.generate_tcc_results(items, solver_run),
|
||||
status=status
|
||||
)
|
||||
|
@ -84,13 +84,12 @@ class LoftService(Base):
|
||||
# solve problem
|
||||
problem.sequentialSolve(problem_objection_functions)
|
||||
|
||||
if LpStatus[problem.status] == 'Optimized':
|
||||
# add return items and create as a form
|
||||
form_items = service_helper.solution_items(problem.variables(), self.solver_run)
|
||||
# remove items
|
||||
self.solver_run.remove_items(form_items)
|
||||
# add form to solution
|
||||
solution.forms.append(Form.create(form_items, self.solver_run))
|
||||
solution.forms.append(Form.create(form_items, self.solver_run, LpStatus[problem.status]))
|
||||
|
||||
# successfull form, increment
|
||||
f += 1
|
||||
|
Reference in New Issue
Block a user