Merge branch 'release/1.3'
This commit is contained in:
commit
c23758bd0b
@ -6,6 +6,10 @@ RUN python -m pip install pulp
|
||||
RUN python -m pip install pydantic
|
||||
RUN python -m pip install daemonize
|
||||
RUN python -m pip install sqspy
|
||||
RUN python -m pip install -U pytest
|
||||
RUN python -m pip install pytest-cov
|
||||
RUN python -m pip install pytest-stub
|
||||
RUN python -m pip install pytest-mock
|
||||
|
||||
RUN mkdir /app
|
||||
WORKDIR /app
|
||||
|
@ -6,6 +6,10 @@ RUN python -m pip install pulp
|
||||
RUN python -m pip install pydantic
|
||||
RUN python -m pip install daemonize
|
||||
RUN python -m pip install sqspy
|
||||
RUN python -m pip install -U pytest
|
||||
RUN python -m pip install pytest-cov
|
||||
RUN python -m pip install pytest-stub
|
||||
RUN python -m pip install pytest-mock
|
||||
|
||||
RUN mkdir /app
|
||||
WORKDIR /app
|
||||
|
@ -27,8 +27,6 @@ class ObjectiveFunction(BaseModel):
|
||||
else:
|
||||
for target in targets:
|
||||
target.drift = round(target.drift + amount, 2)
|
||||
print(self.tif_targets)
|
||||
print(self.tcc_targets)
|
||||
return amount
|
||||
|
||||
def update_targets_drift(self, amount: float = 0.0):
|
||||
|
60
app/test/test_example.py
Normal file
60
app/test/test_example.py
Normal file
@ -0,0 +1,60 @@
|
||||
# content of example.py
|
||||
from pulp import LpProblem, LpVariable, LpMinimize, LpStatus, lpSum
|
||||
|
||||
|
||||
def func(x):
|
||||
return x + 1
|
||||
|
||||
|
||||
def test_pass():
|
||||
assert func(4) == 5
|
||||
|
||||
|
||||
def test_failure():
|
||||
assert func(3) == 5
|
||||
|
||||
|
||||
def yosh_loop():
|
||||
Items = [1, 2, 3, 4, 5]
|
||||
tif = {1: 0.2, 2: 0.5, 3: 0.3, 4: 0.8, 5: 0.1}
|
||||
iif = {1: 0.09, 2: 0.2, 3: 0.113, 4: 0.3, 5: 0.1}
|
||||
drift = 0.0
|
||||
drift_limit = 0.2
|
||||
iif_target = 0.5
|
||||
tif_target = 0.9
|
||||
item_vars = LpVariable.dicts("Item", Items, cat="Binary")
|
||||
result = 'Infeasible'
|
||||
|
||||
while drift <= drift_limit:
|
||||
prob = LpProblem("tif_tcc_test", LpMinimize)
|
||||
prob += lpSum([(tif[i] + iif[i]) * item_vars[i]
|
||||
for i in Items]), "TifTccSum"
|
||||
prob += lpSum([item_vars[i] for i in Items]) == 3, "TotalItems"
|
||||
prob += lpSum([tif[i] * item_vars[i] for i in Items
|
||||
]) >= tif_target - (tif_target * drift), 'TifMin'
|
||||
prob += lpSum([tif[i] * item_vars[i] for i in Items
|
||||
]) <= tif_target + (tif_target * drift), 'TifMax'
|
||||
prob += lpSum([iif[i] * item_vars[i] for i in Items
|
||||
]) >= iif_target - (iif_target * drift), 'TccMin'
|
||||
prob += lpSum([iif[i] * item_vars[i] for i in Items
|
||||
]) <= iif_target + (iif_target * drift), 'TccMax'
|
||||
|
||||
prob.solve()
|
||||
|
||||
if LpStatus[prob.status] == "Infeasible":
|
||||
for v in prob.variables():
|
||||
print(v.name, "=", v.varValue)
|
||||
|
||||
drift += 0.02
|
||||
else:
|
||||
for v in prob.variables():
|
||||
print(v.name, "=", v.varValue)
|
||||
|
||||
result = LpStatus[prob.status]
|
||||
break
|
||||
|
||||
return result
|
||||
|
||||
|
||||
def test_solver():
|
||||
assert yosh_loop() == 'Optimal'
|
Loading…
x
Reference in New Issue
Block a user