Why is MultiObjective not supported in LP files

87 views
Skip to first unread message

Nima Esmaili Mokaram

unread,
Jun 27, 2022, 2:31:40 PM6/27/22
to OPTANO Modeling
Hi,

We're running OPTANO.Modeling version 3.10.1 and have a model with multiple objectives.

When we try to output the LP file for the model, we get a message that reads:
"Your Model contains Objectives with more than 1 ObjectiveStage/PriorityLevel. This is not supported in LP files. Model will not be exported."

According to the change log, support for multi-objective was added to OPTANO.Modeling in version 3.10.0.

Why does the LP model file generation fail? 
Is there anyway to generate an LP (or MPS) file for models with multiple objectives?

-Nima

Nima Esmaili Mokaram

unread,
Jun 27, 2022, 2:58:10 PM6/27/22
to OPTANO Modeling
Same happens with MPS files.

Here's the stack trace when attempting to generate the MPS file:
Type: System.ArgumentException
Message: MPExporter: the model must have excatly one objective.
Properties:
   ParamName: [null]
   HResult: 0x80070057
Source: optano.modeling
Stack Trace:
   at OPTANO.Modeling.Optimization.Exporter.MPSExporter.Write(Model model)

-Nima

Nima Esmaili Mokaram

unread,
Jun 27, 2022, 3:34:03 PM6/27/22
to OPTANO Modeling
from JP: "Looks like the model has more than one objective, but the mps file format only supports a single one. You might remove all objectives from the model object and add them each for a separate mps export."

1. Do `.lp` files support multi-objective? According to the IBM docs for CPLEX, they both should support multi-objective models.
2. Are you saying that we can just output 1 objective at a time and then combine the objectives in file manually by hand?

-Nima

Jannick Lange

unread,
Jun 29, 2022, 3:04:36 AM6/29/22
to OPTANO Modeling
Hi Nima!

Unfortunately, every Solver that (natively) supports multi objectives uses its own LP format for im-/exporting the models. For that reason, Modeling does not support a solver-independent export of multi objective models.
However, if you are using solvers such as CPLEX or Gurobi through OPTANO Modeling, they are able to write multi-objective LP/MPS files, using their custom format specifications.

Add an LP (or MPS) file to the solver configuration's "OutputFilesBeforeSolve" collection:
[...]
var config = new GurobiSolverConfiguration;
config.OutputFilesBeforeSolve.Add(new FileInfo("some/path/model.lp");
using var solver = new GurobiSolver(config);
sover.Solve(model);

This will make Gurobi write a multi objective LP file at "some/path/model.lp".
I hope this helps!

Best Regards
Jannick

Nima Esmaili Mokaram

unread,
Jun 29, 2022, 4:11:23 PM6/29/22
to OPTANO Modeling
Hi Jannick,

Thanks for the explanation. We are using CPLEX. We tried to use the `OutputFilesBeforeSolve` and but it did not output the model file when more than 1 objectives were setup. It did work for the 1 objective so the argument is setup correctly.
There are no exceptions thrown or any logs regarding the model file output 😟. 

Any idea why this might be or another approach that might allow us to output the LP file for a model with 2 objectives?

Note: we're using CPLEX version 20.1.0.0 in case that is important in any shape or form.

-Nima

Nima Esmaili Mokaram

unread,
Jul 6, 2022, 9:20:02 AM7/6/22
to OPTANO Modeling
Hi Jannick,

We're still unable to generate an LP file for a model that has 2 objectives. I was wondering if you have a CPLEX example that does this and we can find what's going wrong?

-Nima

Jannick Lange

unread,
Jul 7, 2022, 5:41:27 AM7/7/22
to OPTANO Modeling
Hi Nima,

please excuse my delayed response. I was absent until today.

Indeed, there is an issue with the mutli objective export of CPLEX.
In the ExportModel-method, we're doing a "CanExport" check, which erroneously makes a call to the "Base"-implementation. In this call, Modeling determins that a Default/Base solver cannot export multi-objective models, and thus the Export is not triggered.
During my initial test, the issue did not arise, since I used a model with 2 objectives that had the same priority. For this type of "multi objective" model, the base method does not complain, as it technically can be re-formulated/transformed to a single-objective model.

I will provide a fix for this issue as soon as possible. In the meantime, you can use the following workaround:
Inherit from CplexSolver, and override the CanExportFile method in the following way:

using OPTANO.Modeling.Optimization.Enums;
using OPTANO.Modeling.Optimization.Solver.Cplex2010;

public class CplexWithExport : CplexSolver
{
    /// <inheritdoc />
    protected override bool CanExportFile(FileInfo outputFile, ExportTime exportTime, bool printHints = false)
    {
        return outputFile != null && (outputFile.Extension?.Length ?? 0) > 0;
    }
}

Then use a 'new CplexWithExport()' solver instead of the CplexSolver in your program.

Best Regards
Jannick

Nima Esmaili Mokaram

unread,
Jul 8, 2022, 11:22:40 AM7/8/22
to OPTANO Modeling
Hi Jannick,

That worked as expected and we were able to get the `lp` file generated for our multi-objective model. Thanks a lot.
Let us know when the fix for this is out there so we can update our libraries and take out the workaround.

Thanks,
Nima

OPTANO Team

unread,
Jul 18, 2022, 8:07:40 AM7/18/22
to OPTANO Modeling
Hi, 

we have pushed this issue to the release branch and will publish a new version for this in the next days (like this week). 

Best
jp

jannic...@orconomy.de

unread,
Jul 19, 2022, 4:09:49 AM7/19/22
to OPTANO Modeling
Hi,

we just release Optano.Modeling 3.11.0, which containts a fix for this issue:

Best Regards
Jannick
Reply all
Reply to author
Forward
0 new messages