Guide

Loading a model

The simplest way to use HiGHS to solve a model is to load it from a file using the method readModel. Different file formats are recognised from the filename extension. HiGHS can read plain text MPS files and (CPLEX) LP files. In general, HiGHS can read compressed files.

Alternatively, data generated by an application can be passed to HiGHS via an instance of the HighsLp class populated by the user and passed using the method passModel. In languages where such structures cannot be used, data constituting an LP model can be passed via individual parameters.

Building a model

The model in HiGHS can be built using a sequence of calls to add variables and constraints. This is most easily done one-by-one using the methods addCol and addRow. Alterntively, addVar and addRow can be used, with changeColCost used to define each objective coefficient.

Addition of multiple variables and constraints can be achieved using addVars and addRows, with changeColsCost used to define objective coefficients. Note that defining the model in this way requires vectors of data and the specification of constraint coefficients as compressed row-wise or column-wise matrices.

Solving a model

The incumbent model in HiGHS is solved by a call to the method run. By default, HiGHS minimizes the model's objective function. Where possible, HiGHS will hot start the solver using solution information obtained on previous runs, or supplied by the user.

Model and solution management

HiGHS has comprehensive tools for defining and extracting models. This can be done either to/from MPS or (CPLEX) format LP files, or via method calls. HiGHS also has methods that permit the incumbent model to be modified. Solutions can be supplied and extracted using either files or method calls.

Extracting the results

After solving a model, its status is the value returnedby the method getModelStatus. This value is of type HighsModelStatus. Scalar information about a solved model is obtained using the method getInfo. The solution and (any) basis are returned by the methods getSolution and getBasis respectively. HiGHS can also be used to write the solution to a file using the method writeSolution.

Option values

The option values that control HiGHS are of type string, bool, int and double. Options are referred to by a string identical to the name of their identifier. A full specification of the options is given List of options. An option value is changed by passing its name and value to the method setOptionValue. The current value of an option is obtained by passing its name to the method getOptionValue

Extracting model data

The numbers of column, rows and nonzeros in the model are returned by the methods getNumCols, getNumRows and getNumEntries respectively.

Model data can be extracted for a single column or row by specifying the index of the column or row and calling the methods getCol and getRow. As well as returning the value of the cost and bounds, these methods also return the number of nonzeros in the corresponding column or row of the constraint matrix. The indices and values of the nonzeros can be obtained using the methods getColEntries and getRowEntries.

For multiple columns and rows defined by a set of indices, the corresponding data can be extracted using the methods getCols, getRows, getColsEntries and getRowsEntries.

Specific matrix coefficients obtained using the method getCoeff.

Modifying model data

The most immediate model modification is to change the sense of the objective. By default, HiGHS minimizes the model's objective function. The objective sense can be set to minimize (maximize) using changeObjectiveSense.

Model data for can be changed for one column or row by specifying the index of the column or row, together with the new scalar value for the cost or bounds, the specific methods being changeColCost, changeColBounds. The corresponding method for a row is changeRowBounds. Changes for multiple columns or rows are defined by supplying a list of indices, together with arrays of new values, using the methods changeColsCost, changeColsBounds. The corresponding method for a row is changeRowsBounds. An individual matrix coefficient is changed by passing its row index, column index and new value to changeCoeff.

Other operations

To run HiGHS from a user-defined solution or basis, this is passed to HiGHS using the methods setSolution or setBasis.