Small bug corrected.
3 * This file is a part of LEMON, a generic C++ optimization library
5 * Copyright (C) 2003-2006
6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
7 * (Egervary Research Group on Combinatorial Optimization, EGRES).
9 * Permission to use, modify and distribute this software is granted
10 * provided that this copyright notice appears in all copies. For
11 * precise terms see the accompanying LICENSE file.
13 * This software is provided "AS IS" with no warranty of any kind,
14 * express or implied, and with no claim as to its suitability for any
20 ///\brief Implementation of the LEMON-CPLEX mip solver interface.
22 #include <lemon/mip_cplex.h>
26 MipCplex::MipCplex() {
27 //This is unnecessary: setting integrality constraints on
28 //variables will set this, too
30 ///\todo The constant CPXPROB_MIP is
31 ///called CPXPROB_MILP in later versions
33 CPXchgprobtype( env, lp, CPXPROB_MIP);
35 CPXchgprobtype( env, lp, CPXPROB_MILP);
40 void MipCplex::_colType(int i, MipCplex::ColTypes col_type){
42 // Note If a variable is to be changed to binary, a call to CPXchgbds
43 // should also be made to change the bounds to 0 and 1.
50 ctype[0]=CPX_INTEGER;//'I'
53 ctype[0]=CPX_CONTINUOUS ;//'C'
58 CPXchgctype (env, lp, 1, indices, ctype);
61 MipCplex::ColTypes MipCplex::_colType(int i){
64 status = CPXgetctype (env, lp, ctype, i, i);
77 LpCplex::SolveExitStatus MipCplex::_solve(){
79 status = CPXmipopt (env, lp);
88 LpCplex::SolutionStatus MipCplex::_getMipStatus(){
90 int stat = CPXgetstat(env, lp);
92 //Fortunately, MIP statuses did not change for cplex 8.0
97 //This also exists in later issues
98 // case CPXMIP_UNBOUNDED:
100 case CPXMIP_INFEASIBLE:
105 //Unboundedness not treated well: the following is from cplex 9.0 doc
106 // About Unboundedness
108 // The treatment of models that are unbounded involves a few
109 // subtleties. Specifically, a declaration of unboundedness means that
110 // ILOG CPLEX has determined that the model has an unbounded
111 // ray. Given any feasible solution x with objective z, a multiple of
112 // the unbounded ray can be added to x to give a feasible solution
113 // with objective z-1 (or z+1 for maximization models). Thus, if a
114 // feasible solution exists, then the optimal objective is
115 // unbounded. Note that ILOG CPLEX has not necessarily concluded that
116 // a feasible solution exists. Users can call the routine CPXsolninfo
117 // to determine whether ILOG CPLEX has also concluded that the model
118 // has a feasible solution.
122 MipCplex::Value MipCplex::_getPrimal(int i){
124 CPXgetmipx(env, lp, &x, i, i);
128 MipCplex::Value MipCplex::_getPrimalValue(){
130 status = CPXgetmipobjval(env, lp, &objval);
133 } //END OF NAMESPACE LEMON