예제 #1
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]
                 )
예제 #2
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]
         )
예제 #3
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])
예제 #4
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])
예제 #5
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)
예제 #6
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)
예제 #7
0
 def test_isProvenPrimalInfeasible(self):
     for solver in yaposib.available_solvers():
         prob = infeasible(solver)
         yaposibTestCheck(prob, ["infeasible", "limitreached"])
         if (not prob.isProvenPrimalInfeasible):
             raise yaposib.YaposibError
예제 #8
0
 def test_isAbandoned(self):
     for solver in yaposib.available_solvers():
         prob = continuous(solver)
         if (not prob.isAbandoned):
             raise yaposib.YaposibError
예제 #9
0
 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
예제 #10
0
 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])
예제 #11
0
 def test_isDualObjectiveLimitReached(self):
     for solver in yaposib.available_solvers():
         prob = infeasible(solver)
         yaposibTestCheck(prob, ["infeasible", "limitreached"])
         if (not prob.isDualObjectiveLimitReached):
             raise yaposib.YaposibError
예제 #12
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])
예제 #13
0
 def test_unbounded(self):
     for solver in yaposib.available_solvers():
         prob = unbounded(solver)
         yaposibTestCheck(prob, ["infeasible"])
예제 #14
0
 def test_feasability_only(self):
     for solver in yaposib.available_solvers():
         prob = feasability_only(solver)
         yaposibTestCheck(prob, ["optimal"])
예제 #15
0
 def test_integer_infeasible(self):
     for solver in yaposib.available_solvers():
         prob = integer_infeasible(solver)
         yaposibTestCheck(prob, ["infeasible", "limitreached"],
                          solve_as_MIP=True)
예제 #16
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)
예제 #17
0
 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])
예제 #18
0
 def test_unbounded(self):
     for solver in yaposib.available_solvers():
         prob = unbounded(solver)
         yaposibTestCheck(prob, ["infeasible"])
예제 #19
0
 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])
예제 #20
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])
예제 #21
0
 def test_isProvenDualInfeasible(self):
     for solver in yaposib.available_solvers():
         prob = unbounded(solver)
         yaposibTestCheck(prob, ["infeasible"])
         if (not prob.isProvenDualInfeasible):
             raise yaposib.YaposibError
예제 #22
0
 def test_integer_infeasible(self):
     for solver in yaposib.available_solvers():
         prob = integer_infeasible(solver)
         yaposibTestCheck(prob, ["infeasible", "limitreached"], solve_as_MIP = True)
예제 #23
0
 def test_isDualObjectiveLimitReached(self):
     for solver in yaposib.available_solvers():
         prob = infeasible(solver)
         yaposibTestCheck(prob, ["infeasible", "limitreached"])
         if (not prob.isDualObjectiveLimitReached):
             raise yaposib.YaposibError
예제 #24
0
 def test_isAbandoned(self):
     for solver in yaposib.available_solvers():
         prob = continuous(solver)
         if (not prob.isAbandoned):
             raise yaposib.YaposibError
예제 #25
0
 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])
예제 #26
0
 def test_isProvenPrimalInfeasible(self):
     for solver in yaposib.available_solvers():
         prob = infeasible(solver)
         yaposibTestCheck(prob, ["infeasible", "limitreached"])
         if (not prob.isProvenPrimalInfeasible):
             raise yaposib.YaposibError
예제 #27
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)
예제 #28
0
 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
예제 #29
0
 def test_feasability_only(self):
     for solver in yaposib.available_solvers():
         prob = feasability_only(solver)
         yaposibTestCheck(prob, ["optimal"])
예제 #30
0
 def test_isProvenDualInfeasible(self):
     for solver in yaposib.available_solvers():
         prob = unbounded(solver)
         yaposibTestCheck(prob, ["infeasible"])
         if (not prob.isProvenDualInfeasible):
             raise yaposib.YaposibError
예제 #31
0
 def test_available_solvers(self):
     self.failIfEqual(yaposib.available_solvers(), [])
예제 #32
0
 def test_available_solvers(self):
     self.failIfEqual(yaposib.available_solvers(), [])