MPS, LP, OSiL Files, More New Features
Click on the Solver Platform SDK features of interest to you. These features are also supported by plug-in Solver engines for larger-scale problems.
- Reading and Writing MPS and LP Format Files
- Optimization Services and OSiL Format Files
- Diagnosing Infeasibility
- Determining Linearity and Smoothness
- Controlling Parameters and Tolerances
- Obtaining Engine Size Limits
- Back to Product Overview
Reading and Writing MPS and LP Format Files
In addition to providing objects and properties (and corresponding procedural API routines) that allow you to specify problem information programmatically, the Solver Platform SDK provides rich facilities for reading and writing problems in several popular file formats: Traditional MPS format files, modern LP format files, and new, XML-based OSiL format files. To create, read in and solve a problem in an MPS file requires only three lines of code:
Problem problem;
problem.Load(filename, File_Format_MPS);
problem.Solver.Optimize();
LP format files -- supported by several other commercial LP/QP solvers -- are designed to be human readable and to resemble algebraic notation. You can use LP format by simply substituting File_Format_LP
for File_Format_MPS
above. A portion of an example file in LP format is shown below:
Maximize LP/MIP
o1: 2.0 x1 + 3.0 x2
Subject To
c1: 9.0 x1 + 6.0 x2 <= 54.0
c2: 6.0 x1 - 7.0 x2 >= 42.0
You can use problem.Save() and problem.Load() to "persist" the definition of a problem to disk between runs of your application. You can also use an external program to generate a file in one of the formats supported by problem.Load(), then use the Solver Platform SDK to read it in and solve it.
Optimization Services and OSiL Format Files
The newest and most flexible format is OSiL -- a new XML-based specification, part of the Optimization Services initiative spearheaded by researchers at the University of Chicago and Northwestern University. Unlike the other formats, OSiL is designed to support both linear and nonlinear optimization problems. To create, read in and solve a problem in OSiL format also requires just three lines of code:
Problem problem;
problem.Load(filename, File_Format_OSiL);
problem.Solver.Optimize();
The Solver Platform SDK reads and writes LP, QP and QCP (quadratically constrained) problems with integer variables in OSiL format. Once Optimization Services is formally "launched", Frontline Systems expects to read and write nonlinear problems in OSiL format, in future SDK releases. A portion of an example file in OSiL format is shown below:
<variables number="2"> <var lb="0" name="x1" type="C"/> <var lb="0" name="x2" type="C"/> </variables> <objectives number="1"> <obj maxOrMin="max" name="o1" numberOfObjCoef="2"> <coef idx="0">2.0</coef> <coef idx="1">3.0</coef> </obj> </objectives>
Diagnosing Infeasibility
When the Solver Platform SDK finds no feasible solution to an LP or NLP problem, this often means that you've made a mistake in defining some constraint, for example by choosing <= when you meant >= using the Relation method. But if you have hundreds or thousands of constraints, it can be difficult to pinpoint the source of the problem. The Solver Platform SDK's feasibility analysis routines can help! When you write:
problem.Solver.IISFind();
...the SDK will compute an Irreducibly Infeasible Subset (IIS) of the constraints and variable bounds. A model consisting of only these constraints and bounds would still be infeasible, but if any one of them is dropped from the set, the model would become feasible. Examining the constraints and bounds in the IIS can help you quickly locate the error or condition that makes the problem infeasible. You can obtain the index and status of each constraint in the IIS with:
OptIIS MyIIS = problem.Solver.OptIIS; for (i=0; i < MyIIS.NumConstraints; i++) { index = MyIIS.ConstraintIndex[i]; status = MyIIS.ConstraintStatus[i]; }
Determining Linearity and Smoothness
The Solver Platform SDK makes it easy to define and solve linear, smooth nonlinear, and nonsmooth problems. But nonlinear problems may contain a mix of linear and nonlinear constraints, or variables that occur linearly in some constraints and nonlinearly in others. Some advanced Solver engines are able to use such linearity information to greatly improve solution time and accuracy.
You can specify whether each occurrence of a variable in a constraint or the objective is linear, nonlinear, nonsmooth, or independent (i.e. the variable does not occur) by setting the AllGradDepend property:
_Depend_Type [] MyObjType = { Depend_Type_Linear, Depend_Type_Quadratic, ... }; problem.Model.AllGradDepend[Function_Type.Objective] = new DependMatrix(Array_Order.ByCol, 1, nvars, MyObjType);
If your problem functions are computed by a "black box" routine and you cannot specify the occurrence information in advance, you can -- for linear and smooth nonlinear problems -- ask the Solver Platform SDK to diagnose your model for linear or nonlinear behavior by calling (for example):
problem.Model.DependTest(Variable_Type_Decision, 10);
The AllGradDepend property will be filled in automatically by the DependTest method. This can be very useful in a general-purpose application program that handles a variety of models.
Controlling Parameters and Tolerances
Parameters and tolerances in the Solver Platform SDK and all plug-in Solver engines are controlled in a uniform way, by getting and setting "parameter" property values. For example, you can set the "reduced cost tolerance" in the Simplex method with a call such as:
problem.Engine.Params["ReducedTol"].Value = 1E-6;
If you're programming in a procedural language such as C, you can accomplish the same thing with:
SolverEngParamSet (problem, L"ReducedTol", 1E-6);
Obtaining Engine Size Limits
You can determine the maximum problem size limits allowed for a specific Solver engine by referencing properties of the EngineLimit object:
int MaxVars = problem.Engine.Limit.VarDecisionLimit;