Changeset 2195


Ignore:
Timestamp:
Jan 28, 2010 5:52:52 PM (10 years ago)
Author:
wehart
Message:

Merged revisions 2112-2194 via svnmerge from
https://software.sandia.gov/svn/public/coopr/coopr.plugins/trunk

........

r2168 | jwatson | 2010-01-24 14:07:25 -0700 (Sun, 24 Jan 2010) | 3 lines


Improvements to the CPLEX plugin, mainly in the area of reporting solver status.

........

r2171 | wehart | 2010-01-25 16:56:28 -0700 (Mon, 25 Jan 2010) | 2 lines


Update CPLEX baselines.

........

r2187 | wehart | 2010-01-27 17:40:16 -0700 (Wed, 27 Jan 2010) | 2 lines


A draft NLOPT solver.

........

Location:
coopr.plugins/stable/2.2
Files:
6 edited
1 copied

Legend:

Unmodified
Added
Removed
  • coopr.plugins/stable/2.2

  • coopr.plugins/stable/2.2/coopr/plugins/mip/CPLEX.py

    r2100 r2195  
    2626import xml.dom.minidom
    2727
     28import time
     29
    2830
    2931class CPLEX(ILMLicensedSystemCallSolver):
     
    153155                raise ValueError, "CPLEX _presolve method can only handle a single problem instance - "+str(len(args))+" were supplied"                 
    154156
    155              if self._hasIntegerVariables(args[0]) is True:         
     157             if self._hasIntegerVariables(args[0]) is True:
     158                start_time = time.time()
    156159                self.write_warmstart_file(args[0])
     160                end_time = time.time()
     161                print "Warm start write time="+str(end_time-start_time)+" seconds"
    157162         
    158163       # let the base class handle any remaining keywords/actions.
     
    259264            tokens = re.split('[ \t]+',line.strip())
    260265            if len(tokens) > 3 and tokens[0] == "CPLEX" and tokens[1] == "Error":
     266                # IMPT: See below - cplex can generate an error line and then terminate fine, e.g., in CPLEX 12.1.
     267                #       To handle these cases, we should be specifying some kind of termination criterion always
     268                #       in the course of parsing a log file (we aren't doing so currently - just in some conditions).
    261269                results.solver.status=SolverStatus.error
    262270                results.solver.error = " ".join(tokens)
     
    264272                cplex_version = tokens[2].rstrip(',')
    265273            elif len(tokens) >= 3 and tokens[0] == "Variables":
    266                 if results.problem.number_of_variables is None: # CPLEX 11.2 and subsequent has two Variables sections.
     274                if results.problem.number_of_variables is None: # CPLEX 11.2 and subsequent versions have two Variables sections in the log file output.
    267275                    results.problem.number_of_variables = tokens[2]
    268276            # In CPLEX 11 (and presumably before), there was only a single line output to
     
    285293               # to differentiate, and I'm not sure we can always provide a break-down.
    286294               results.solver.user_time = eval(tokens[3])
    287             elif len(tokens) >= 4 and tokens == ['MIP', '-', 'Integer', 'infeasible.']:
     295            elif len(tokens) >= 4 and tokens[0] == "Dual" and tokens[1] == "simplex" and tokens[3] == "Optimal:":
     296                results.solver.termination_condition = TerminationCondition.optimal
     297                results.solver.termination_message = ' '.join(tokens)
     298            elif len(tokens) >= 4 and tokens[0] == "MIP" and tokens[2] == "Integer" and tokens[3] == "infeasible.":
     299                # if CPLEX has previously printed an error message, reduce it to a warning -
     300                # there is a strong indication it recovered, but we can't be sure.
     301                if results.solver.status == SolverStatus.error:
     302                   results.solver.status = SolverStatus.warning
     303                else:
     304                   results.solver.status = SolverStatus.ok
    288305                results.solver.termination_condition = TerminationCondition.infeasible
    289306                results.solver.termination_message = ' '.join(tokens)
    290             elif len(tokens) >= 3 and tokens == ['Presolve', '-', 'Infeasible.']:
     307            # for the case below, CPLEX sometimes reports "true" optimal (the first case)
     308            # and other times within-tolerance optimal (the second case).
     309            elif (len(tokens) >= 4 and tokens[0] == "MIP" and tokens[2] == "Integer" and tokens[3] == "optimal") or \
     310                 (len(tokens) >= 4 and tokens[0] == "MIP" and tokens[2] == "Integer" and tokens[3] == "optimal,"):
     311                # if CPLEX has previously printed an error message, reduce it to a warning -
     312                # there is a strong indication it recovered, but we can't be sure.
     313                if results.solver.status == SolverStatus.error:
     314                   results.solver.status = SolverStatus.warning
     315                else:
     316                   results.solver.status = SolverStatus.ok               
     317                results.solver.termination_condition = TerminationCondition.optimal
     318                results.solver.termination_message = ' '.join(tokens)               
     319            elif len(tokens) >= 3 and tokens[0] == "Presolve" and tokens[2] == "Infeasible.":
     320                # if CPLEX has previously printed an error message, reduce it to a warning -
     321                # there is a strong indication it recovered, but we can't be sure.
     322                if results.solver.status == SolverStatus.error:
     323                   results.solver.status = SolverStatus.warning
     324                else:
     325                   results.solver.status = SolverStatus.ok               
    291326                results.solver.termination_condition = TerminationCondition.infeasible
    292327                results.solver.termination_message = ' '.join(tokens)
    293             elif len(tokens) >= 5 and tokens == ['Presolve', '-', 'Unbounded', 'or', 'infeasible.']:
     328            elif len(tokens) >= 5 and tokens[0] == "Presolve" and tokens[2] == "Unbounded" and tokens[4] == "infeasible.":
     329                # if CPLEX has previously printed an error message, reduce it to a warning -
     330                # there is a strong indication it recovered, but we can't be sure.
     331                if results.solver.status == SolverStatus.error:
     332                   results.solver.status = SolverStatus.warning
     333                else:
     334                   results.solver.status = SolverStatus.ok               
    294335                # It isn't clear whether we can determine if the problem is unbounded from
    295336                # CPLEX's output.
     
    401442            elif tokens[0].startswith("solutionStatusString"):
    402443                solution_status = (string.strip(" ".join(tokens).split('=')[1])).lstrip("\"").rstrip("\"")
    403                 if solution_status in ["optimal", "integer optimal solution"]:
     444                if solution_status in ["optimal", "integer optimal solution", "integer optimal, tolerance"]:
    404445                    soln.status = SolutionStatus.optimal
    405446                    soln.gap = 0.0
  • coopr.plugins/stable/2.2/coopr/plugins/mip/__init__.py

    r1768 r2195  
    1616from GLPK import GLPK, MockGLPK
    1717from CPLEX import CPLEX, MockCPLEX
     18#from NLOPT import NLOPT, MockNLOPT
    1819#from NLWRITE import NLWRITE
    1920
  • coopr.plugins/stable/2.2/coopr/plugins/tests/mip/test1_cplex.txt

    r2048 r2195  
    2121Solver:
    2222- Status: ok
    23   Termination condition: unsure
     23  Termination condition: optimal
     24  Termination message: Dual simplex - Optimal\x3a Objective = 3.0000000000e+00
    2425  Error rc: 0
    2526
  • coopr.plugins/stable/2.2/coopr/plugins/tests/mip/test2_cplex.txt

    r1919 r2195  
    2121Solver:
    2222- Status: ok
    23   Termination condition: unsure
     23  Termination condition: optimal
     24  Termination message: MIP - Integer optimal solution\x3a Objective = 2.0000000000e+00
    2425  Statistics:
    2526    Branch and bound:
  • coopr.plugins/stable/2.2/coopr/plugins/tests/mip/test4_cplex.txt

    r2048 r2195  
    2121Solver:
    2222- Status: ok
    23   Termination condition: unsure
     23  Termination condition: optimal
     24  Termination message: Dual simplex - Optimal\x3a Objective = 8.8578000000e+01
    2425  Error rc: 0
    2526
Note: See TracChangeset for help on using the changeset viewer.