# Using lpsolve from MATLAB

### MATLAB?

MATLAB® is a high-performance language for technical computing. It integrates computation, visualization, and programming in an easy-to-use environment where problems and solutions are expressed in familiar mathematical notation. Typical uses include

- Math and computation
- Algorithm development
- Data acquisition
- Modelling, simulation, and prototyping
- Data analysis, exploration, and visualization
- Scientific and engineering graphics
- Application development, including graphical user interface building

MATLAB is an interactive system whose basic data element is an array that does not require dimensioning. This allows you to solve many technical computing problems, especially those with matrix and vector formulations, in a fraction of the time it would take to write a program in a scalar noninteractive language such as C or Fortran.

The name MATLAB stands for matrix laboratory. MATLAB was originally written to provide easy access to matrix software developed by the LINPACK and EISPACK projects. Today, MATLAB engines incorporate the LAPACK and BLAS libraries, embedding the state of the art in software for matrix computation.

MATLAB has evolved over a period of years with input from many users. In university environments, it is the standard instructional tool for introductory and advanced courses in mathematics, engineering, and science. In industry, MATLAB is the tool of choice for high-productivity research, development, and analysis.

MATLAB features a family of add-on application-specific solutions called toolboxes. Very important to most users of MATLAB, toolboxes allow you to learn and apply specialized technology. Toolboxes are comprehensive collections of MATLAB functions (M-files) that extend the MATLAB environment to solve particular classes of problems. Areas in which toolboxes are available include signal processing, control systems, neural networks, fuzzy logic, wavelets, simulation, and many others.

We will not discuss the specifics of MATLAB here but instead refer the reader to the MATLAB website and documentation.

### MATLAB and lpsolve

lpsolve is callable from MATLAB via an external interface or MEX-function. As such, it looks like lpsolve is fully integrated with MATLAB. Matrices can directly be transferred between MATLAB and lpsolve in both directions. The complete interface is written in C so it has maximum performance. The whole lpsolve API is implemented with some extra's specific for MATLAB (especially for matrix support). So you have full control to the complete lpsolve functionality via the mxlpsolve MATLAB driver. If you find that this involves too much work to solve an lp model then you can also work via higher-level M-files that can make things a lot easier. See further in this article.

### Installation

To make this possible, a driver program is needed: mxlpsolve (mxlpsolve.dll under Windows). This driver must be put in a directory known to MATLAB (specified via File, Set Path or via the MATLAB path command) and MATLAB can call the mxlpsolve solver.

This driver calls lpsolve via the lpsolve shared library (lpsolve51.dll under Windows and liblpsolve51.so under Unix/Linux). This has the advantage that the mxlpsolve driver doesn't have to be recompiled when an update of lpsolve is provided. The shared library must be somewhere in the Windows path.

So note the difference between the MATLAB lpsolve driver that is called mxlpsolve and the lpsolve library that implements the API that is called lpsolve51.

There are also some MATLAB script files (.m) as a quick start.

To test if everything is installed correctly, enter mxlpsolve in the MATLAB command window. If it gives the following, then everything is ok:

    mxlpsolve MATLAB Interface version 5.1.0.0

    using lpsolve version 5.1.1.2

    Usage: [ret1, ret2, ...] = mxlpsolve('functionname', arg1, arg2, ...)

However, if you get the following:

    mxlpsolve driver not found !!!

    Check if mxlpsolve.dll is on your system and in a directory known to MATLAB.

    Press enter to see the paths where MATLAB looks for the driver.

Then MATLAB can find the mxlpsolve.m file, but not the mxlpsolve.dll file. This dll should be in the same directory as the .m file.

If you get the following:

    ??? Undefined function or variable 'mxlpsolve'.

Then MATLAB cannot find the mxlpsolve.* files. Enter path in the command line to see the MATLAB search path for its files. You can modify this path via File, Set Path. Specify the path where the mxlpsolve.* files are located on your system.

If you get the following:

    ??? Failed to initialise lpsolve library.

    Error in ==> ...\mxlpsolve.dll

Then MATLAB can find the mxlpsolve driver program, but the driver program cannot find the lpsolve library that contains the lpsolve implementation. This library is called lpsolve51.dll and should be on your system in a directory that in the PATH environment variable. This path can be shown via the following command in MATLAB: !PATH

The lpsolve51.dll files must be in one of these specified directories. It is common to place this in the WINDOWS\system32 folder.

Note that it may also be necessary to restart MATLAB after having put the files in the specified directory. It was noted that MATLAB sometimes doesn't see the newly added files in folders until it is restarted.

All this is developed and tested with MATLAB version 6.0.0.88 Release 12.

### Solve an lp model from MATLAB via mxlpsolve

In the following text, >> before the MATLAB commands is the MATLAB prompt. Only the text after >> must be entered.

To call an lpsolve function, the following syntax must be used:

    >> [ret1, ret2, ...] = mxlpsolve('functionname', arg1, arg2, ...)

The return values are optional and depend on the function called. functionname must always be enclosed between single quotes to make it alphanumerical and it is case sensitive. The number and type of arguments depend on the function called. Some functions even have a variable number of arguments and a different behaviour occurs depending on the type of the argument. functionname can be (almost) any of the lpsolve API routines (see lp_solve API reference) plus some extra MATLAB specific functions. Most of the lpsolve API routines use or return an lprec structure. To make things more robust in MATLAB, this structure is replaced by a handle. This is an incrementing number starting from 0 and the lprec structures are maintained internally by the mxlpsolve driver. However you will see not much (if any) difference in the use of it.

Almost all callable functions can be found in the lp_solve API reference. Some are exactly as described in the reference guide, others have a slightly different syntax to make maximum use of the MATLAB functionality. For example make_lp is used identical as described. But get_variables is slightly different. In the API reference, this function has two arguments. The first the lp handle and the second the resulting variables and this array must already be dimensioned. When lpsolve is used from MATLAB, nothing must be dimensioned in advance. The mxlpsolve driver takes care of dimensioning all return variables and they are always returned as return value of the call to mxlpsolve. Never as argument to the routine. This can be a single value as for get_objective (although MATLAB stores this in a 1x1 matrix) or a matrix or vector as in get_variables. In this case, get_variables returns a 4x1 matrix (vector) with the result of the 4 variables of the lp model.

Note that you can get an overview of the available functionnames and their arguments by entering the following in MATLAB:

    >> help mxlpsolve

### An example

(Note that you can execute this example by entering command per command as shown below or by just entering example1. This will execute example1.m. You can see its contents by entering type example1.m)

    >> lp=mxlpsolve('make_lp', 0, 4);

    >> mxlpsolve('set_verbose', lp, 3);

    >> mxlpsolve('set_obj_fn', lp, [1, 3, 6.24, 0.1]);

    >> mxlpsolve('add_constraint', lp, [0, 78.26, 0, 2.9], 2, 92.3);

    >> mxlpsolve('add_constraint', lp, [0.24, 0, 11.31, 0], 1, 14.8);

    >> mxlpsolve('add_constraint', lp, [12.68, 0, 0.08, 0.9], 2, 4);

    >> mxlpsolve('set_lowbo', lp, 1, 28.6);

    >> mxlpsolve('set_lowbo', lp, 4, 18);

    >> mxlpsolve('set_upbo', lp, 4, 48.98);

    >> mxlpsolve('set_col_name', lp, 1, 'COLONE');

    >> mxlpsolve('set_col_name', lp, 2, 'COLTWO');

    >> mxlpsolve('set_col_name', lp, 3, 'COLTHREE');

    >> mxlpsolve('set_col_name', lp, 4, 'COLFOUR');

    >> mxlpsolve('set_row_name', lp, 1, 'THISROW');

    >> mxlpsolve('set_row_name', lp, 2, 'THATROW');

    >> mxlpsolve('set_row_name', lp, 3, 'LASTROW');

    >> mxlpsolve('write_lp', lp, 'a.lp');

    >> mxlpsolve('get_mat', lp, 1, 2)

    ans =

       78.2600

    >> mxlpsolve('solve', lp)

    ans =

         0

    >> mxlpsolve('get_objective', lp)

    ans =

       31.7828

    >> mxlpsolve('get_variables', lp)

    ans =

       28.6000

             0

             0

       31.8276

    >> mxlpsolve('get_constraints', lp)

    ans =

       92.3000

        6.8640

      391.2928

    >> mxlpsolve('delete_lp', lp);

Note that there are some commands that return an answer. To see the answer, the command was not terminated with a semicolon (;). If the semicolon is put at the end of a command, the answer is not shown. However it is also possible to write the answer in a variable. For example:

    >> obj=mxlpsolve('get_objective', lp)

    obj =

       31.7828

Or without echoing on screen:

    >> obj=mxlpsolve('get_objective', lp);

The last command will only write the result in variable obj without showing anything on screen. get_variables and get_constraints return a vector with the result. This can also be put in a variable:

    >> x=mxlpsolve('get_variables', lp);

    >> b=mxlpsolve('get_constraints', lp);

It is always possible to show the contents of a variable by just giving it as command:

    >> x

    x =

      28.6000

            0

            0

      31.8276

### Matrices

In MATLAB, all numerical data is stored in matrices; even a scalar variable. MATLAB also supports complex numbers (a + b * i with i=SQRT(-1)). mxlpsolve can only work with real numbers. MATLAB also supports sparse matrices. Sparse matrices are matrices where only the non-zero elements are provided and stored. This results in both less storage and faster calculation if there are a sufficient number of zero values in the matrix and there usually are. The mxlpsolve driver supports both dense and sparse matrices and their use is totally transparent to the user. Everywhere a matrix can be provided, it can be dense or sparse. In the above example all matrices were dense. For example:

    >> mxlpsolve('add_constraint', lp, [0.24, 0, 11.31, 0], 1, 14.8);

In sparse matrix notation, this can be written:

    >> mxlpsolve('add_constraint', lp, sparse([0.24, 0, 11.31, 0]), 1, 14.8);

Most of the time, variables are used to provide the data:

    >> mxlpsolve('add_constraint', lp, a1, 1, 14.8);

Where a1 is a matrix variable that can be dense or sparse.

The mxlpsolve driver sees all provided matrices as sparse matrices. mxlpsolve also uses sparse matrices internally and data can be provided sparse via the ex routines. For example add_constraintex. The mxlpsolve driver always uses the ex routines to provide the data to lpsolve. Even if you call from MATLAB the routine names that would require a dense matrix (for example add_constraint), the mxlpsolve driver will always call the sparse version of the routine (for example add_constraintex). This results in the most performing behaviour. Note that if a dense matrix is provided, the dimension must exactly match the dimension that is expected by mxlpsolve. Matrices with too few or too much elements gives an 'invalid vector.' error. Sparse matrices can off course provide less elements (the non provided elements are seen as zero). However if too many elements are provided or an element with a too large index, again an 'invalid vector.' error is raised.

Most of the time, mxlpsolve needs vectors (rows or columns). In all situations, it doesn't matter if the vectors are row or column vectors. The driver accepts them both. For example:

    >> mxlpsolve('add_constraint', lp, [0.24; 0; 11.31; 0], 1, 14.8);

Which is a column vector, but it is also accepted.

An important final note. Several lp_solve API routines accept a vector where the first element (element 0) is not used. Other lp_solve API calls do use the first element. In the MATLAB interface, there is never an unused element in the matrices. So if the lp_solve API specifies that the first element is not used, then this element is not in the MATLAB matrix.

### Sets

All numerical data is stored in matrices. Alphanumerical data, however, is more difficult to store in matrices. Matrices require that each element has the same size (length) and that is difficult and unpractical for alphanumerical data. In a limited number of lpsolve routines, alphanumerical data is required or returned and in some also multiple elements. An example is set_col_name. For this, MATLAB sets are used. To specify a set of alphanumerical elements, the following notation is used: { 'element1', 'element2', ... }. Note the { and } symbols instead of [ and ] that are used with matrices.

### Maximum usage of matrices/sets with mxlpsolve

Because MATLAB is all about matrices, all lpsolve API routines that need a column or row number to get/set information for that column/row are extended in the mxlpsolve MATLAB driver to also work with matrices. For example set_int in the API can only set the integer status for one column. If the status for several integer variables must be set, then set_int must be called multiple times. The mxlpsolve MATLAB driver however also allows specifying a vector to set the integer status of all variables at once. The API call is: return = mxlpsolve('set_int', lp_handle, column, must_be_int). The matrix version of this call is: return = mxlpsolve('set_int', lp_handle, [must_be_int]). The API call to return the integer status of a variable is: return = mxlpsolve('is_int', lp_handle, column). The matrix version of this call is: [is_int] = mxlpsolve('is_int', lp_handle)
Also note the get_mat and set_mat routines. In MATLAB these are extended to return/set the complete constraint matrix. See following example.

Above example can thus also be done as follows:
(Note that you can execute this example by entering command per command as shown below or by just entering example2. This will execute example2.m. You can see its contents by entering type example2.m)

    >> lp=mxlpsolve('make_lp', 0, 4);

    >> mxlpsolve('set_verbose', lp, 3);

    >> mxlpsolve('set_obj_fn', lp, [1, 3, 6.24, 0.1]);

    >> mxlpsolve('add_constraint', lp, [0, 78.26, 0, 2.9], 2, 92.3);

    >> mxlpsolve('add_constraint', lp, [0.24, 0, 11.31, 0], 1, 14.8);

    >> mxlpsolve('add_constraint', lp, [12.68, 0, 0.08, 0.9], 2, 4);

    >> mxlpsolve('set_lowbo', lp, [28.6, 0, 0, 18]);

    >> mxlpsolve('set_upbo', lp, [Inf, Inf, Inf, 48.98]);

    >> mxlpsolve('set_col_name', lp, {'COLONE', 'COLTWO', 'COLTHREE', 'COLFOUR'});

    >> mxlpsolve('set_row_name', lp, {'THISROW', 'THATROW', 'LASTROW'});

    >> mxlpsolve('write_lp', lp, 'a.lp');

    >> mxlpsolve('get_mat', lp)

    ans =

             0   78.2600         0    2.9000

        0.2400         0   11.3100         0

       12.6800         0    0.0800    0.9000

    >> mxlpsolve('solve', lp)

    ans =

         0

    >> mxlpsolve('get_objective', lp)

    ans =

       31.7828

    >> mxlpsolve('get_variables', lp)

    ans =

       28.6000

             0

             0

       31.8276

    >> mxlpsolve('get_constraints', lp)

    ans =

       92.3000

        6.8640

      391.2928

Note the usage of Inf in set_upbo. This stands for 'infinity'. Meaning an infinite upper bound. It is also possible to use -Inf to express minus infinity. This can for example be used to create a free variable.

To show the full power of the matrices, let's now do some matrix calculations to check the solution. It works further on above example:

    >> A=mxlpsolve('get_mat', lp);

    >> X=mxlpsolve('get_variables', lp);

    >> B = A * X

    B =

       92.3000

        6.8640

      391.2928

So what we have done here is calculate the values of the constraints (RHS) by multiplying the constraint matrix with the solution vector. Now take a look at the values of the constraints that lpsolve has found:

    >> mxlpsolve('get_constraints', lp)

    ans =

       92.3000

        6.8640

      391.2928

Exactly the same as the calculated B vector, as expected.

Also the value of the objective can be calculated in a same way:

    >> C=mxlpsolve('get_obj_fn', lp);

    >> X=mxlpsolve('get_variables', lp);

    >> obj = C * X

    obj =

       31.7828

So what we have done here is calculate the value of the objective by multiplying the objective vector with the solution vector. Now take a look at the value of the objective that lpsolve has found:

    >> mxlpsolve('get_objective', lp)

    ans =

       31.7828

Again exactly the same as the calculated obj value, as expected.

### M-files

MATLAB can execute a sequence of statements stored in diskfiles. Such files are called "M-files" because they must have the file type of ".m" as the last part of their filename (extension). Much of your work with MATLAB will be in creating and refining M-files. M-files are usually created using your local editor.

M-files can be compared with batch files or scripts. You can put MATLAB commands in them and execute them at any time. The M-file is executed like any other command, by entering its name (without the .m extension).

The mxlpsolve MATLAB distribution contains some example M-files to demonstrate this.

To see the contents of such a file, enter the command 'type filename'. You can also edit these files with your favourite text editor (or notepad).

#### example1.m

Contains the commands as shown in the first example of this article.

#### example2.m

Contains the commands as shown in the second example of this article.

#### lp_solve.m

This script uses the API to create a higher-level function called lp_solve. This function accepts as arguments some matrices and options to create and solve an lp model. See the beginning of the file or type help lp_solve or just lp_solve to see its usage:

     LP_SOLVE  Solves mixed integer linear programming problems.

       SYNOPSIS: [obj,x,duals] = lp_solve(f,a,b,e,vlb,vub,xint,scalemode,keep)

          solves the MILP problem

                  max v = f'*x

                    a*x <> b

                      vlb <= x <= vub

                      x(int) are integer

       ARGUMENTS: The first four arguments are required:

                f: n vector of coefficients for a linear objective function.

                a: m by n matrix representing linear constraints.

                b: m vector of right sides for the inequality constraints.

                e: m vector that determines the sense of the inequalities:

                          e(i) = -1  ==> Less Than

                          e(i) =  0  ==> Equals

                          e(i) =  1  ==> Greater Than

              vlb: n vector of lower bounds. If empty or omitted,

                   then the lower bounds are set to zero.

              vub: n vector of upper bounds. May be omitted or empty.

             xint: vector of integer variables. May be omitted or empty.

        scalemode: scale flag. Off when 0 or omitted.

             keep: Flag for keeping the lp problem after it's been solved.

                   If omitted, the lp will be deleted when solved.

       OUTPUT: A nonempty output is returned if a solution is found:

              obj: Optimal value of the objective function.

                x: Optimal value of the decision variables.

            duals: solution of the dual problem.

Example of usage. To create and solve following lp-model:

    max: -x1 + 2 x2;

    C1: 2x1 + x2 < 5;

    -4 x1 + 4 x2 <5;

    int x2,x1;

The following command can be used:

    >> [obj, x]=lp_solve([-1, 2], [2, 1; -4, 4], [5, 5], [-1, -1], [], [], [1, 2])

    obj =

         3

    x =

         1

         2

#### lp_maker.m

This script is analog to the lp_solve script and also uses the API to create a higher-level function called lp_maker. This function accepts as arguments some matrices and options to create an lp model. Note that this scripts only creates a model and returns a handle. See the beginning of the file or type help lp_maker or just lp_maker to see its usage:

    >> help lp_maker

     LP_MAKER  Makes mixed integer linear programming problems.

       SYNOPSIS: lp_handle = lp_maker(f,a,b,e,vlb,vub,xint,scalemode,setminim)

          make the MILP problem

            max v = f'*x

              a*x <> b

                x >= vlb >= 0

                x <= vub

                x(int) are integer

       ARGUMENTS: The first four arguments are required:

                f: n vector of coefficients for a linear objective function.

                a: m by n sparse matrix representing linear constraints.

                b: m vector of right sides for the inequality constraints.

                e: m vector that determines the sense of the inequalities:

                          e(i) < 0  ==> Less Than

                          e(i) = 0  ==> Equals

                          e(i) > 0  ==> Greater Than

              vlb: n vector of non-negative lower bounds. If empty or omitted,

                   then the lower bounds are set to zero.

              vub: n vector of upper bounds. May be omitted or empty.

             xint: vector of integer variables. May be omitted or empty.

        scalemode: scale flag. Off when 0 or omitted.

         setminim: Set maximum lp when this flag equals 0 or omitted.

       OUTPUT: lp_handle is an integer handle to the lp created.

Example of usage. To create following lp-model:

    max: -x1 + 2 x2;

    C1: 2x1 + x2 < 5;

    -4 x1 + 4 x2 <5;

    int x2,x1;

The following command can be used:

    >> lp=lp_maker([-1, 2], [2, 1; -4, 4], [5, 5], [-1, -1], [], [], [1, 2])

    lp =

         0

To solve the model and get the solution:

    >> mxlpsolve('solve', lp)

    ans =

         0

    >> mxlpsolve('get_objective', lp)

    ans =

         3

    >> mxlpsolve('get_variables', lp)

    ans =

         1

         2

Don't forget to free the handle and its associated memory when you are done:

    >> mxlpsolve('delete_lp', lp);

#### lpdemo.m

Contains several examples to build and solve lp models.

#### ex.m

Contains several examples to build and solve lp models. Also solves the lp_examples from the lp_solve distribution.

### Overview of API routines

Note again that the MATLAB command 'help mxlpsolve' gives an overview of all functions that can be called via mxlpsolve with their arguments and return values.

- add_column, add_columnex
  - return = mxlpsolve('add_column', lp_handle, [column])
  - return = mxlpsolve('add_columnex', lp_handle, [column])
  - Both have the same interface from add_column but act as add_columnex
- add_constraint, add_constraintex
  - return = mxlpsolve('add_constraint', lp_handle, [row], constr_type, rh)
  - return = mxlpsolve('add_constraintex', lp_handle, [row], constr_type, rh)
  - Both have the same interface from add_constraint but act as add_constraintex
- add_SOS
  - return = mxlpsolve('add_SOS', lp_handle, name, sostype, priority, [sosvars], [weights])
  - The count argument in the API documentation is not needed in MATLAB since the number of elements is derived from the size of the sosvars and weights matrices. These must have the same size.
- column_in_lp
  - return = mxlpsolve('column_in_lp', lp_handle, [column])
  - No special considerations.
- default_basis
  - mxlpsolve('default_basis', lp_handle)
  - No special considerations.
- del_column
  - return = mxlpsolve('del_column', lp_handle, column)
  - No special considerations.
- del_constraint
  - return = mxlpsolve('del_constraint', lp_handle, del_row)
  - No special considerations.
- delete_lp
  - mxlpsolve('delete_lp', lp_handle)
  - No special considerations.
- free_lp
  - mxlpsolve('free_lp', lp_handle)
  - lp_handle is not changed as in the lpsolve API since it is a read_only input parameter. So it acts the same as delete_lp.
- get_anti_degen
  - return = mxlpsolve('get_anti_degen', lp_handle)
  - No special considerations.
- get_basis
  - [bascolumn] = mxlpsolve('get_basis', lp_handle {, nonbasic})
  - The bascolumn argument in the API documentation is here the return value. The nonbasic argument is optional in MATLAB. If not provided, then 0 is used.
- get_basiscrash
  - return = mxlpsolve('get_basiscrash', lp_handle)
  - No special considerations.
- get_bb_depthlimit
  - return = mxlpsolve('get_bb_depthlimit', lp_handle)
  - No special considerations.
- get_bb_floorfirst
  - return = mxlpsolve('get_bb_floorfirst', lp_handle)
  - No special considerations.
- get_bb_rule
  - return = mxlpsolve('get_bb_rule', lp_handle)
  - No special considerations.
- get_bounds_tighter
  - return = mxlpsolve('get_bounds_tighter', lp_handle)
  - No special considerations.
- get_break_at_value
  - return = mxlpsolve('get_break_at_value', lp_handle)
  - No special considerations.
- get_col_name
  - name = mxlpsolve('get_col_name', lp_handle, column)
  - [names] = mxlpsolve('get_col_name', lp_handle)
  - In MATLAB, this routine has two formats. The first format is identical to the API. The second format allows retrieving the values into a MATLAB matrix.
- get_column
  - [column, return] = mxlpsolve('get_column', lp_handle, col_nr)
  - The column argument in the API documentation is here the first return value.
  - The return code of the call is the second return value.
- get_constr_type
  - return = mxlpsolve('get_constr_type', lp_handle, row)
  - [constr_type] = mxlpsolve('get_constr_type', lp_handle)
  - In MATLAB, this routine has two formats. The first format is identical to the API. The second format allows retrieving the values into a MATLAB matrix.
- get_constraints
  - [constr, return] = mxlpsolve('get_constraints', lp_handle)
  - The constr argument in the API documentation is here the first return value.
  - The return code of the call is the second return value.
- get_dual_solution
  - [duals, return] = mxlpsolve('get_dual_solution', lp_handle)
  - The duals argument in the API documentation is here the first return value.
  - In the API, element 0 is not used and values start from element 1. In MATLAB, there is no unused element in the matrix.
  - The return code of the call is the second return value.
- get_epsb
  - return = mxlpsolve('get_epsb', lp_handle)
  - No special considerations.
- get_epsd
  - return = mxlpsolve('get_epsd', lp_handle)
  - No special considerations.
- get_epsel
  - return = mxlpsolve('get_epsel', lp_handle)
  - No special considerations.
- get_epsint
  - return = mxlpsolve('get_epsint', lp_handle)
  - No special considerations.
- get_epsperturb
  - return = mxlpsolve('get_epsperturb', lp_handle)
  - No special considerations.
- get_epspivot
  - return = mxlpsolve('get_epspivot', lp_handle)
  - No special considerations.
- get_improve
  - return = mxlpsolve('get_improve', lp_handle)
  - No special considerations.
- get_infinite
  - return = mxlpsolve('get_infinite', lp_handle)
  - No special considerations.
- get_lowbo
  - return = mxlpsolve('get_lowbo', lp_handle, column)
  - [return] = mxlpsolve('get_lowbo', lp_handle)
  - In MATLAB, this routine has two formats. The first format is identical to the API. The second format allows retrieving the values into a MATLAB matrix.
- get_lp_index
  - return = mxlpsolve('get_lp_index', lp_handle, orig_index)
  - No special considerations.
- get_lp_name
  - name = mxlpsolve('get_lp_name', lp_handle)
  - No special considerations.
- get_mat
  - value = mxlpsolve('get_mat', lp_handle, row, col)
  - [matrix, return] = mxlpsolve('get_mat', lp_handle)
  - In MATLAB, this routine has two formats. The first format is identical to the API. The second format allows retrieving the values into a MATLAB matrix in the first return value. The return code of the call is the second return value.
- get_max_level
  - return = mxlpsolve('get_max_level', lp_handle)
  - No special considerations.
- get_maxpivot
  - return = mxlpsolve('get_maxpivot', lp_handle)
  - No special considerations.
- get_mip_gap
  - return = mxlpsolve('get_mip_gap', lp_handle, absolute)
  - No special considerations.
- get_nameindex
  - return = mxlpsolve('get_nameindex', lp_handle, name, isrow)
  - No special considerations.
- get_Ncolumns
  - return = mxlpsolve('get_Ncolumns', lp_handle)
  - No special considerations.
- get_negrange
  - return = mxlpsolve('get_negrange', lp_handle)
  - No special considerations.
- get_nonzeros
  - return = mxlpsolve('get_nonzeros', lp_handle)
  - No special considerations.
- get_Norig_columns
  - return = mxlpsolve('get_Norig_columns', lp_handle)
  - No special considerations.
- get_Norig_rows
  - return = mxlpsolve('get_Norig_rows', lp_handle)
  - No special considerations.
- get_Nrows
  - return = mxlpsolve('get_Nrows', lp_handle)
  - No special considerations.
- get_obj_bound
  - return = mxlpsolve('get_obj_bound', lp_handle)
  - No special considerations.
- get_objective
  - return = mxlpsolve('get_objective', lp_handle)
  - No special considerations.
- get_orig_index
  - return = mxlpsolve('get_orig_index', lp_handle, lp_index)
  - No special considerations.
- get_origcol_name
  - name = mxlpsolve('get_origcol_name', lp_handle, column)
  - [names] = mxlpsolve('get_origcol_name', lp_handle)
  - In MATLAB, this routine has two formats. The first format is identical to the API. The second format allows retrieving the values into a MATLAB matrix.
- get_origrow_name
  - name = mxlpsolve('get_origrow_name', lp_handle, row)
  - [names] = mxlpsolve('get_origrow_name', lp_handle)
  - In MATLAB, this routine has two formats. The first format is identical to the API. The second format allows retrieving the values into a MATLAB matrix.
- get_pivoting
  - return = mxlpsolve('get_pivoting', lp_handle)
  - No special considerations.
- get_presolve
  - return = mxlpsolve('get_presolve', lp_handle)
  - No special considerations.
- get_primal_solution
  - [pv, return] = mxlpsolve('get_primal_solution', lp_handle)
  - The pv argument in the API documentation is here the first return value.
  - The return code of the call is the second return value.
- get_print_sol
  - return = mxlpsolve('get_print_sol', lp_handle)
  - No special considerations.
- get_ptr_constraints
  - Not implemented.
- get_ptr_dualsolution
  - Not implemented.
- get_ptr_primal_solution
  - Not implemented.
- get_ptr_sensitivity_obj, get_ptr_sensitivity_objex
  - Not implemented.
- get_ptr_sensitivity_rhs
  - Not implemented.
- get_ptr_variables
  - Not implemented.
- get_rh
  - return = mxlpsolve('get_rh', lp_handle, row)
  - [rh] = mxlpsolve('get_rh', lp_handle)
  - In MATLAB, this routine has two formats. The first format is identical to the API. The second format allows retrieving the values into a MATLAB matrix. Note that in this case, the value of row 0 is not returned.
- get_rh_range
  - return = mxlpsolve('get_rh_range', lp_handle, row)
  - [rh_ranges] = mxlpsolve('get_rh_range', lp_handle)
  - In MATLAB, this routine has two formats. The first format is identical to the API. The second format allows retrieving the values into a MATLAB matrix.
- get_row
  - [row, return] = mxlpsolve('get_row', lp_handle, row_nr)
  - The row argument in the API documentation is here the first return value.
  - In the API, element 0 is not used and values start from element 1. In MATLAB, there is no unused element in the matrix.
  - The return code of the call is the second return value.
- get_row_name
  - name = mxlpsolve('get_row_name', lp_handle, row)
  - [names] = mxlpsolve('get_row_name', lp_handle)
  - In MATLAB, this routine has two formats. The first format is identical to the API. The second format allows retrieving the values into a MATLAB matrix.
- get_scalelimit
  - return = mxlpsolve('get_scalelimit', lp_handle)
  - No special considerations.
- get_scaling
  - return = mxlpsolve('get_scaling', lp_handle)
  - No special considerations.
- get_sensitivity_obj, get_sensitivity_objex
  - [objfrom, objtill, objfromvalue, objtillvalue, return] = mxlpsolve('get_sensitivity_obj', lp_handle)
  - [objfrom, objtill, objfromvalue, objtillvalue, return] = mxlpsolve('get_sensitivity_objex', lp_handle)
  - The objfrom, objtill, objfromvalue, objtillvalue arguments in the API documentation are here the return values. Note that MATLAB allows the return of fewer variables. For example if only objfrom and objtill are needed then the call can be [objfrom, objtill] = mxlpsolve('get_sensitivity_obj', lp_handle). The unrequested values are even not calculated.
  - Since the API routine doesn't calculate the objtillvalue value at this time, MATLAB always returns a zero vector for this.
  - The return code of the call is the last value.
  - get_sensitivity_obj and get_sensitivity_objex are both implemented, but have the same functionality.
- get_sensitivity_rhs, get_sensitivity_rhsex
  - [duals, dualsfrom, dualstill, return] = mxlpsolve('get_sensitivity_rhs', lp_handle)
  - [duals, dualsfrom, dualstill, return] = mxlpsolve('get_sensitivity_rhsex', lp_handle)
  - The duals, dualsfrom, dualstill arguments in the API documentation are here the return values. Note that MATLAB allows the return of fewer variables. For example if only duals is needed then the call can be [duals] = mxlpsolve('get_sensitivity_rhs', lp_handle). The unrequested values are even not calculated.
  - The return code of the call is the last value.
  - get_sensitivity_rhs and get_sensitivity_rhsex are both implemented, but have the same functionality.
- get_simplextype
  - return = mxlpsolve('get_simplextype', lp_handle)
  - No special considerations.
- get_solutioncount
  - return = mxlpsolve('get_solutioncount', lp_handle)
  - No special considerations.
- get_solutionlimit
  - return = mxlpsolve('get_solutionlimit', lp_handle)
  - No special considerations.
- get_status
  - return = mxlpsolve('get_status', lp_handle)
  - No special considerations.
- get_statustext
  - return = mxlpsolve('get_statustext', lp_handle, statuscode)
  - No special considerations.
- get_timeout
  - return = mxlpsolve('get_timeout', lp_handle)
  - No special considerations.
- get_total_iter
  - return = mxlpsolve('get_total_iter', lp_handle)
  - No special considerations.
- get_total_nodes
  - return = mxlpsolve('get_total_nodes', lp_handle)
  - No special considerations.
- get_upbo
  - return = mxlpsolve('get_upbo', lp_handle, column)
  - [upbo] = mxlpsolve('get_upbo', lp_handle)
  - In MATLAB, this routine has two formats. The first format is identical to the API. The second format allows retrieving the values into a MATLAB matrix.
- get_var_branch
  - return = mxlpsolve('get_var_branch', lp_handle, column)
  - [var_branch] = mxlpsolve('get_var_branch', lp_handle)
  - In MATLAB, this routine has two formats. The first format is identical to the API. The second format allows retrieving the values into a MATLAB matrix.
- get_var_dualresult
  - return = mxlpsolve('get_var_dualresult', lp_handle, index)
  - No special considerations.
- get_var_primalresult
  - return = mxlpsolve('get_var_primalresult', lp_handle, index)
  - No special considerations.
- get_var_priority
  - return = mxlpsolve('get_var_priority', lp_handle, column)
  - [var_priority] = mxlpsolve('get_var_priority', lp_handle)
  - In MATLAB, this routine has two formats. The first format is identical to the API. The second format allows retrieving the values into a MATLAB matrix.
- get_variables
  - [var, return] = mxlpsolve('get_variables', lp_handle)
  - The var argument in the API documentation is here the first return value.
  - The return code of the call is the second return value.
- get_verbose
  - return = mxlpsolve('get_verbose', lp_handle)
  - No special considerations.
- get_working_objective
  - return = mxlpsolve('get_working_objective', lp_handle)
  - No special considerations.
- has_BFP
  - return = mxlpsolve('has_BFP', lp_handle)
  - No special considerations.
- has_XLI
  - return = mxlpsolve('has_XLI', lp_handle)
  - No special considerations.
- is_add_rowmode
  - return = mxlpsolve('is_add_rowmode', lp_handle)
  - No special considerations.
- is_anti_degen
  - return = mxlpsolve('is_anti_degen', lp_handle, testmask)
  - No special considerations.
- is_binary
  - return = mxlpsolve('is_binary', lp_handle, column)
  - [binary] = mxlpsolve('is_binary', lp_handle)
  - In MATLAB, this routine has two formats. The first format is identical to the API. The second format allows retrieving the values into a MATLAB matrix.
- is_break_at_first
  - return = mxlpsolve('is_break_at_first', lp_handle)
  - No special considerations.
- is_constr_type
  - return = mxlpsolve('is_constr_type', lp_handle, row, mask)
  - No special considerations.
- is_debug
  - return = mxlpsolve('is_debug', lp_handle)
  - No special considerations.
- is_feasible
  - return = mxlpsolve('is_feasible', lp_handle, [values] {, threshold})
  - The threshold argument is optional. When not provided, the value of get_epsint will be taken.
- is_free
  - return = mxlpsolve('is_free', lp_handle, column)
  - [free] = mxlpsolve('is_free', lp_handle)
  - In MATLAB, this routine has two formats. The first format is identical to the API. The second format allows retrieving the values into a MATLAB matrix.
- is_infinite
  - return = mxlpsolve('is_infinite', lp_handle, value)
  - No special considerations.
- is_int
  - return = mxlpsolve('is_int', lp_handle, column)
  - [int] = mxlpsolve('is_int', lp_handle)
  - In MATLAB, this routine has two formats. The first format is identical to the API. The second format allows retrieving the values into a MATLAB matrix.
- is_integerscaling
  - return = mxlpsolve('is_integerscaling', lp_handle)
  - No special considerations.
- is_maxim
  - return = mxlpsolve('is_maxim', lp_handle)
  - No special considerations.
- is_nativeBFP
  - return = mxlpsolve('is_nativeBFP', lp_handle)
  - No special considerations.
- is_nativeXLI
  - return = mxlpsolve('is_nativeXLI', lp_handle)
  - No special considerations.
- is_negative
  - return = mxlpsolve('is_negative', lp_handle, column)
  - [negative] = mxlpsolve('is_negative', lp_handle)
  - In MATLAB, this routine has two formats. The first format is identical to the API. The second format allows retrieving the values into a MATLAB matrix.
- is_piv_mode
  - return = mxlpsolve('is_piv_mode', lp_handle, testmask)
  - No special considerations.
- is_piv_rule
  - return = mxlpsolve('is_piv_rule', lp_handle, rule)
  - No special considerations.
- is_presolve
  - return = mxlpsolve('is_presolve', lp_handle, testmask)
  - No special considerations.
- is_scalemode
  - return = mxlpsolve('is_scalemode', lp_handle, testmask)
  - No special considerations.
- is_scaletype
  - return = mxlpsolve('is_scaletype', lp_handle, scaletype)
  - No special considerations.
- is_semicont
  - return = mxlpsolve('is_semicont', lp_handle, column)
  - [semicont] = mxlpsolve('is_semicont', lp_handle)
  - In MATLAB, this routine has two formats. The first format is identical to the API. The second format allows retrieving the values into a MATLAB matrix.
- is_SOS_var
  - return = mxlpsolve('is_SOS_var', lp_handle, column)
  - [SOS_var] = mxlpsolve('is_SOS_var', lp_handle)
  - In MATLAB, this routine has two formats. The first format is identical to the API. The second format allows retrieving the values into a MATLAB matrix.
- is_trace
  - return = mxlpsolve('is_trace', lp_handle)
  - No special considerations.
- lp_solve_version
  - versionstring = mxlpsolve('lp_solve_version')
  - The mxlpsolve API routine returns the version information in 4 provided argument variables while the MATLAB version returns the information as a string in the format major.minor.release.build
- make_lp
  - lp_handle = mxlpsolve('make_lp', rows, columns)
  - lp_handle is not a pointer to an lprec structure as in the API, but an incrementing handle number starting from 0.
- print_constraints
  - mxlpsolve('print_constraints', lp_handle {, columns})
  - columns is optional. If not specified, then 1 is used.
  - First call set_outputfile to specify where the information is written to. In the API documentation it is written that by default, the output goes to stdout, but under MATLAB (Windows) this means that the output is not shown.
  - The same information can also be obtained via mxlpsolve('get_constraints', lp_handle). This shows the result on screen.
- print_debugdump
  - return = mxlpsolve('print_debugdump', lp_handle, filename)
  - No special considerations.
- print_duals
  - mxlpsolve('print_duals', lp_handle)
  - First call set_outputfile to specify where the information is written to. In the API documentation it is written that by default, the output goes to stdout, but under MATLAB (Windows) this means that the output is not shown.
  - The same information can be obtained via mxlpsolve('get_dual_solution', lp_handle). This shows the result on screen.
- print_lp
  - mxlpsolve('print_lp', lp_handle)
  - First call set_outputfile to specify where the information is written to. In the API documentation it is written that by default, the output goes to stdout, but under MATLAB (Windows) this means that the output is not shown.
- print_objective
  - mxlpsolve('print_objective', lp_handle)
  - First call set_outputfile to specify where the information is written to. In the API documentation it is written that by default, the output goes to stdout, but under MATLAB (Windows) this means that the output is not shown.
  - The same information can be obtained via mxlpsolve('get_objective', lp_handle). This shows the result on screen.
- print_scales
  - mxlpsolve('print_scales', lp_handle)
  - First call set_outputfile to specify where the information is written to. In the API documentation it is written that by default, the output goes to stdout, but under MATLAB (Windows) this means that the output is not shown.
- print_solution
  - mxlpsolve('print_solution', lp_handle {, columns})
  - columns is optional. If not specified, then 1 is used.
  - First call set_outputfile to specify where the information is written to. In the API documentation it is written that by default, the output goes to stdout, but under MATLAB (Windows) this means that the output is not shown.
  - The same information can also be obtained via mxlpsolve('get_variables', lp_handle). This shows the result on screen.
- print_str
  - mxlpsolve('print_str', lp_handle, str)
  - First call set_outputfile to specify where the information is written to. In the API documentation it is written that by default, the output goes to stdout, but under MATLAB (Windows) this means that the output is not shown.
- print_tableau
  - mxlpsolve('print_tableau', lp_handle)
  - First call set_outputfile to specify where the information is written to. In the API documentation it is written that by default, the output goes to stdout, but under MATLAB (Windows) this means that the output is not shown.
- put_abortfunc
  - Not implemented.
- put_logfunc
  - Not implemented.
  - However, the mxlpsolve driver sets a log function to redirect the output of lpsolve from stdout (which is not visible in Windows MATLAB) to the command window of MATLAB. As such, all reported output can be seen in MATLAB. How much output is seen is controlled by the verbose level that can be defined by set_verbose or can be specified in the read_ routines.
- put_msgfunc
  - Not implemented.
- read_freemps, read_freeMPS
  - lp_handle = mxlpsolve('read_freemps', filename {, verbose})
  - lp_handle = mxlpsolve('read_freeMPS', filename {, verbose})
  - In the lpsolve API, read_freemps needs a FILE handle. In MATLAB it needs the filename and thus acts the same as read_freeMPS.
  - lp_handle is not a pointer to an lprec structure as in the API, but an incrementing handle number starting from 0.
  - verbose is optional. If not specified, then NORMAL is used.
- read_lp, read_LP
  - lp_handle = mxlpsolve('read_lp', filename {, verbose {, lp_name}})
  - lp_handle = mxlpsolve('read_LP', filename {, verbose {, lp_name}})
  - In the lpsolve API, read_lp needs a FILE handle. In MATLAB it needs the filename and thus acts the same as read_LP.
  - lp_handle is not a pointer to an lprec structure as in the API, but an incrementing handle number starting from 0.
  - verbose is optional. If not provided then NORMAL is used.
  - lp_name is optional. If not provided then no name is given to the model ('').
- read_mps, read_MPS
  - lp_handle = mxlpsolve('read_mps', filename {, verbose})
  - lp_handle = mxlpsolve('read_MPS', filename {, verbose})
  - In the lpsolve API, read_mps needs a FILE handle. In MATLAB it needs the filename and thus acts the same as read_MPS.
  - lp_handle is not a pointer to an lprec structure as in the API, but an incrementing handle number starting from 0.
  - verbose is optional. If not specified, then NORMAL is used.
- read_XLI
  - lp_handle = mxlpsolve('read_XLI', xliname, modelname {, dataname {, options {, verbose}}}
  - lp_handle is not a pointer to an lprec structure as in the API, but an incrementing handle number starting from 0.
  - dataname is optional. When not provided, '' (NULL) is taken. '' is taken as NULL.
  - options is optional. When not provided, '' is taken.
  - verbose is optional. If not specified, then NORMAL is used.
- reset_basis
  - Not implemented.
  - Use default_basis
- set_add_rowmode
  - return = mxlpsolve('set_add_rowmode', lp_handle, turnon)
  - No special considerations.
- set_anti_degen
  - mxlpsolve('set_anti_degen', lp_handle, anti_degen)
  - No special considerations.
- set_basis
  - return = mxlpsolve('set_basis', lp_handle, [bascolumn], nonbasic)
  - In the API, element 0 of bascolumn is not used and values start from element 1. In MATLAB, there is no unused element in the matrix.
- set_basiscrash
  - mxlpsolve('set_basiscrash', lp_handle, mode)
  - No special considerations.
- set_bb_depthlimit
  - mxlpsolve('set_bb_depthlimit', lp_handle, bb_maxlevel)
  - No special considerations.
- set_bb_floorfirst
  - mxlpsolve('set_bb_floorfirst', lp_handle, bb_floorfirst)
  - No special considerations.
- set_bb_rule
  - mxlpsolve('set_bb_rule', lp_handle, bb_rule)
  - No special considerations.
- set_BFP
  - return = mxlpsolve('set_BFP', lp_handle, filename)
  - No special considerations.
- set_binary
  - return = mxlpsolve('set_binary', lp_handle, column, must_be_bin)
  - return = mxlpsolve('set_binary', lp_handle, [must_be_bin])
  - In MATLAB, this routine has two formats. The first format is identical to the API. The second format allows setting a matrix of all variables.
- set_bounds
  - return = mxlpsolve('set_bounds', lp_handle, column, lower, upper)
  - return = mxlpsolve('set_bounds', lp_handle, [lower], [upper])
  - In MATLAB, this routine has two formats. The first format is identical to the API. The second format allows setting a matrix of all variables.
- set_bounds_tighter
  - mxlpsolve('set_bounds_tighter', lp_handle, tighten)
  - No special considerations.
- set_break_at_first
  - mxlpsolve('set_break_at_first', lp_handle, break_at_first)
  - No special considerations.
- set_break_at_value
  - mxlpsolve('set_break_at_value', lp_handle, break_at_value)
  - No special considerations.
- set_col_name
  - return = mxlpsolve('set_col_name', lp_handle, column, name)
  - return = mxlpsolve('set_col_name', lp_handle, [names])
  - In MATLAB, this routine has two formats. The first format is identical to the API. The second format allows setting a matrix of all variables.
- set_column, set_columnex
  - return = mxlpsolve('set_column', lp_handle, col_no, [column])
  - return = mxlpsolve('set_columnex', lp_handle, col_no, [column])
  - Both have the same interface from set_column but act as set_columnex
- set_constr_type
  - return = mxlpsolve('set_constr_type', lp_handle, row, con_type)
  - return = mxlpsolve('set_constr_type', lp_handle, [con_type])
  - In MATLAB, this routine has two formats. The first format is identical to the API. The second format allows setting a matrix of all rows.
- set_debug
  - mxlpsolve('set_debug', lp_handle, debug)
  - No special considerations.
- set_epsb
  - mxlpsolve('set_epsb', lp_handle, epsb)
  - No special considerations.
- set_epsd
  - mxlpsolve('set_epsd', lp_handle, epsd)
  - No special considerations.
- set_epsel
  - mxlpsolve('set_epsel', lp_handle, epsel)
  - No special considerations.
- set_epsint
  - mxlpsolve('set_epsint', lp_handle, epsint)
  - No special considerations.
- set_epsperturb
  - mxlpsolve('set_epsperturb', lp_handle, epsperturb)
  - No special considerations.
- set_epspivot
  - mxlpsolve('set_epspivot', lp_handle, epspivot)
  - No special considerations.
- set_free
  - return = mxlpsolve('set_free', lp_handle, column)
  - No special considerations.
- set_improve
  - mxlpsolve('set_improve', lp_handle, improve)
  - No special considerations.
- set_infinite
  - mxlpsolve('set_infinite', lp_handle, infinite)
  - No special considerations.
- set_int
  - return = mxlpsolve('set_int', lp_handle, column, must_be_int)
  - return = mxlpsolve('set_int', lp_handle, [must_be_int])
  - In MATLAB, this routine has two formats. The first format is identical to the API. The second format allows setting a matrix of all variables.
- set_lowbo
  - return = mxlpsolve('set_lowbo', lp_handle, column, value)
  - return = mxlpsolve('set_lowbo', lp_handle, [values])
  - In MATLAB, this routine has two formats. The first format is identical to the API. The second format allows setting a matrix of all variables.
- set_lp_name
  - return = mxlpsolve('set_lp_name', lp_handle, name)
  - No special considerations.
- set_mat
  - return = mxlpsolve('set_mat', lp_handle, row, column, value)
  - return = mxlpsolve('set_mat', lp_handle, [matrix])
  - In MATLAB, this routine has two formats. The first format is identical to the API. The second format allows to set the whole matrix (all rows/columns) at once. This is the most performant way to provide the constraint matrix. Consider using a MATLAB sparse matrix for maximum performance and least memory usage. The matrix must be two-dimentional.
- set_maxim
  - mxlpsolve('set_maxim', lp_handle)
  - No special considerations.
- set_maxpivot
  - mxlpsolve('set_maxpivot', max_num_inv)
  - No special considerations.
- set_minim
  - mxlpsolve('set_minim', lp_handle)
  - No special considerations.
- set_mip_gap
  - mxlpsolve('set_mip_gap', lp_handle, absolute, mip_gap)
  - No special considerations.
- set_negrange
  - mxlpsolve('set_negrange', negrange)
  - No special considerations.
- set_obj
  - return = mxlpsolve('set_obj', lp_handle, column, value)
  - return = mxlpsolve('set_obj', lp_handle, [values])
  - In MATLAB, this routine has two formats. The first format is identical to the API. The second format allows setting a matrix of all variables. It is then the same as set_obj_fn
- set_obj_bound
  - mxlpsolve('set_obj_bound', lp_handle, obj_bound)
  - No special considerations.
- set_obj_fn, set_obj_fnex
  - return = mxlpsolve('set_obj_fn', lp_handle, [row])
  - return = mxlpsolve('set_obj_fnex', lp_handle, [row])
  - Both have the same interface from set_obj_fn but act as set_obj_fnex
  - In the API, element 0 is not used and values start from element 1. In MATLAB, there is no unused element in the matrix.
- set_outputfile
  - return = mxlpsolve('set_outputfile', lp_handle, filename)
  - In the API description it says that setting filename to NULL results in writing output back to stdout. In MATLAB under Windows, output to stdout it not shown. However it results in closing the file. Use '' to have the effect of NULL.
- set_outputstream
  - Not implemented.
- set_pivoting
  - mxlpsolve('set_pivoting', lp_handle, pivoting)
  - No special considerations.
- set_preferdual
  - mxlpsolve('set_preferdual', lp_handle, dodual)
  - No special considerations.
- set_presolve
  - mxlpsolve('set_presolve', lp_handle, do_presolve)
  - No special considerations.
- set_print_sol
  - mxlpsolve('set_print_sol', lp_handle, print_sol)
  - No special considerations.
- set_rh
  - return = mxlpsolve('set_rh', lp_handle, row, value)
  - return = mxlpsolve('set_rh', lp_handle, [values])
  - In MATLAB, this routine has two formats. The first format is identical to the API. The second format allows setting a matrix of all rows. Note that in this case, the value of row 0 is not specified in the matrix.
- set_rh_range
  - return = mxlpsolve('set_rh_range', lp_handle, row, deltavalue)
  - return = mxlpsolve('set_rh_range', lp_handle, [deltavalues])
  - In MATLAB, this routine has two formats. The first format is identical to the API. The second format allows setting a matrix of all rows.
- set_rh_vec
  - mxlpsolve('set_rh_vec', lp_handle, [rh])
  - In the API, element 0 is not used and values start from element 1. In MATLAB, there is no unused element in the matrix.
- set_row, set_rowex
  - return = mxlpsolve('set_row', lp_handle, row_no, [row])
  - return = mxlpsolve('set_rowex', lp_handle, row_no, [row])
  - Both have the same interface from set_row but act as set_rowex
  - In the API, element 0 is not used and values start from element 1. In MATLAB, there is no unused element in the matrix.
- set_row_name
  - return = mxlpsolve('set_row_name', lp_handle, row, name)
  - return = mxlpsolve('set_row_name', lp_handle, [names])
  - In MATLAB, this routine has two formats. The first format is identical to the API. The second format allows setting a matrix of all rows.
- set_scalelimit
  - mxlpsolve('set_scalelimit', lp_handle, scalelimit)
  - No special considerations.
- set_scaling
  - mxlpsolve('set_scaling', lp_handle, scalemode)
  - No special considerations.
- set_semicont
  - return = mxlpsolve('set_semicont', lp_handle, column, must_be_sc)
  - return = mxlpsolve('set_semicont', lp_handle, [must_be_sc])
  - In MATLAB, this routine has two formats. The first format is identical to the API. The second format allows setting a matrix of all variables.
- set_sense
  - mxlpsolve('set_sense', lp_handle, maximize)
  - No special considerations.
- set_simplextype
  - mxlpsolve('set_simplextype', lp_handle, simplextype)
  - No special considerations.
- set_solutionlimit
  - mxlpsolve('set_solutionlimit', lp_handle, simplextype)
  - No special considerations.
- set_timeout
  - mxlpsolve('set_timeout', lp_handle, sectimeout)
  - No special considerations.
- set_trace
  - mxlpsolve('set_trace', lp_handle, trace)
  - No special considerations.
- set_upbo
  - return = mxlpsolve('set_upbo', lp_handle, column, value)
  - return = mxlpsolve('set_upbo', lp_handle, [values])
  - In MATLAB, this routine has two formats. The first format is identical to the API. The second format allows setting a matrix of all variables.
- set_var_branch
  - return = mxlpsolve('set_var_branch', lp_handle, column, branch_mode)
  - return = mxlpsolve('set_var_branch', lp_handle, [branch_mode])
  - In MATLAB, this routine has two formats. The first format is identical to the API. The second format allows setting a matrix of all variables.
- set_var_weights
  - return = mxlpsolve('set_var_weights', lp_handle, [weights])
  - No special considerations.
- set_verbose
  - mxlpsolve('set_verbose', lp_handle, verbose)
  - No special considerations.
- set_XLI
  - return = mxlpsolve('set_XLI', lp_handle, filename)
  - No special considerations.
- solve
  - result = mxlpsolve('solve', lp_handle)
  - No special considerations.
- str_add_column
  - Not implemented.
- str_add_constraint
  - Not implemented.
- str_set_obj_fn
  - Not implemented.
- str_set_rh_vec
  - Not implemented.
- time_elapsed
  - return = mxlpsolve('time_elapsed', lp_handle)
  - No special considerations.
- unscale
  - mxlpsolve('unscale', lp_handle)
  - No special considerations.
- write_freemps, write_freeMPS
  - return = mxlpsolve('write_freemps', lp_handle, filename)
  - return = mxlpsolve('write_freeMPS', lp_handle, filename)
  - In the lpsolve API, write_freeMPS needs a FILE handle. In MATLAB it needs the filename and thus acts the same as write_freemps.
- write_lp, write_LP
  - return = mxlpsolve('write_lp', lp_handle, filename)
  - return = mxlpsolve('write_LP', lp_handle, filename)
  - In the lpsolve API, write_LP needs a FILE handle. In MATLAB it needs the filename and thus acts the same as write_lp.
- write_mps, write_MPS
  - return = mxlpsolve('write_mps', lp_handle, filename)
  - return = mxlpsolve('write_MPS', lp_handle, filename)
  - In the lpsolve API, write_MPS needs a FILE handle. In MATLAB it needs the filename and thus acts the same as write_mps.
  - No special considerations.
- write_XLI
  - return = mxlpsolve('write_XLI', lp_handle, filename {, options {, results}})
  - No special considerations.

### Extra MATLAB routines

These routines are not part of the lpsolve API, but are added for backwards compatibility. Most of them exist in the lpsolve API with another name.

- [names] = mxlpsolve('get_col_names', lp_handle)
  - The same as get_col_name. Implemented for backwards compatibility.
- [constr_type] = mxlpsolve('get_constr_types', lp_handle)
  - The same as get_constr_type. Implemented for backwards compatibility.
- [int] = mxlpsolve('get_int', lp_handle)
  - The same as is_int. Implemented for backwards compatibility.
- return = mxlpsolve('get_no_cols', lp_handle)
  - The same as get_Ncolumns. Implemented for backwards compatibility.
- return = mxlpsolve('get_no_rows', lp_handle)
  - The same as get_Nrows. Implemented for backwards compatibility.
- name = mxlpsolve('get_objective_name', lp_handle)
  - The same as get_row_name with row=0. Implemented for backwards compatibility.
- [row_vec, return] = mxlpsolve('get_obj_fn', lp_handle)
  [row_vec, return] = mxlpsolve('get_obj_fun', lp_handle)
  - The same as get_row with row 0. Implemented for backwards compatibility.
- name = mxlpsolve('get_problem_name', lp_handle)
  - The same as get_lp_name. Implemented for backwards compatibility.
- [costs] = mxlpsolve('get_reduced_costs', lp_handle)
  - The same as get_dual_solution. Implemented for backwards compatibility.
- [names] = mxlpsolve('get_row_names', lp_handle)
  - The same as get_row_name. Implemented for backwards compatibility.
- [obj, x, duals, return] = mxlpsolve('get_solution', lp_handle)
  - Returns the value of the objective function, the values of the variables and the duals. Implemented for backwards compatibility.
  - The return code of the call is the last value.
- value = mxlpsolve('mat_elm', lp_handle)
  - The same as get_mat. Implemented for backwards compatibility.
- [handle_vec] = mxlpsolve('print_handle')
  - Returns a vector with open handles. Can be handy to see which handles aren't closed yet with delete_lp or free_lp.
- lp_handle = mxlpsolve('read_lp_file', filename {, verbose {, lp_name}})
  - The same as read_LP. Implemented for backwards compatibility.

### Compile the mxlpsolve driver

#### Windows

Under Windows, the mxlpsolve MATLAB driver is a dll: mxlpsolve.dll
This dll is an interface to the lpsolve51.dll lpsolve dll that contains the implementation of lp_solve. lpsolve51.dll is distributed with the lp_solve package. The mxlpsolve MATLAB driver dll (mxlpsolve.dll) is just a wrapper between MATLAB and lp_solve to translate the input/output to/from MATLAB and the lp_solve library.

The mxlpsolve MATLAB driver is written in C. To compile this code, the MATLAB compiler is needed (mex). This compiler must be called from MATLAB. To make the compilation process easier, a makefile can be used: MakefileWin.m
Enter 'help MakefileWin' from the MATLAB command window to see a list of options.
It may be necessary to edit this file first to change the path where lp_solve is installed. Change at the beginning lpsolvepath.
To make for release, just enter MakefileWin and everything is build.
This compiles two source files: lpsolve.c and hash.c
Then these are linked with the library lp_explicit.lib to generate the mxlpsolve.dll file. The lp_explicit.lib file is a wrapper library between the lp_solve dll and the compiled application. This wrapper is needed because the lp_solve dll uses __stdcall calling convention. There seems to be a problem in MATLAB to call __stdcall functions directly (unexpected crashes). The lp_explicit library uses __cdecl calling convention and this then calls the lp_solve dll which uses __stdcall calling convention. Looks a bit complex, but it works without any problem.
The optional arguments to MakefileWin are used for development. The first argument allows specifying a filename so that only this file is build. For example hash.c should only be compiled once while developing. So specifying 'lpsolve.c' as first argument will only compile this file and then link everything. This makes the build process a bit faster. The second argument is by default 0. When set to 1, then extra argument checking is done and while executing, some debug information is printed. Should only be used for debugging purposes. When released, this parameter should be 0. The third argument is by default 1. When set to 0, the makefile will not ask to press enter to start building.

There appears to be another way to compile MATLAB mex files with gcc for Windows. This is not tested. See Compiling Matlab mex files with gcc for Windows.

#### Unix/Linux

Untested! Should be something like.
<MATLAB-DIR>/bin/mex -I../../.. -L../../../lpsolve51 -O3 lpsolve.c hash.c -llpsolve51 -lm

Note: A full path to mex has been given in case teTeX is installed and so there is another mex:

    $ which mex

    /usr/local/teTeX/bin/mex

If anyone has made this work, please let know to Peter Notebaert to update this document.

See also Using lpsolve from Scilab, Using lpsolve from O-Matrix