OptRead(filename, vars, constraints, format, engine, settingName, settingValue, maximize)

Reads a Linear Program specification from a file. The file must be in one of the standard recognized formats, specified in the optional «format» parameter:

In most cases, your file will have been written by a previous call to OptWrite or OptWriteIIS.

If only a file name without a folder path, or a relative file path is provided for «filename», it is interpreted relative to the CurrentDataFolder.

You may optionally pass in indexes for «vars» and «constraints». If you don't pass these in, the function will automatically create local indexes of the appropriate size to index the decision variables and constraints in the problem. If you do pass these, they will be used as the index for the decision variables and for the constraints, but must be of the correct length or an error results.

You can also optionally specify which solver «engine» should be used and any control settings to be used during the solve via the «settingName» and «settingValue» parameters. To override a single setting, provide a single value to each, e.g.:

OptRead("alloc.lp", settingName: "Cuts", settingValue: 0)

To set multiple values, configure an index with the names of the parameters and an array with the values:

Index settingNames := ['PrimalTolerance', 'MaxTime'];
OptRead("alloc.lp", settingVals: Array(settingNames, [100n, 20]))

The optional «maximize» parameter can be set to true to force the objective to be maximized, or false to force the objective to be minimized. When this is specified, it overrides the polarity in the model being loaded (for "LP" and "LPFML" formats). The "MPS" format standard (also known as fixed-width MPS) does not include a specification for whether the objective is to be maximized or minimized. While OptWrite will always store the objective in an MPS file in a form to be minimized, not all other optimization software products make the same assumptions, so if you are getting an "MPS" file from an external source, you may need to set the «maximize» flag explicitly if you intend to solve it.


This function was introduced in Analytica 4.3 to replace the earlier version LpRead.

See Also


You are not allowed to post comments.