def test_can_handle_request_whose_edge_demand_exceeds_all_substrate_capacities(self):
self.request.edge[("m", "p")]["demand"] = 10 ** 10
scenario = datamodel.Scenario("test_scenario", self.substrate, [self.request],
objective=datamodel.Objective.MAX_PROFIT)
mc_ecg = modelcreator_ecg_decomposition.ModelCreatorCactusDecomposition(scenario)
mc_ecg.init_model_creator()
sol = mc_ecg.compute_fractional_solution()
assert mc_ecg.model.getAttr(GRB.Attr.ObjVal) == pytest.approx(1000.0) # Can be solved by colocation
# forbid colocation => should become infeasible
self.request.set_allowed_nodes("m", {"u"})
self.request.set_allowed_nodes("p", {"v"})
mc_ecg = modelcreator_ecg_decomposition.ModelCreatorCactusDecomposition(scenario)
mc_ecg.init_model_creator()
sol = mc_ecg.compute_fractional_solution()
assert mc_ecg.model.getAttr(GRB.Attr.ObjVal) == pytest.approx(0.0) # Cannot be solved by colocation
modelcreator_ecg_decomposition_test.py 文件源码
python
阅读 23
收藏 0
点赞 0
评论 0
评论列表
文章目录