handle n enemy cleansing runs
This commit is contained in:
parent
c15345867d
commit
eef86369ab
@ -41,7 +41,7 @@ class Problem(BaseModel):
|
||||
upBound=1,
|
||||
cat='Binary')
|
||||
|
||||
def solve(self, solver_run: SolverRun) -> LpProblem:
|
||||
def solve(self, solver_run: SolverRun, enemy_ids: List[int] = []) -> LpProblem:
|
||||
logging.info('solving problem...')
|
||||
# if we allow enemies, go through the normal solving process
|
||||
if solver_run.allow_enemies:
|
||||
@ -60,11 +60,17 @@ class Problem(BaseModel):
|
||||
# get items from solution
|
||||
solved_items, _ = service_helper.solution_items(self.problem.variables(), solver_run)
|
||||
|
||||
sacred_ids, enemy_ids = sanctify(solved_items)
|
||||
# sacred items will remain the same between solve attempts
|
||||
# but new enemies will be appended
|
||||
sacred_ids, new_enemy_ids = sanctify(solved_items)
|
||||
|
||||
if enemy_ids:
|
||||
# the current solve run found new enemies
|
||||
if new_enemy_ids:
|
||||
logging.info('enemies found, adding constraints...')
|
||||
|
||||
# append the new enemies to the enemies_id list
|
||||
enemy_ids = list(set(enemy_ids+new_enemy_ids))
|
||||
|
||||
# remove old enemy/sacred constraints
|
||||
if 'Exclude_enemy_items' in self.problem.constraints.keys(): self.problem.constraints.pop('Exclude_enemy_items')
|
||||
if 'Include_sacred_items' in self.problem.constraints.keys(): self.problem.constraints.pop('Include_sacred_items')
|
||||
|
Loading…
x
Reference in New Issue
Block a user