def test_pulp_123(self): """ Test the ability to use Elastic constraints (penalty unbounded) """ prob = LpProblem("test123", const.LpMinimize) x = LpVariable("x", 0, 4) y = LpVariable("y", -1, 1) z = LpVariable("z", 0) w = LpVariable("w") prob += x + 4 * y + 9 * z + w, "obj" prob += x + y <= 5, "c1" prob += x + z >= 10, "c2" prob += -y + z == 7, "c3" prob.extend((w >= -1).makeElasticSubProblem(penalty=0.9)) print("\t Testing elastic constraints (penalty unbounded)") if self.solver.__class__ in [COINMP_DLL, GUROBI, CPLEX_CMD, YAPOSIB, MOSEK]: # COINMP_DLL Does not report unbounded problems, correctly pulpTestCheck( prob, self.solver, [const.LpStatusInfeasible, const.LpStatusUnbounded] ) elif self.solver.__class__ is GLPK_CMD: # GLPK_CMD Does not report unbounded problems, correctly pulpTestCheck(prob, self.solver, [const.LpStatusUndefined]) elif self.solver.__class__ in [CPLEX_DLL, GUROBI_CMD, SCIP_CMD]: # GLPK_CMD Does not report unbounded problems, correctly pulpTestCheck(prob, self.solver, [const.LpStatusNotSolved]) elif self.solver.__class__ in [PULP_CHOCO_CMD, CHOCO_CMD]: # choco bounds all variables. Would not return unbounded status pass else: pulpTestCheck(prob, self.solver, [const.LpStatusUnbounded])
def test_pulp_122(self): """ Test the ability to use Elastic constraints (penalty unchanged) """ prob = LpProblem("test122", const.LpMinimize) x = LpVariable("x", 0, 4) y = LpVariable("y", -1, 1) z = LpVariable("z", 0) w = LpVariable("w") prob += x + 4 * y + 9 * z + w, "obj" prob += x + y <= 5, "c1" prob += x + z >= 10, "c2" prob += -y + z == 7, "c3" prob.extend((w >= -1).makeElasticSubProblem(penalty=1.1)) print("\t Testing elastic constraints (penalty unchanged)") pulpTestCheck(prob, self.solver, [const.LpStatusOptimal], {x: 4, y: -1, z: 6, w: -1.0})