def test_duals_and_slacks(self): for solver in yaposib.available_solvers(): prob = duals_and_slacks(solver) yaposibTestCheck(prob, ["optimal"], sol=[4, -1, 6], reducedcosts=[0, 12, 0], duals=[0, 1, 8], #slacks=[2, 0, 0] )
def test_duals_and_slacks(self): for solver in yaposib.available_solvers(): prob = duals_and_slacks(solver) yaposibTestCheck( prob, ["optimal"], sol=[4, -1, 6], reducedcosts=[0, 12, 0], duals=[0, 1, 8], #slacks=[2, 0, 0] )
def test_HotStart(self): """ Tests the hotstart feature. 1) solve, get a hotstart 2) wipe and resolve, knowing a hotstart now exists 3) wipe and unmark the hotstart, resolve again """ for solver in yaposib.available_solvers(): prob = continuous(solver) prob.solve() yaposibTestCheck(prob, ["optimal"], sol = [4.0, -1.0, 6.0, 0.0]) wipe_solution(prob) prob.markHotStart() #time = -clock() prob.solve() #time += clock() yaposibTestCheck(prob, ["optimal"], sol = [4.0, -1.0, 6.0, 0.0]) wipe_solution(prob) prob.unmarkHotStart() prob.solve() yaposibTestCheck(prob, ["optimal"], sol = [4.0, -1.0, 6.0, 0.0])
def test_HotStart(self): """ Tests the hotstart feature. 1) solve, get a hotstart 2) wipe and resolve, knowing a hotstart now exists 3) wipe and unmark the hotstart, resolve again """ for solver in yaposib.available_solvers(): prob = continuous(solver) prob.solve() yaposibTestCheck(prob, ["optimal"], sol=[4.0, -1.0, 6.0, 0.0]) wipe_solution(prob) prob.markHotStart() #time = -clock() prob.solve() #time += clock() yaposibTestCheck(prob, ["optimal"], sol=[4.0, -1.0, 6.0, 0.0]) wipe_solution(prob) prob.unmarkHotStart() prob.solve() yaposibTestCheck(prob, ["optimal"], sol=[4.0, -1.0, 6.0, 0.0])
def test_writeLp(self): lpfile = ["\Problem name: ", "", "Minimize", "OBJROW: x + 4 y + 9 z", "Subject To", "c1: x + y <= 5", "c2: x + z >= 10", "c3: - y + z = 7", "c4: w >= 0", "Bounds", " 0 <= x <= 4", " -1 <= y <= 1", "End",] for solver in yaposib.available_solvers(): prob = continuous(solver) prob.writeLp("debug") with open("debug.lp", "r") as f: for line, ref in zip(f, lpfile): if line.strip() != ref.strip(): error_msg = "\t%s != %s" % (line.strip(), ref.strip()) raise yaposib.YaposibError(error_msg)
def test_writeLp(self): lpfile = [ "\Problem name: ", "", "Minimize", "OBJROW: x + 4 y + 9 z", "Subject To", "c1: x + y <= 5", "c2: x + z >= 10", "c3: - y + z = 7", "c4: w >= 0", "Bounds", " 0 <= x <= 4", " -1 <= y <= 1", "End", ] for solver in yaposib.available_solvers(): prob = continuous(solver) prob.writeLp("debug") with open("debug.lp", "r") as f: for line, ref in zip(f, lpfile): if line.strip() != ref.strip(): error_msg = "\t%s != %s" % (line.strip(), ref.strip()) raise yaposib.YaposibError(error_msg)
def test_isProvenPrimalInfeasible(self): for solver in yaposib.available_solvers(): prob = infeasible(solver) yaposibTestCheck(prob, ["infeasible", "limitreached"]) if (not prob.isProvenPrimalInfeasible): raise yaposib.YaposibError
def test_isAbandoned(self): for solver in yaposib.available_solvers(): prob = continuous(solver) if (not prob.isAbandoned): raise yaposib.YaposibError
def test_isProvenOptimal(self): for solver in yaposib.available_solvers(): prob = continuous(solver) yaposibTestCheck(prob, ["optimal"], sol = [4.0, -1.0, 6.0, 0.0]) if (not prob.isProvenOptimal): raise yaposib.YaposibError
def test_relaxed_mip(self): for solver in yaposib.available_solvers(): prob = mip(solver) prob.obj.name = "relaxed_mip" yaposibTestCheck(prob, ["optimal"], [3.5, -1, 6.5])
def test_isDualObjectiveLimitReached(self): for solver in yaposib.available_solvers(): prob = infeasible(solver) yaposibTestCheck(prob, ["infeasible", "limitreached"]) if (not prob.isDualObjectiveLimitReached): raise yaposib.YaposibError
def test_continuous(self): for solver in yaposib.available_solvers(): prob = continuous(solver) yaposibTestCheck(prob, ["optimal"], sol = [4.0, -1.0, 6.0, 0.0])
def test_unbounded(self): for solver in yaposib.available_solvers(): prob = unbounded(solver) yaposibTestCheck(prob, ["infeasible"])
def test_feasability_only(self): for solver in yaposib.available_solvers(): prob = feasability_only(solver) yaposibTestCheck(prob, ["optimal"])
def test_integer_infeasible(self): for solver in yaposib.available_solvers(): prob = integer_infeasible(solver) yaposibTestCheck(prob, ["infeasible", "limitreached"], solve_as_MIP=True)
def test_mip(self): for solver in yaposib.available_solvers(): prob = mip(solver) yaposibTestCheck(prob, ["optimal"], [3.0, -0.5, 7.0], solve_as_MIP=True)
def test_continuous_maximisation(self): for solver in yaposib.available_solvers(): prob = continuous_maximisation(solver) yaposibTestCheck(prob, ["optimal"], sol=[4.0, 1.0, 8.0, 0.0])
def test_continuous(self): for solver in yaposib.available_solvers(): prob = continuous(solver) yaposibTestCheck(prob, ["optimal"], sol=[4.0, -1.0, 6.0, 0.0])
def test_isProvenDualInfeasible(self): for solver in yaposib.available_solvers(): prob = unbounded(solver) yaposibTestCheck(prob, ["infeasible"]) if (not prob.isProvenDualInfeasible): raise yaposib.YaposibError
def test_integer_infeasible(self): for solver in yaposib.available_solvers(): prob = integer_infeasible(solver) yaposibTestCheck(prob, ["infeasible", "limitreached"], solve_as_MIP = True)
def test_continuous_maximisation(self): for solver in yaposib.available_solvers(): prob = continuous_maximisation(solver) yaposibTestCheck(prob, ["optimal"], sol = [4.0, 1.0, 8.0, 0.0])
def test_mip(self): for solver in yaposib.available_solvers(): prob = mip(solver) yaposibTestCheck(prob, ["optimal"], [3.0, -0.5, 7.0], solve_as_MIP = True)
def test_isProvenOptimal(self): for solver in yaposib.available_solvers(): prob = continuous(solver) yaposibTestCheck(prob, ["optimal"], sol=[4.0, -1.0, 6.0, 0.0]) if (not prob.isProvenOptimal): raise yaposib.YaposibError
def test_available_solvers(self): self.failIfEqual(yaposib.available_solvers(), [])