% CPLEX - Use CPLEX solvers (simplex, barrier, mip) interactively in MATLAB
% 
% MEX interface, Copyright (C) 2000-2001 Mikael Prytz. Type CPLEX('show license') for license info.
%
% USAGE: S = CPLEX(COMMAND, PROBLEM, PARAM1, PARAM2, ...)
%
%  where COMMAND = CPLEX command to execute, text string
%        PROBLEM = problem object in Matlab MEX memory, text string
%        PARAM1, etc. = parameters required by the command
%        S = output from the command, structure array
%
% If PROBLEM = '', then COMMAND is applied to the same problem object as in the
% last call to cplex. Note that a few commands apply to all problem objects and do
% not have a PROBLEM argument.
%
% The no argument form, S = CPLEX, returns a list of the problem objects that
% are currently stored in Matlab MEX memory.
%
% One CPLEX license is held as long as there are open problem objects in Matlab MEX
% memory. Use 'free problem' or 'free all problems' to remove problem objects that are
% no longer used. The CPLEX license is released when the last problem object is freed.
%
% The "immediate solve" form, S = CPLEX(SOLVER, c, A, b, OPTDAT, CPXPAR),
% solves the linear (continuous or integer) program
%
%        min c'x
%        s.t Ax <=> b
%            u >= x >= l, where
%
% SOLVER = the CPLEX command for one of the solvers, see below,
%      c = objective coefficients; vector of real numbers, length = n,
%      A = constraint coefficients; (m x n)-matrix of real numbers, numrows = m,
%          numcols = n,
%      b = right hand side coefficients; vector of real numbers, length = m,
% OPTDAT = optional, can contain bounds (u and l), constraint senses (<=, =, >=), variable
%          types (continuous 'C', binary 'B', integer 'I'), starting solution, etc,
% CPXPAR = optional, contains CPLEX parameter values.
%
% Note that Ax = b, u = inf, and l = 0 is assumed if OPTDAT is not specified for the
% "immediate solve" form. Technically, the immediate solve first creates a temporary
% problem object, applies the solver, returns all possible solver results, and then
% removes the temporary problem object. This means that if CTRL+C is used to abort a
% lengthy solve operation, the temporary problem object remains in memory so that any
% intermediate results (such as best integer feasible solution) can be retrieved. It
% also means that a CPLEX license is held until the temporary problem is freed.
%
% All real number data should be stored using double, single or int32 MATLAB type,
% and may be sparse or dense. The MEX interface converts between the different forms
% of CPLEX sparse matrix storage (row- or columnordered).
%
% Type   HELP CPLEX_CMD  for descriptions of the available CPLEX commands (COMMAND),
%        HELP CPLEX_OPT  for information on CPLEX optional data (OPTDAT),
%        HELP CPLEX_PAR  for information on how to set CPLEX parameters (CPXPAR),
%        HELP CPLEX_OUT  for information on how to interpret the output (S).
% 
% Summary of available CPLEX commands, type HELP CPLEX_CMD for descriptions
% -------------------------------------------------------------------------
% COMMAND can be any of of (name and alternative name, if available, is listed; note that
% each word in the command may be abbreviated, as long as the command is distinguishable):
%    'show license',
%    'primopt',                       'primal simplex'
%    'tranopt',                       'dual simplex'
%    'netopt primal',                 'hybrid network primal'
%    'netopt dual',                   'hybrid network dual'
%    'mipopt'
%    'baropt stop',                   'barrier'
%    'baropt primopt',                'hybrid barrier primal'
%    'baropt dualopt',                'hybrid barrier dual'
%    'set logfile',                   'logfile'
%    'set cplex parameters',          'set cpxpar'
%    'create problem'
%    'free problem'
%    'free all problems'
%    'set minimization',              'minimization'
%    'set maximization',              'maximization'
%    'new constraints',               'new rows'
%    'add constraints',               'add rows'
%    'delete constratins',            'delete rows'
%    'new variables',                 'new columns'
%    'add variables',                 'add columns'
%    'delete variables',              'delete columns'
%    'copy optional data',            'copy optdat'
%    'copy objective name',           'copy objname'
%    'copy variable types',           'copy ctype'
%    'copy start information',        'copy basis'
%    'copy priority order',           'copy order'
%    'copy mip start',                'copy mipstart'
%    'copy sos'
%    'change coefficients'
%    'change bounds'
%    'change constraint senses',      'change sense'
%    'change objective coefficients', 'change c'
%    'change rhs coefficients',       'change b'
%    'change range coefficients',     'change rngval'
%    'change variable types',         'change ctype'
%    'change problem type'
%    'change constraint names',       'change rowname'
%    'change variable names',         'change colname'
%    'get solution'
%    'get simplex solution',          'get lp solution'
%    'get barrier solution'
%    'get mip solution'
%    'get status solver'
%    'get objective value'
%    'get variable values'
%    'get slack values',              'get constraint slacks'
%    'get itcnt',                     'get iteration count'
%    'get nodecnt',                   'get node count'
%    'get bestbound',                 'get best bound'
%    'get nodeleftcnt',               'get nodeleft count'
%    'get nodeint',                   'get nodenumber integersolution'
%    'get cutoff'
%    'get genclqcnt',                 'get generated cliqueinequalities'
%    'get clqcnt',                    'get clique cuts'
%    'get covcnt',                    'get cover cuts'
%    'get dual values',               'get dual variables'
%    'get basis status'
%    'get reduced costs',             'get reducedcost values'
%    'get phase1cnt',                 'get phase1 iterations'
%    'get sensitivity values',        'get sensitivity information'
%    'get iis',                       'get irreducible infeasibleset'
%    'get quality'
%    'get objective name',            'get objname'
%    'get variable names',            'get colname'
%    'get constraint names',          'get rowname'
%    'get variable index',            'get colindex'
%    'get constraint index',          'get rowindex'
%    'get number variables',          'get numcols'
%    'get number constraints',        'get numrows'
%    'get number nonzeros',           'get numnz'
%    'get objective sense',           'get objsen'
%    'get rhs coefficients',          'get b'
%    'get constraint senses',         'get sense'
%    'get lower bounds',              'get lb'
%    'get upper bounds',              'get ub'
%    'get constraint columns',        'get cols'
%    'get constraint rows',           'get rows'
%    'get constraint coefficient',    'get coef'
%    'get range coefficients',        'get rngval'
%    'get problem type',              'get probtype'
%    'get number integer',            'get numint'
%    'get number binary',             'get numbin'
%    'get variable types',            'get ctype'
%    'get priority order',            'get order'
%    'get number sos',                'get numsos'
%    'get sos',                       'get sos'


% CPLEX.M
%
% Main help file for the CPLEX MEX interface to use CPLEX interactively in MATLAB.
% Copyright (C) 2000-2001 Mikael Prytz
%
% This file is part of the CPLEX MEX interface.
%
% The CPLEX MEX interface is free software; you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation; either version 2 of the License, or
% (at your option) any later version.
%
% The CPLEX MEX interface is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with the CPLEX MEX interface; if not, write to the Free Software
% Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
%
% Uses Application Program Interfaces (API) for MATLAB and CPLEX. Licenses
% for these, and the relevant files and libraries, must be obtained separately
% from Mathworks Inc. and ILOG Inc. respectively.
%
% ------------------------------------------------------------------------------
%
% This MATLAB MEX interface gives access to most of the CPLEX interactive mode
% functionality from within MATLAB. Several CPLEX problem objects can reside
% in MATLAB memory simultaneously, complete with current solution, reduced costs,
% basis, etc. The problem objects can be modified in memory, which allows CPLEX to take
% advantage of a current solution when resolving.
%
% ver 0.91, Mikael Prytz 2001-05-30
%           Minimal modifications for CPLEX 6.5 and MATLAB 6.0.
%           Some CPLEX 6.5 parameters not implemented. Network problem objects
%           not implemented (yet...)
%
% ver 0.9,  Mikael Prytz 2000-11-02
%           First "release" developed for CPLEX 6.0 and MATLAB 5.3.
%           Functionality limited to simplex, network, barrier and MIP solvers.
%           Code tested under Solaris 2.5.1 and Solaris 2.6.
%           Traps SIGINT signal (CTRL+C) using <signal.h> functions, so that lengthy
%           CPLEX operations can be gracefully terminated and intermediate solution
%           data be retrieved.
%
% Author:   Mikael Prytz
% Email:    mikael.prytz@math.kth.se
% WWW:      http://www.math.kth.se/~mikaelp/
