convert boolean to int to satisfy solver requirements
This commit is contained in:
parent
df517fe7fe
commit
9d15112320
5
app/helpers/common_helper.py
Normal file
5
app/helpers/common_helper.py
Normal file
@ -0,0 +1,5 @@
|
||||
def boolean_to_int(value: bool) -> int:
|
||||
if value:
|
||||
return 1
|
||||
else:
|
||||
return 0
|
@ -3,6 +3,8 @@ from random import randint, sample
|
||||
|
||||
import logging
|
||||
|
||||
from helpers.common_helper import *
|
||||
|
||||
from models.bundle import Bundle
|
||||
from models.solver_run import SolverRun
|
||||
from models.item import Item
|
||||
@ -26,7 +28,7 @@ def build_constraints(solver_run: SolverRun, problem: LpProblem,
|
||||
logging.info('Metadata Constraint Generating...')
|
||||
con = dict(
|
||||
zip([item.id for item in solver_run.items], [
|
||||
item.attribute_exists(attribute)
|
||||
boolean_to_int(item.attribute_exists(attribute))
|
||||
for item in solver_run.items
|
||||
]))
|
||||
problem += lpSum(
|
||||
|
Loading…
x
Reference in New Issue
Block a user