Changeset 2926


Ignore:
Timestamp:
Aug 14, 2010 3:36:36 PM (9 years ago)
Author:
wehart
Message:

Evaluating tokens before they are used to define values in the results object.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • coopr.plugins/trunk/coopr/plugins/mip/CPLEX.py

    r2853 r2926  
    284284            elif len(tokens) >= 3 and tokens[0] == "Variables":
    285285                if results.problem.number_of_variables is None: # CPLEX 11.2 and subsequent versions have two Variables sections in the log file output.
    286                     results.problem.number_of_variables = tokens[2]
     286                    results.problem.number_of_variables = eval(tokens[2])
    287287            # In CPLEX 11 (and presumably before), there was only a single line output to
    288288            # indicate the constriant count, e.g., "Linear constraints : 16 [Less: 7, Greater: 6, Equal: 3]".
     
    292292            # that's all.
    293293            elif len(tokens) >= 4 and tokens[0] == "Linear" and tokens[1] == "constraints":
    294                 results.problem.number_of_constraints = tokens[3]
     294                results.problem.number_of_constraints = eval(tokens[3])
    295295            elif len(tokens) >= 3 and tokens[0] == "Nonzeros":
    296296                if results.problem.number_of_nonzeros is None: # CPLEX 11.2 and subsequent has two Nonzeros sections.               
    297                     results.problem.number_of_nonzeros = tokens[2]
     297                    results.problem.number_of_nonzeros = eval(tokens[2])
    298298            elif len(tokens) >= 5 and tokens[4] == "MINIMIZE":
    299299                results.problem.sense = ProblemSense.minimize
     
    348348                results.solver.termination_condition = TerminationCondition.unbounded
    349349                results.solver.termination_message = ' '.join(tokens)
     350
     351        try:
     352            results.solver.termination_message = pyutilib.misc.yaml_fix(results.solver.termination_message)
     353        except:
     354            pass
    350355        return results
    351356
     
    473478            elif tokens[0].startswith("objectiveValue"):
    474479                objective_value = (string.strip(tokens[0].split('=')[1])).lstrip("\"").rstrip("\"")
    475                 soln.objective['f'].value = objective_value
     480                soln.objective['f'].value = eval(objective_value)
    476481            elif tokens[0].startswith("solutionStatusString"):
    477482                solution_status = (string.strip(" ".join(tokens).split('=')[1])).lstrip("\"").rstrip("\"")
     
    493498            elif tokens[0].startswith("MIPNodes"):
    494499                if mip_problem:
    495                     n = eval(string.strip(" ".join(tokens).split('=')[1])).lstrip("\"").rstrip("\"")
     500                    n = eval(eval(string.strip(" ".join(tokens).split('=')[1])).lstrip("\"").rstrip("\""))
    496501                    results.solver.statistics.branch_and_bound.number_of_created_subproblems=n
    497502                    results.solver.statistics.branch_and_bound.number_of_bounded_subproblems=n
Note: See TracChangeset for help on using the changeset viewer.