target variance for each solver run. authored by Yosh

This commit is contained in:
Adrian Manteza
2022-03-25 17:20:14 +00:00
parent 6ebe33a76b
commit 1f00e1e1bc
6 changed files with 46 additions and 19 deletions

View File

@ -1,5 +1,14 @@
def boolean_to_int(value: bool) -> int:
if value:
return 1
else:
return 0
def is_float(element: str) -> bool:
try:
float(element)
return True
except ValueError:
return False

View File

@ -3,7 +3,9 @@ import io
import re
from tokenize import String
from helpers import common_helper
from models.item import Item
from models.solver_run import SolverRun
def csv_to_item(items_csv_reader, solver_run):
items = []
@ -17,7 +19,7 @@ def csv_to_item(items_csv_reader, solver_run):
item = {'attributes': []}
# ensure that the b param is formatted correctly
if row[len(headers) - 1] != '' and is_float(row[len(headers) - 1]):
if row[len(headers) - 1] != '' and common_helper.is_float(row[len(headers) - 1]):
for key, col in enumerate(headers):
if solver_run.irt_model.formatted_b_param() == col:
value = float(row[key])
@ -100,11 +102,14 @@ def key_to_uuid(key):
return re.split("_", key)[0]
def solution_items(variables, solver_run):
def solution_items(variables: list, solver_run: SolverRun) -> (list, list):
form_items = []
solver_variables = []
for v in variables:
if v.varValue > 0:
solver_variables.append(v.name)
if 'Item_' in v.name:
item_id = v.name.replace('Item_', '')
item = solver_run.get_item(int(item_id))
@ -118,17 +123,9 @@ def solution_items(variables, solver_run):
for item in bundle.items:
if item: form_items.append(item)
return form_items
return form_items, solver_variables
def print_problem_variables(problem):
# Uncomment this as needed in local dev
# print(problem);
for v in problem.variables(): print(v.name, "=", v.varValue);
# probably a better place for this...
def is_float(element: String) -> bool:
try:
float(element)
return True
except ValueError:
return False
for v in problem.variables(): print(v.name, "=", v.varValue)