Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update cplex solution parser for cplex 12.10 #1792

Merged
merged 1 commit into from
Jan 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion pyomo/core/kernel/block.py
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,9 @@ def load_solution(self,
raise KeyError("Objective associated with symbol '%s' "
"is not found on this block"
% (label))
unseen_var_ids.remove(id(obj))
# Because of __default_objective__, an objective might
# appear twice in the objective dictionary.
unseen_var_ids.discard(id(obj))
for _attr_key, attr_value in six.iteritems(entry):
attr_key = _attr_key[0].lower() + _attr_key[1:]
if attr_key in valid_import_suffixes:
Expand Down
14 changes: 13 additions & 1 deletion pyomo/solvers/plugins/solvers/CPLEX.py
Original file line number Diff line number Diff line change
Expand Up @@ -776,9 +776,21 @@ def process_soln_file(self,results):
break
tINPUT.close()

elif tokens[0].startswith("objectiveValue"):
elif tokens[0].startswith("objectiveValue") and tokens[0] != 'objectiveValues':
# prior to 12.10.0, the objective value came back as an
# attribute on the <header> tag
objective_value = (tokens[0].split('=')[1].strip()).lstrip("\"").rstrip("\"")
soln.objective['__default_objective__']['Value'] = float(objective_value)

elif tokens[0] == "objective":
# beginning in 12.10.0, CPLEX supports multiple
# objectives in an <objectiveValue> tag
fields = {}
for field in tokens[1:]:
k,v = field.split('=')
fields[k] = v.strip('"')
soln.objective.setdefault(fields['name'], {})['Value'] = float(fields['value'])

elif tokens[0].startswith("solutionStatusValue"):
pieces = tokens[0].split("=")
solution_status = eval(pieces[1])
Expand Down