Missing cplex files: sorry.
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/lemon/mip_cplex.cc Mon Sep 25 08:50:36 2006 +0000
1.3 @@ -0,0 +1,133 @@
1.4 +/* -*- C++ -*-
1.5 + *
1.6 + * This file is a part of LEMON, a generic C++ optimization library
1.7 + *
1.8 + * Copyright (C) 2003-2006
1.9 + * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
1.10 + * (Egervary Research Group on Combinatorial Optimization, EGRES).
1.11 + *
1.12 + * Permission to use, modify and distribute this software is granted
1.13 + * provided that this copyright notice appears in all copies. For
1.14 + * precise terms see the accompanying LICENSE file.
1.15 + *
1.16 + * This software is provided "AS IS" with no warranty of any kind,
1.17 + * express or implied, and with no claim as to its suitability for any
1.18 + * purpose.
1.19 + *
1.20 + */
1.21 +
1.22 +#ifndef LEMON_MIP_CPLEX_CC
1.23 +#define LEMON_MIP_CPLEX_CC
1.24 +
1.25 +///\file
1.26 +///\brief Implementation of the LEMON-CPLEX mip solver interface.
1.27 +
1.28 +#include <lemon/mip_cplex.h>
1.29 +
1.30 +namespace lemon {
1.31 +
1.32 + MipCplex::MipCplex() {
1.33 + //This is unnecessary: setting integrality constraints on
1.34 + //variables will set this, too
1.35 +
1.36 + ///\todo The constant CPXPROB_MIP is
1.37 + ///called CPXPROB_MILP in later versions
1.38 + CPXchgprobtype( env, lp, CPXPROB_MIP);
1.39 + }
1.40 +
1.41 + void MipCplex::_colType(int i, MipCplex::ColTypes col_type){
1.42 +
1.43 + // Note If a variable is to be changed to binary, a call to CPXchgbds
1.44 + // should also be made to change the bounds to 0 and 1.
1.45 +
1.46 + int indices[1];
1.47 + indices[0]=i;
1.48 + char ctype[1];
1.49 + switch (col_type){
1.50 + case LEMON_INTEGER:
1.51 + ctype[0]=CPX_INTEGER;//'I'
1.52 + break;
1.53 + case REAL:
1.54 + ctype[0]=CPX_CONTINUOUS ;//'C'
1.55 + break;
1.56 + default:;
1.57 + //FIXME problem
1.58 + }
1.59 + CPXchgctype (env, lp, 1, indices, ctype);
1.60 + }
1.61 +
1.62 + MipCplex::ColTypes MipCplex::_colType(int i){
1.63 +
1.64 + char ctype[1];
1.65 + status = CPXgetctype (env, lp, ctype, i, i);
1.66 + switch (ctype[0]){
1.67 +
1.68 + case CPX_INTEGER:
1.69 + return LEMON_INTEGER;
1.70 + case CPX_CONTINUOUS:
1.71 + return REAL;
1.72 + default:
1.73 + return REAL;//Error!
1.74 + }
1.75 +
1.76 + }
1.77 +
1.78 + LpCplex::SolveExitStatus MipCplex::_solve(){
1.79 +
1.80 + status = CPXmipopt (env, lp);
1.81 + if (status==0)
1.82 + return SOLVED;
1.83 + else
1.84 + return UNSOLVED;
1.85 +
1.86 + }
1.87 +
1.88 +
1.89 + LpCplex::SolutionStatus MipCplex::_getMipStatus(){
1.90 +
1.91 + int stat = CPXgetstat(env, lp);
1.92 +
1.93 + //Fortunately, MIP statuses did not change for cplex 8.0
1.94 + switch (stat)
1.95 + {
1.96 + case CPXMIP_OPTIMAL:
1.97 + return OPTIMAL;
1.98 + //This also exists in later issues
1.99 + // case CPXMIP_UNBOUNDED:
1.100 + //return INFINITE;
1.101 + case CPXMIP_INFEASIBLE:
1.102 + return INFEASIBLE;
1.103 + default:
1.104 + return UNDEFINED;
1.105 + }
1.106 + //Unboundedness not treated well: the following is from cplex 9.0 doc
1.107 + // About Unboundedness
1.108 +
1.109 + // The treatment of models that are unbounded involves a few
1.110 + // subtleties. Specifically, a declaration of unboundedness means that
1.111 + // ILOG CPLEX has determined that the model has an unbounded
1.112 + // ray. Given any feasible solution x with objective z, a multiple of
1.113 + // the unbounded ray can be added to x to give a feasible solution
1.114 + // with objective z-1 (or z+1 for maximization models). Thus, if a
1.115 + // feasible solution exists, then the optimal objective is
1.116 + // unbounded. Note that ILOG CPLEX has not necessarily concluded that
1.117 + // a feasible solution exists. Users can call the routine CPXsolninfo
1.118 + // to determine whether ILOG CPLEX has also concluded that the model
1.119 + // has a feasible solution.
1.120 +
1.121 + }
1.122 +
1.123 + MipCplex::Value MipCplex::_getPrimal(int i){
1.124 + Value x;
1.125 + CPXgetmipx(env, lp, &x, i, i);
1.126 + return x;
1.127 + }
1.128 +
1.129 + MipCplex::Value MipCplex::_getPrimalValue(){
1.130 + Value objval;
1.131 + status = CPXgetmipobjval(env, lp, &objval);
1.132 + return objval;
1.133 + }
1.134 +} //END OF NAMESPACE LEMON
1.135 +
1.136 +#endif //END OF MIP_CPLEX_CC
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
2.2 +++ b/lemon/mip_cplex.cc~ Mon Sep 25 08:50:36 2006 +0000
2.3 @@ -0,0 +1,135 @@
2.4 +/* -*- C++ -*-
2.5 + *
2.6 + * This file is a part of LEMON, a generic C++ optimization library
2.7 + *
2.8 + * Copyright (C) 2003-2006
2.9 + * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
2.10 + * (Egervary Research Group on Combinatorial Optimization, EGRES).
2.11 + *
2.12 + * Permission to use, modify and distribute this software is granted
2.13 + * provided that this copyright notice appears in all copies. For
2.14 + * precise terms see the accompanying LICENSE file.
2.15 + *
2.16 + * This software is provided "AS IS" with no warranty of any kind,
2.17 + * express or implied, and with no claim as to its suitability for any
2.18 + * purpose.
2.19 + *
2.20 + */
2.21 +
2.22 +#ifndef LEMON_MIP_CPLEX_CC
2.23 +#define LEMON_MIP_CPLEX_CC
2.24 +
2.25 +///\file
2.26 +///\brief Implementation of the LEMON-CPLEX mip solver interface.
2.27 +
2.28 +#include <lemon/mip_cplex.h>
2.29 +
2.30 +namespace lemon {
2.31 +
2.32 + MipCplex::MipCplex() {
2.33 + //This is unnecessary: setting integrality constraints on
2.34 + //variables will set this, too
2.35 +
2.36 + ///\todo The constant CPXPROB_MIP is
2.37 + ///called CPXPROB_MILP in later versions
2.38 + CPXchgprobtype( env, lp, CPXPROB_MIP);
2.39 + }
2.40 +
2.41 + void MipCplex::_colType(int i, MipCplex::ColTypes col_type){
2.42 +
2.43 + // Note If a variable is to be changed to binary, a call to CPXchgbds
2.44 + // should also be made to change the bounds to 0 and 1.
2.45 +
2.46 + int indices[1];
2.47 + indices[0]=i;
2.48 + char ctype[1];
2.49 + switch (col_type){
2.50 + case INTEGER:
2.51 + ctype[0]=CPX_INTEGER;//'I'
2.52 + break;
2.53 + case REAL:
2.54 + ctype[0]=CPX_CONTINUOUS ;//'C'
2.55 + break;
2.56 + default:;
2.57 + //FIXME problem
2.58 + }
2.59 + CPXchgctype (env, lp, 1, indices, ctype);
2.60 + }
2.61 +
2.62 + MipCplex::ColTypes MipCplex::_colType(int i){
2.63 +
2.64 + char ctype[1];
2.65 + status = CPXgetctype (env, lp, ctype, i, i);
2.66 + std::cout<<"Kukucska: "<<INTEGER<<std::endl;
2.67 + return REAL;
2.68 +// switch (ctype[0]){
2.69 +
2.70 +// case CPX_INTEGER:
2.71 +// return INTEGER;
2.72 +// case CPX_CONTINUOUS:
2.73 +// return REAL;
2.74 +// default:
2.75 +// return REAL;//Error!
2.76 +// }
2.77 +
2.78 + }
2.79 +
2.80 + LpCplex::SolveExitStatus MipCplex::_solve(){
2.81 +
2.82 + status = CPXmipopt (env, lp);
2.83 + if (status==0)
2.84 + return SOLVED;
2.85 + else
2.86 + return UNSOLVED;
2.87 +
2.88 + }
2.89 +
2.90 +
2.91 + LpCplex::SolutionStatus MipCplex::_getMipStatus(){
2.92 +
2.93 + int stat = CPXgetstat(env, lp);
2.94 +
2.95 + //Fortunately, MIP statuses did not change for cplex 8.0
2.96 + switch (stat)
2.97 + {
2.98 + case CPXMIP_OPTIMAL:
2.99 + return OPTIMAL;
2.100 + //This also exists in later issues
2.101 + // case CPXMIP_UNBOUNDED:
2.102 + //return INFINITE;
2.103 + case CPXMIP_INFEASIBLE:
2.104 + return INFEASIBLE;
2.105 + default:
2.106 + return UNDEFINED;
2.107 + }
2.108 + //Unboundedness not treated well: the following is from cplex 9.0 doc
2.109 + // About Unboundedness
2.110 +
2.111 + // The treatment of models that are unbounded involves a few
2.112 + // subtleties. Specifically, a declaration of unboundedness means that
2.113 + // ILOG CPLEX has determined that the model has an unbounded
2.114 + // ray. Given any feasible solution x with objective z, a multiple of
2.115 + // the unbounded ray can be added to x to give a feasible solution
2.116 + // with objective z-1 (or z+1 for maximization models). Thus, if a
2.117 + // feasible solution exists, then the optimal objective is
2.118 + // unbounded. Note that ILOG CPLEX has not necessarily concluded that
2.119 + // a feasible solution exists. Users can call the routine CPXsolninfo
2.120 + // to determine whether ILOG CPLEX has also concluded that the model
2.121 + // has a feasible solution.
2.122 +
2.123 + }
2.124 +
2.125 + MipCplex::Value MipCplex::_getPrimal(int i){
2.126 + Value x;
2.127 + CPXgetmipx(env, lp, &x, i, i);
2.128 + return x;
2.129 + }
2.130 +
2.131 + MipCplex::Value MipCplex::_getPrimalValue(){
2.132 + Value objval;
2.133 + status = CPXgetmipobjval(env, lp, &objval);
2.134 + return objval;
2.135 + }
2.136 +} //END OF NAMESPACE LEMON
2.137 +
2.138 +#endif //END OF MIP_CPLEX_CC
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
3.2 +++ b/lemon/mip_cplex.h Mon Sep 25 08:50:36 2006 +0000
3.3 @@ -0,0 +1,61 @@
3.4 +/* -*- C++ -*-
3.5 + *
3.6 + * This file is a part of LEMON, a generic C++ optimization library
3.7 + *
3.8 + * Copyright (C) 2003-2006
3.9 + * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
3.10 + * (Egervary Research Group on Combinatorial Optimization, EGRES).
3.11 + *
3.12 + * Permission to use, modify and distribute this software is granted
3.13 + * provided that this copyright notice appears in all copies. For
3.14 + * precise terms see the accompanying LICENSE file.
3.15 + *
3.16 + * This software is provided "AS IS" with no warranty of any kind,
3.17 + * express or implied, and with no claim as to its suitability for any
3.18 + * purpose.
3.19 + *
3.20 + */
3.21 +
3.22 +#ifndef LEMON_MIP_CPLEX_H
3.23 +#define LEMON_MIP_CPLEX_H
3.24 +
3.25 +///\file
3.26 +///\brief Header of the LEMON-CPLEX mip solver interface.
3.27 +///\ingroup gen_opt_group
3.28 +
3.29 +
3.30 +#include <lemon/lp_cplex.h>
3.31 +
3.32 +namespace lemon {
3.33 +
3.34 + /// \brief Interface for the CPLEX MIP solver
3.35 + ///
3.36 + /// This class implements an interface for the CPLEX MIP solver.
3.37 + ///\ingroup gen_opt_group
3.38 + class MipCplex : public MipSolverBase, public LpCplex{
3.39 +
3.40 + public:
3.41 +
3.42 + typedef MipSolverBase ParentMip;
3.43 + typedef LpCplex ParentLp;
3.44 +
3.45 + MipCplex();
3.46 + //~MipCplex();
3.47 +
3.48 +
3.49 +
3.50 +
3.51 + protected:
3.52 +
3.53 + virtual ColTypes _colType(int col);
3.54 + virtual void _colType(int col, ColTypes col_type);
3.55 +
3.56 + virtual LpCplex::SolveExitStatus _solve();
3.57 + virtual LpCplex::SolutionStatus _getMipStatus();
3.58 + virtual ParentLp::Value _getPrimal(int i);
3.59 + virtual ParentLp::Value _getPrimalValue();
3.60 + };
3.61 +
3.62 +} //END OF NAMESPACE LEMON
3.63 +
3.64 +#endif // END OF LEMON_MIP_CPLEX_H
4.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
4.2 +++ b/lemon/mip_cplex.h~ Mon Sep 25 08:50:36 2006 +0000
4.3 @@ -0,0 +1,59 @@
4.4 +/* -*- C++ -*-
4.5 + *
4.6 + * This file is a part of LEMON, a generic C++ optimization library
4.7 + *
4.8 + * Copyright (C) 2003-2006
4.9 + * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
4.10 + * (Egervary Research Group on Combinatorial Optimization, EGRES).
4.11 + *
4.12 + * Permission to use, modify and distribute this software is granted
4.13 + * provided that this copyright notice appears in all copies. For
4.14 + * precise terms see the accompanying LICENSE file.
4.15 + *
4.16 + * This software is provided "AS IS" with no warranty of any kind,
4.17 + * express or implied, and with no claim as to its suitability for any
4.18 + * purpose.
4.19 + *
4.20 + */
4.21 +
4.22 +#ifndef LEMON_MIP_CPLEX_H
4.23 +#define LEMON_MIP_CPLEX_H
4.24 +
4.25 +///\file
4.26 +///\brief Header of the LEMON-CPLEX mip solver interface.
4.27 +///\ingroup gen_opt_group
4.28 +
4.29 +
4.30 +#include <lemon/lp_cplex.h>
4.31 +
4.32 +namespace lemon {
4.33 + /// \brief Interface for the CPLEX MIP solver
4.34 + ///
4.35 + /// This class implements an interface for the CPLEX MIP solver.
4.36 + ///\ingroup gen_opt_group
4.37 + class MipCplex : public MipSolverBase, public LpCplex{
4.38 +
4.39 + public:
4.40 +
4.41 + typedef MipSolverBase ParentMip;
4.42 + typedef LpCplex ParentLp;
4.43 +
4.44 + MipCplex();
4.45 + //~MipCplex();
4.46 +
4.47 +
4.48 +
4.49 + protected:
4.50 +
4.51 + virtual ColTypes _colType(int col);
4.52 + virtual void _colType(int col, ColTypes col_type);
4.53 +
4.54 + virtual LpCplex::SolveExitStatus _solve();
4.55 + virtual LpCplex::SolutionStatus _getMipStatus();
4.56 + virtual ParentLp::Value _getPrimal(int i);
4.57 + virtual ParentLp::Value _getPrimalValue();
4.58 + };
4.59 +
4.60 +} //END OF NAMESPACE LEMON
4.61 +
4.62 +#endif // END OF LEMON_MIP_CPLEX_H