src/work/athos/lp/lp_cplex.cc
changeset 1365 c280de819a73
parent 1364 ee5959aa4410
child 1366 d00b85f8be45
     1.1 --- a/src/work/athos/lp/lp_cplex.cc	Sun Apr 17 18:57:22 2005 +0000
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,201 +0,0 @@
     1.4 -/* -*- C++ -*-
     1.5 - * src/lemon/lp_cplex.cc
     1.6 - * - Part of LEMON, a generic C++ optimization library
     1.7 - *
     1.8 - * Copyright (C) 2005 Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
     1.9 - * (Egervary Research Group on Combinatorial Optimization, EGRES).
    1.10 - *
    1.11 - * Permission to use, modify and distribute this software is granted
    1.12 - * provided that this copyright notice appears in all copies. For
    1.13 - * precise terms see the accompanying LICENSE file.
    1.14 - *
    1.15 - * This software is provided "AS IS" with no warranty of any kind,
    1.16 - * express or implied, and with no claim as to its suitability for any
    1.17 - * purpose.
    1.18 - *
    1.19 - */
    1.20 -
    1.21 -#include"lp_cplex.h"
    1.22 -
    1.23 -///\file
    1.24 -///\brief Implementation of the LEMON-CPLEX lp solver interface.
    1.25 -namespace lemon {
    1.26 -  
    1.27 -  int LpCplex::_addCol()
    1.28 -  {
    1.29 -    int i = CPXgetnumcols (env, lp);
    1.30 -    Value lb[1],ub[1];
    1.31 -    lb[0]=-INF;//-CPX_INFBOUND;
    1.32 -    ub[0]=INF;//CPX_INFBOUND;
    1.33 -    status = CPXnewcols (env, lp, 1, NULL, lb, ub, NULL, NULL);
    1.34 -    return i;
    1.35 -  }
    1.36 -  
    1.37 -  int LpCplex::_addRow() 
    1.38 -  {
    1.39 -    //We want a ranged row
    1.40 -    char sense[1];
    1.41 -    sense[0]='R';
    1.42 -
    1.43 -    int i = CPXgetnumrows (env, lp);
    1.44 -    status = CPXnewrows (env, lp, 1, NULL, sense, NULL, NULL);
    1.45 -    return i;
    1.46 -  }
    1.47 -  
    1.48 -  ///\warning Data at index 0 is ignored iin the arrays.
    1.49 -  void LpCplex::_setRowCoeffs(int i, 
    1.50 -			      int length,
    1.51 -			      int  const * indices, 
    1.52 -			      Value  const * values )
    1.53 -  {
    1.54 -    int rowlist[length+1];
    1.55 -    int* p=rowlist;
    1.56 -    for (int k=1;k<=length;++k){
    1.57 -      rowlist[k]=i;
    1.58 -    }
    1.59 -    status = CPXchgcoeflist(env, lp, 
    1.60 -			    length, 
    1.61 -			    p++, 
    1.62 -			    const_cast<int * >(indices++), 
    1.63 -			    const_cast<Value * >(values++));
    1.64 -  }
    1.65 -  
    1.66 -  void LpCplex::_setColCoeffs(int i, 
    1.67 -			      int length,
    1.68 -			      int  const * indices, 
    1.69 -			      Value  const * values)
    1.70 -  {
    1.71 -    int collist[length+1];
    1.72 -    int* p=collist;
    1.73 -    for (int k=1;k<=length;++k){
    1.74 -      collist[k]=i;
    1.75 -    }
    1.76 -    status = CPXchgcoeflist(env, lp, 
    1.77 -			    length, 
    1.78 -			    const_cast<int * >(indices++), 
    1.79 -			    p++, 
    1.80 -			    const_cast<Value * >(values++));
    1.81 -  }
    1.82 -  
    1.83 -  void LpCplex::_setColLowerBound(int i, Value value)
    1.84 -  {
    1.85 -    int indices[1];
    1.86 -    indices[0]=i;
    1.87 -    char lu[1];
    1.88 -    lu[0]='L';
    1.89 -    Value bd[1];
    1.90 -    bd[0]=value;
    1.91 -    status = CPXchgbds (env, lp, 1, indices, lu, bd);
    1.92 - 
    1.93 -  }
    1.94 -  
    1.95 -  void LpCplex::_setColUpperBound(int i, Value value)
    1.96 -  {
    1.97 -    int indices[1];
    1.98 -    indices[0]=i;
    1.99 -    char lu[1];
   1.100 -    lu[0]='U';
   1.101 -    Value bd[1];
   1.102 -    bd[0]=value;
   1.103 -    status = CPXchgbds (env, lp, 1, indices, lu, bd);
   1.104 -  }
   1.105 -  
   1.106 -  void LpCplex::_setRowLowerBound(int i, Value value)
   1.107 -  {
   1.108 -    status = CPXchgcoef (env, lp, i, -1, value);
   1.109 -
   1.110 -  }
   1.111 -  
   1.112 -  void LpCplex::_setRowUpperBound(int i, Value value)
   1.113 -  {
   1.114 -    //TODO Ezt kell meg megirni
   1.115 -    //type of the problem
   1.116 -    char sense[1];
   1.117 -    status = CPXgetsense (env, lp, sense, i, i);
   1.118 -    Value rhs[1];
   1.119 -    status = CPXgetrhs (env, lp, rhs, i, i);
   1.120 -
   1.121 -    switch (sense[0]) {
   1.122 -    case 'L'://<= constraint
   1.123 -      break;
   1.124 -    case 'E'://= constraint
   1.125 -      break;
   1.126 -    case 'G'://>= constraint
   1.127 -      break;
   1.128 -    case 'R'://ranged constraint
   1.129 -      break;
   1.130 -    default: ;
   1.131 -      //FIXME error
   1.132 -    }
   1.133 -
   1.134 -    status = CPXchgcoef (env, lp, i, -2, value_rng);
   1.135 -  }
   1.136 -  
   1.137 -  void LpCplex::_setObjCoeff(int i, Value obj_coef)
   1.138 -  {
   1.139 -    status = CPXchgcoef (env, lp, -1, i, obj_coef);
   1.140 -   }
   1.141 -
   1.142 -  LpCplex::SolveExitStatus LpCplex::_solve()
   1.143 -  {
   1.144 -    return SOLVED;
   1.145 -//     int i=  lpx_simplex(lp);
   1.146 -//     switch (i) {
   1.147 -//     case LPX_E_OK: 
   1.148 -//       return SOLVED;
   1.149 -//       break;
   1.150 -//     default:
   1.151 -//       return UNSOLVED;
   1.152 -//     }
   1.153 -  }
   1.154 -
   1.155 -  LpCplex::Value LpCplex::_getPrimal(int i)
   1.156 -  {
   1.157 -    return 0;
   1.158 -  }
   1.159 -  
   1.160 -  LpCplex::Value LpCplex::_getPrimalValue()
   1.161 -  {
   1.162 -    return 0;
   1.163 -  }
   1.164 -  
   1.165 - 
   1.166 -  LpCplex::SolutionStatus LpCplex::_getPrimalStatus()
   1.167 -  {
   1.168 -    return OPTIMAL;
   1.169 -//     int stat=  lpx_get_status(lp);
   1.170 -//     switch (stat) {
   1.171 -//     case LPX_UNDEF://Undefined (no solve has been run yet)
   1.172 -//       return UNDEFINED;
   1.173 -//       break;
   1.174 -//     case LPX_NOFEAS://There is no feasible solution (primal, I guess)
   1.175 -//     case LPX_INFEAS://Infeasible 
   1.176 -//       return INFEASIBLE;
   1.177 -//       break;
   1.178 -//     case LPX_UNBND://Unbounded
   1.179 -//       return INFINITE;
   1.180 -//       break;
   1.181 -//     case LPX_FEAS://Feasible
   1.182 -//       return FEASIBLE;
   1.183 -//       break;
   1.184 -//     case LPX_OPT://Feasible
   1.185 -//       return OPTIMAL;
   1.186 -//       break;
   1.187 -//     default:
   1.188 -//       return UNDEFINED; //to avoid gcc warning
   1.189 -//       //FIXME error
   1.190 -//     }
   1.191 -  }
   1.192 -
   1.193 -
   1.194 -  void LpCplex::_setMax()
   1.195 -  {
   1.196 -    CPXchgobjsen (env, lp, CPX_MAX);
   1.197 -   }
   1.198 -  void LpCplex::_setMin()
   1.199 -  {
   1.200 -    CPXchgobjsen (env, lp, CPX_MIN);
   1.201 -   }
   1.202 -  
   1.203 -} //namespace lemon
   1.204 -