Get a tool to automatically generates your mex-files from standard C/Fortran codes

Using CPLEX with MATLAB

Claude Tadonki
Computer scientist

Note : This page provides matlab routines (with associated c mex-file) to run cplex features in a matlab environment. The initial routines (lp and qp) was done by David Musicant ( Carleton College ). Several extensions including the optimization options, error handling, and the adaptation to the Mixed Integer Programming was done by Claude Tadonki (University of Geneva). You are allowed to download and use materials of this page freely for research purposes, provided you correctly mention the authors as described in each file. Here you can get code for lp, qp, and mip with cplex 6.5 and cplex 8.1.

Download all files as a single tar file

C Mex-Files should be compiled with the command

                       mex   -I/cplex_include_fullpath   -L/cplex_library_fullpath   -lcplex  file.c

Original file for Solving a standard linear programming problem

See here

 

General Linear Programming

[obj, x, lambda, status, colstat, it] = lp_cplex(c, A, b, l, u, le, ge, maxIter, optimizer)

min  c' * x   with linear constraints

optimizer is a variable for optimizer choice, which can be one of the following
0 : primal simplex
1 : dual simplex
2 : network
3 : primal - dual barrier

Download                                                     Matlab file             Associated mex file

 

 

Quadratic Programming

[obj, x, lambda, status, colstat, it] = qp_cplex(q, c, A, b, l, u, le, ge, maxIter)

min 1/2 * x' * Q * x + c' * x  with linear contraints

Download                                                     Matlab file             Associated mex file

 

 

Mixed Integer Programming

[obj, x, lambda, status, colstat, it] = mip_cplex(q, c, A, b, l, u, le, ge, binvar, genvar, maxIter, verbose)

min  c' * x   with linear contraints and integer variables ( binary or general )

Indices of binary variables are listed in binvar, and indices of general integer variables are listed in genvar

Download                                                     Matlab file             Associated mex file

Get a tool to automatically generates your mex-files from standard C/Fortran codes