Skip to content

Instantly share code, notes, and snippets.

@goghino
Created August 28, 2020 18:17
Show Gist options
  • Save goghino/06d97bc286f11f7c163485597c6a13c7 to your computer and use it in GitHub Desktop.
Save goghino/06d97bc286f11f7c163485597c6a13c7 to your computer and use it in GitHub Desktop.
(UnitCommitment) Juraj@Manin (master):~/Documents/Optimization/pyomo/Egret/egret/models/tests$ pytest test_unit_commitment.py
=========================================== test session starts ============================================
platform darwin -- Python 3.8.5, pytest-6.0.1, py-1.9.0, pluggy-0.13.1
rootdir: /Users/Juraj/Documents/Optimization/pyomo/Egret
collected 21 items
test_unit_commitment.py F.................... [100%]
================================================= FAILURES =================================================
__________________________________________ test_int_all_uc_models __________________________________________
@unittest.skipUnless(comm_mip_avail, "Neither Gurobi or CPLEX solver is available")
def test_int_all_uc_models():
_test_uc_model(create_tight_unit_commitment_model)
_test_uc_model(create_compact_unit_commitment_model)
_test_uc_model(create_KOW_unit_commitment_model)
_test_uc_model(create_ALS_unit_commitment_model)
_test_uc_model(create_MLR_unit_commitment_model)
_test_uc_model(create_random1_unit_commitment_model)
_test_uc_model(create_random2_unit_commitment_model)
_test_uc_model(create_OAV_unit_commitment_model)
> _test_uc_model(create_OAV_tighter_unit_commitment_model)
test_unit_commitment.py:95:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
uc_model = <function create_OAV_tighter_unit_commitment_model at 0x7fd774552280>, relax = False
test_objvals = [4201915.017320504, 5454367.7670904165, 5999272.361123627, 5461120.3231092375, 6062406.32677043]
def _test_uc_model(uc_model, relax=False, test_objvals=test_int_objvals):
for test_case, ref_objval in zip(test_cases, test_objvals):
md_dict = json.load(open(test_case,'r'))
md = ModelData(md_dict)
model = uc_model(md, relaxed=relax)
opt = SolverFactory(test_solver)
_set_options(opt, mipgap=0.0)
if isinstance(opt, PersistentSolver):
opt.set_instance(model)
result = opt.solve(model, tee=False)
assert result.solver.termination_condition == TerminationCondition.optimal
> assert math.isclose(ref_objval, result.problem.upper_bound, rel_tol=rel_tol)
E AssertionError: assert False
E + where False = <built-in function isclose>(4201915.017320504, 4202208.2790861, rel_tol=1e-08)
E + where <built-in function isclose> = math.isclose
E + and 4202208.2790861 = <pyomo.opt.results.container.ListContainer object at 0x7fd776013e80>.upper_bound
E + where <pyomo.opt.results.container.ListContainer object at 0x7fd776013e80> = {'Problem': [{'Name': 'unknown', 'Lower bound': 4202208.2790861, 'Upper bound': 4202208.2790861, 'Number of objectives...': 14.349226951599121}], 'Solution': [OrderedDict([('number of solutions', 0), ('number of solutions displayed', 0)])]}.problem
test_unit_commitment.py:74: AssertionError
------------------------------------------- Captured stdout call -------------------------------------------
WARNING: Polynomial cost curves will be approximated using piecewise segments
WARNING: Polynomial cost curves will be approximated using piecewise segments
WARNING: Polynomial cost curves will be approximated using piecewise segments
WARNING: Polynomial cost curves will be approximated using piecewise segments
WARNING: Polynomial cost curves will be approximated using piecewise segments
WARNING: Polynomial cost curves will be approximated using piecewise segments
WARNING: Polynomial cost curves will be approximated using piecewise segments
WARNING: Polynomial cost curves will be approximated using piecewise segments
WARNING: Polynomial cost curves will be approximated using piecewise segments
WARNING: Polynomial cost curves will be approximated using piecewise segments
WARNING: Polynomial cost curves will be approximated using piecewise segments
WARNING: Polynomial cost curves will be approximated using piecewise segments
WARNING: Polynomial cost curves will be approximated using piecewise segments
WARNING: Polynomial cost curves will be approximated using piecewise segments
WARNING: Polynomial cost curves will be approximated using piecewise segments
WARNING: Polynomial cost curves will be approximated using piecewise segments
WARNING: Polynomial cost curves will be approximated using piecewise segments
WARNING: Polynomial cost curves will be approximated using piecewise segments
WARNING: Polynomial cost curves will be approximated using piecewise segments
WARNING: Polynomial cost curves will be approximated using piecewise segments
WARNING: Polynomial cost curves will be approximated using piecewise segments
WARNING: Polynomial cost curves will be approximated using piecewise segments
WARNING: Polynomial cost curves will be approximated using piecewise segments
WARNING: Polynomial cost curves will be approximated using piecewise segments
WARNING: Polynomial cost curves will be approximated using piecewise segments
WARNING: Polynomial cost curves will be approximated using piecewise segments
WARNING: Polynomial cost curves will be approximated using piecewise segments
WARNING: Polynomial cost curves will be approximated using piecewise segments
WARNING: Polynomial cost curves will be approximated using piecewise segments
WARNING: Polynomial cost curves will be approximated using piecewise segments
WARNING: Polynomial cost curves will be approximated using piecewise segments
WARNING: Polynomial cost curves will be approximated using piecewise segments
WARNING: Polynomial cost curves will be approximated using piecewise segments
WARNING: Polynomial cost curves will be approximated using piecewise segments
WARNING: Polynomial cost curves will be approximated using piecewise segments
WARNING: Polynomial cost curves will be approximated using piecewise segments
WARNING: Polynomial cost curves will be approximated using piecewise segments
WARNING: Polynomial cost curves will be approximated using piecewise segments
WARNING: Polynomial cost curves will be approximated using piecewise segments
WARNING: Polynomial cost curves will be approximated using piecewise segments
WARNING: Polynomial cost curves will be approximated using piecewise segments
-------------------------------------------- Captured log call ---------------------------------------------
WARNING egret:params.py:862 WARNING: Polynomial cost curves will be approximated using piecewise segments
WARNING egret:params.py:862 WARNING: Polynomial cost curves will be approximated using piecewise segments
WARNING egret:params.py:862 WARNING: Polynomial cost curves will be approximated using piecewise segments
WARNING egret:params.py:862 WARNING: Polynomial cost curves will be approximated using piecewise segments
WARNING egret:params.py:862 WARNING: Polynomial cost curves will be approximated using piecewise segments
WARNING egret:params.py:862 WARNING: Polynomial cost curves will be approximated using piecewise segments
WARNING egret:params.py:862 WARNING: Polynomial cost curves will be approximated using piecewise segments
WARNING egret:params.py:862 WARNING: Polynomial cost curves will be approximated using piecewise segments
WARNING egret:params.py:862 WARNING: Polynomial cost curves will be approximated using piecewise segments
WARNING egret:params.py:862 WARNING: Polynomial cost curves will be approximated using piecewise segments
WARNING egret:params.py:862 WARNING: Polynomial cost curves will be approximated using piecewise segments
WARNING egret:params.py:862 WARNING: Polynomial cost curves will be approximated using piecewise segments
WARNING egret:params.py:862 WARNING: Polynomial cost curves will be approximated using piecewise segments
WARNING egret:params.py:862 WARNING: Polynomial cost curves will be approximated using piecewise segments
WARNING egret:params.py:862 WARNING: Polynomial cost curves will be approximated using piecewise segments
WARNING egret:params.py:862 WARNING: Polynomial cost curves will be approximated using piecewise segments
WARNING egret:params.py:862 WARNING: Polynomial cost curves will be approximated using piecewise segments
WARNING egret:params.py:862 WARNING: Polynomial cost curves will be approximated using piecewise segments
WARNING egret:params.py:862 WARNING: Polynomial cost curves will be approximated using piecewise segments
WARNING egret:params.py:862 WARNING: Polynomial cost curves will be approximated using piecewise segments
WARNING egret:params.py:862 WARNING: Polynomial cost curves will be approximated using piecewise segments
WARNING egret:params.py:862 WARNING: Polynomial cost curves will be approximated using piecewise segments
WARNING egret:params.py:862 WARNING: Polynomial cost curves will be approximated using piecewise segments
WARNING egret:params.py:862 WARNING: Polynomial cost curves will be approximated using piecewise segments
WARNING egret:params.py:862 WARNING: Polynomial cost curves will be approximated using piecewise segments
WARNING egret:params.py:862 WARNING: Polynomial cost curves will be approximated using piecewise segments
WARNING egret:params.py:862 WARNING: Polynomial cost curves will be approximated using piecewise segments
WARNING egret:params.py:862 WARNING: Polynomial cost curves will be approximated using piecewise segments
WARNING egret:params.py:862 WARNING: Polynomial cost curves will be approximated using piecewise segments
WARNING egret:params.py:862 WARNING: Polynomial cost curves will be approximated using piecewise segments
WARNING egret:params.py:862 WARNING: Polynomial cost curves will be approximated using piecewise segments
WARNING egret:params.py:862 WARNING: Polynomial cost curves will be approximated using piecewise segments
WARNING egret:params.py:862 WARNING: Polynomial cost curves will be approximated using piecewise segments
WARNING egret:params.py:862 WARNING: Polynomial cost curves will be approximated using piecewise segments
WARNING egret:params.py:862 WARNING: Polynomial cost curves will be approximated using piecewise segments
WARNING egret:params.py:862 WARNING: Polynomial cost curves will be approximated using piecewise segments
WARNING egret:params.py:862 WARNING: Polynomial cost curves will be approximated using piecewise segments
WARNING egret:params.py:862 WARNING: Polynomial cost curves will be approximated using piecewise segments
WARNING egret:params.py:862 WARNING: Polynomial cost curves will be approximated using piecewise segments
WARNING egret:params.py:862 WARNING: Polynomial cost curves will be approximated using piecewise segments
WARNING egret:params.py:862 WARNING: Polynomial cost curves will be approximated using piecewise segments
============================================= warnings summary =============================================
/Users/Juraj/anaconda3/envs/UnitCommitment/lib/python3.8/site-packages/pyutilib/misc/import_file.py:11
/Users/Juraj/anaconda3/envs/UnitCommitment/lib/python3.8/site-packages/pyutilib/misc/import_file.py:11: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses
import imp
-- Docs: https://docs.pytest.org/en/stable/warnings.html
========================================= short test summary info ==========================================
FAILED test_unit_commitment.py::test_int_all_uc_models - AssertionError: assert False
=========================== 1 failed, 20 passed, 1 warning in 2765.15s (0:46:05) ===========================
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment