コード例 #1
0
    def test_log_file_shows_warm_start_failure(self):
        log_file_text = """
Warning:  No solution found from 1 MIP starts.
"""
        with open(self.solver._log_file, "w") as f:
            f.write(log_file_text)

        results = CPLEXSHELL.process_logfile(self.solver)
        self.assertEqual(results.solver.mip_start_failed, True)
コード例 #2
0
    def test_log_file_shows_n_solutions_found_when_single(self):
        log_file_text = """
Solution pool: 1 solution saved.
 """
        with open(self.solver._log_file, "w") as f:
            f.write(log_file_text)

        results = CPLEXSHELL.process_logfile(self.solver)
        self.assertEqual(results.solver.n_solutions_found, 1)
コード例 #3
0
    def test_log_file_shows_number_of_binary_variables_when_integer_variables_are_present(
            self):
        log_file_text = """
Variables : 7 [Nneg: 1, Binary: 4, General Integer: 2]
 """
        with open(self.solver._log_file, "w") as f:
            f.write(log_file_text)

        results = CPLEXSHELL.process_logfile(self.solver)
        self.assertEqual(results.problem.number_of_binary_variables, 4)
コード例 #4
0
    def test_log_file_shows_warm_start_objective_value(self):
        log_file_text = """
1 of 1 MIP starts provided solutions.
MIP start 'm1' defined initial solution with objective 25210.5363.
"""
        with open(self.solver._log_file, "w") as f:
            f.write(log_file_text)

        results = CPLEXSHELL.process_logfile(self.solver)
        self.assertEqual(results.solver.warm_start_objective_value, 25210.5363)
コード例 #5
0
    def test_log_file_shows_number_of_continuous_variables(self):
        log_file_text = """
Objective sense      : Minimize
Variables            :     506  [Nneg: 206,  Binary: 300]
Objective nonzeros   :      32
 """
        with open(self.solver._log_file, "w") as f:
            f.write(log_file_text)

        results = CPLEXSHELL.process_logfile(self.solver)
        self.assertEqual(results.problem.number_of_continuous_variables, 206)
コード例 #6
0
    def test_log_file_shows_tree_processing_time_when_sequential(self):
        log_file_text = """
Presolve time = 0.14 sec. (181.11 ticks)

Root node processing (before b&c):
  Real time             =    123.45 sec. (211.39 ticks)
Sequential b&c:
  Real time             =    67.89 sec. (56.98 ticks)
  Sync time (average)   =    0.00 sec.
  Wait time (average)   =    0.00 sec.
                          ------------
Total (root+branch&cut) =    191.34 sec. (268.37 ticks)
 """
        with open(self.solver._log_file, "w") as f:
            f.write(log_file_text)

        results = CPLEXSHELL.process_logfile(self.solver)
        self.assertEqual(results.solver.tree_processing_time, 67.89)
コード例 #7
0
    def test_log_file_shows_max_deterministic_time_limit_exceeded_with_feasible_solution(
            self):
        log_file_text = """
MIP - Deterministic time limit exceeded, integer feasible:  Objective =  0.0000000000e+00
Current MIP best bound =  0.0000000000e+00 (gap = 10.0, 10.00%)
Solution time =   10.00 sec.  Iterations = 10000  Nodes = 1000 (1)
Deterministic time = 100.00 ticks  (10.00 ticks/sec)

CPLEX> Incumbent solution written to file '/var/folders/_x/xxxx/T/tmpxxx.cplex.sol'.
CPLEX>"""
        with open(self.solver._log_file, "w") as f:
            f.write(log_file_text)

        results = CPLEXSHELL.process_logfile(self.solver)
        self.assertEqual(results.solver.status, SolverStatus.ok)
        self.assertEqual(results.solver.termination_condition,
                         TerminationCondition.maxTimeLimit)
        self.assertEqual(results.solver.deterministic_time, 100.00)
コード例 #8
0
    def test_log_file_shows_infeasible(self):
        log_file_text = """
MIP - Integer infeasible.
Current MIP best bound =  0.0000000000e+00 (gap is infinite)
Solution time =    0.00 sec.  Iterations = 0  Nodes = 0
Deterministic time = 0.00 ticks  (0.20 ticks/sec)

CPLEX> CPLEX Error  1217: No solution exists.
No file written.
CPLEX>"""
        with open(self.solver._log_file, "w") as f:
            f.write(log_file_text)

        results = CPLEXSHELL.process_logfile(self.solver)
        self.assertEqual(results.solver.status, SolverStatus.warning)
        self.assertEqual(results.solver.termination_condition,
                         TerminationCondition.infeasible)
        self.assertEqual(results.solver.termination_message,
                         "MIP - Integer infeasible.")
        self.assertEqual(results.solver.return_code, 1217)
コード例 #9
0
    def test_log_file_shows_presolve_infeasible(self):
        log_file_text = """
Infeasibility row 'c_e_x18_':  0  = -1.
Presolve time = 0.00 sec. (0.00 ticks)
Presolve - Infeasible.
Solution time =    0.00 sec.
Deterministic time = 0.00 ticks  (0.61 ticks/sec)
CPLEX> CPLEX Error  1217: No solution exists.
No file written.
CPLEX>"""

        with open(self.solver._log_file, "w") as f:
            f.write(log_file_text)

        results = CPLEXSHELL.process_logfile(self.solver)
        self.assertEqual(results.solver.status, SolverStatus.warning)
        self.assertEqual(results.solver.termination_condition,
                         TerminationCondition.infeasible)
        self.assertEqual(results.solver.termination_message,
                         "Presolve - Infeasible.")
        self.assertEqual(results.solver.return_code, 1217)