added constant drift incrementing for tcc, tif values

This commit is contained in:
Joshua Burman
2022-02-12 03:43:37 -05:00
parent 46d3538690
commit f18e048081
6 changed files with 152 additions and 109 deletions

View File

@ -12,3 +12,32 @@ class ObjectiveFunction(BaseModel):
tcc_targets: List[Target]
objective: AnyStr = "minimize"
weight: Dict = {'tif': 1, 'tcc': 1}
def increment_targets_drift(self,
limit: float or bool,
all: bool = False,
amount: float = 0.1,
targets: list[Target] = []) -> bool:
if all:
for target in self.tif_targets:
target.drift = round(target.drift + amount, 2)
for target in self.tcc_targets:
target.drift = round(target.drift + amount, 2)
else:
for target in targets:
target.drift = round(target.drift + amount, 2)
print(self.tif_targets)
print(self.tcc_targets)
return amount
def minimum_drift(self) -> float:
minimum_drift = 0.0
for target in self.all_targets():
if target.drift < minimum_drift:
minimum_drift = target.drift
return minimum_drift
def all_targets(self) -> list[Target]:
return self.tif_targets + self.tcc_targets

View File

@ -1,5 +1,5 @@
from pydantic import BaseModel
from typing import List, Optional
from typing import List, Literal, Optional
import logging
@ -20,6 +20,7 @@ class SolverRun(BaseModel):
total_form_items: int
total_forms: int = 1
theta_cut_score: float = 0.00
drift_style: Literal['constant', 'variable'] = 'constant'
advanced_options: Optional[AdvancedOptions]
engine: str

View File

@ -6,3 +6,4 @@ class Target(BaseModel):
theta: float
value: float
result: Optional[float]
drift: float = 0.0