return results whether optimized or not, add status to returned csv

This commit is contained in:
Josh Burman
2021-11-22 17:25:32 +00:00
parent c2d1ccb2bd
commit 88ef6b2e03
3 changed files with 13 additions and 11 deletions

View File

@ -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 # 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 # fill the rows with the targets and cut score then the items
header = [] header = ['status']
for result in forms[0].tif_results: for result in forms[0].tif_results:
header += [f'tif @ {round(result.theta, 2)}'] 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 # add each form as row to processed csv
for form in forms: for form in forms:
row = [] row = [form.status]
for result in form.tif_results: for result in form.tif_results:
row += [f'value - {result.value}\nresult - {round(result.result, 2)}'] row += [f'value - {result.value}\nresult - {round(result.result, 2)}']

View File

@ -13,12 +13,14 @@ class Form(BaseModel):
cut_score: float cut_score: float
tif_results: List[Target] tif_results: List[Target]
tcc_results: List[Target] tcc_results: List[Target]
status: str = 'Not Optimized'
@classmethod @classmethod
def create(cls, items, solver_run): def create(cls, items, solver_run, status):
return cls( return cls(
items=items, items=items,
cut_score=TestResponseFunction(solver_run.irt_model).calculate(items, theta=solver_run.theta_cut_score), 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), 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
) )

View File

@ -84,13 +84,12 @@ class LoftService(Base):
# solve problem # solve problem
problem.sequentialSolve(problem_objection_functions) problem.sequentialSolve(problem_objection_functions)
if LpStatus[problem.status] == 'Optimized': # add return items and create as a form
# 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) # remove items
# remove items self.solver_run.remove_items(form_items)
self.solver_run.remove_items(form_items) # add form to solution
# add form to solution solution.forms.append(Form.create(form_items, self.solver_run, LpStatus[problem.status]))
solution.forms.append(Form.create(form_items, self.solver_run))
# successfull form, increment # successfull form, increment
f += 1 f += 1