fix for non bundles runs as well as some typing
This commit is contained in:
parent
2576c982e0
commit
24168f6bbb
@ -1,12 +1,14 @@
|
||||
from pulp import lpSum
|
||||
from pulp import lpSum, LpProblem
|
||||
from random import randint, sample
|
||||
import logging
|
||||
|
||||
from models.bundle import Bundle
|
||||
from models.solver_run import SolverRun
|
||||
from models.item import Item
|
||||
|
||||
from lib.errors.item_generation_error import ItemGenerationError
|
||||
|
||||
def build_constraints(solver_run, problem, items, bundles):
|
||||
def build_constraints(solver_run: SolverRun, problem: LpProblem, items: list[Item]) -> LpProblem:
|
||||
logging.info('Creating Constraints...')
|
||||
|
||||
try:
|
||||
|
@ -25,7 +25,7 @@ class LoftService(Base):
|
||||
logging.error(error)
|
||||
self.result = self.stream_to_s3_bucket(ItemGenerationError("Provided params causing error in calculation results"))
|
||||
|
||||
def create_solver_run_from_attributes(self):
|
||||
def create_solver_run_from_attributes(self) -> SolverRun:
|
||||
logging.info('Retrieving attributes from message...')
|
||||
# get s3 object
|
||||
self.key = aws_helper.get_key_from_message(self.source)
|
||||
@ -52,7 +52,7 @@ class LoftService(Base):
|
||||
|
||||
return solver_run
|
||||
|
||||
def generate_solution(self):
|
||||
def generate_solution(self) -> Solution:
|
||||
logging.info('Generating Solution...')
|
||||
|
||||
# unsolved solution
|
||||
@ -70,8 +70,8 @@ class LoftService(Base):
|
||||
# setup vars
|
||||
items = LpVariable.dicts(
|
||||
"Item", [item.id for item in self.solver_run.items], lowBound=1, upBound=1, cat='Binary')
|
||||
bundles = LpVariable.dicts(
|
||||
"Bundle", [bundle.id for bundle in self.solver_run.bundles], lowBound=1, upBound=1, cat='Binary')
|
||||
# bundles = LpVariable.dicts(
|
||||
# "Bundle", [bundle.id for bundle in self.solver_run.bundles], lowBound=1, upBound=1, cat='Binary')
|
||||
|
||||
problem_objection_functions = []
|
||||
|
||||
@ -87,7 +87,7 @@ class LoftService(Base):
|
||||
for item in self.solver_run.items]) == self.solver_run.total_form_items, 'Total form items'
|
||||
|
||||
# dynamic constraints
|
||||
problem = solver_helper.build_constraints(self.solver_run, problem, items, bundles)
|
||||
problem = solver_helper.build_constraints(self.solver_run, problem, items)
|
||||
|
||||
# multi-objective constraints
|
||||
logging.info('Creating TIF and TCC constraints')
|
||||
|
Loading…
x
Reference in New Issue
Block a user