but when removing enemy constraints
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
from pydantic import BaseModel
|
||||
from pydantic import BaseModel, validator
|
||||
from typing import List, Optional
|
||||
|
||||
from models.attribute import Attribute
|
||||
@ -16,6 +16,13 @@ class Item(BaseModel):
|
||||
b_param: float = 0.00
|
||||
response: Optional[int] = None
|
||||
|
||||
@validator("enemies", pre=True)
|
||||
def set_enemies(cls, v) -> List[id]:
|
||||
if v == "":
|
||||
return []
|
||||
enemies = list(filter(None, [int(enemy) for enemy in v.split(",")]))
|
||||
return enemies
|
||||
|
||||
def iif(self, irt_model, theta):
|
||||
return ItemInformationFunction(irt_model).calculate(b_param=self.b_param, theta=theta)
|
||||
|
||||
|
@ -8,7 +8,6 @@ from pulp import LpProblem, LpVariable, LpStatus, lpSum
|
||||
import logging
|
||||
|
||||
from helpers.problem_helper import *
|
||||
|
||||
from helpers import service_helper
|
||||
|
||||
from models.solution import Solution
|
||||
@ -67,8 +66,8 @@ class Problem(BaseModel):
|
||||
logging.info('enemies found, adding constraints...')
|
||||
|
||||
# remove old enemy/sacred constraints
|
||||
self.problem.constraints.pop('Exclude_enemy_items')
|
||||
self.problem.constraints.pop('Include_sacred_items')
|
||||
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')
|
||||
|
||||
# add constraint to not allow enemy items
|
||||
self.problem += lpSum([
|
||||
|
Reference in New Issue
Block a user