Changeset 3874

Show
Ignore:
Timestamp:
07/08/05 12:48:51 (4 years ago)
Author:
josyoun
Message:

( Links to Acro-related mail archives at http://software.sandia.gov/Acro/ )

( Links to Acro-related mail archives at http://software.sandia.gov/Acro/ )

Initial version of the GLPK derived class. This will not work with the current version of COIN since the function getModelPtr is public, noncost and getMutablePtr is private.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • pico/trunk/src/lp/pico/PicoGlpkLP.h

    r3864 r3874  
    2020#include <pico/PicoLPSubclass.h> 
    2121 
    22 namespace pico { 
    23  
    24  
    25 template <> 
    26 void PicoLPSubclass<OsiGlpkSolverInterface,PicoLPCutMngmnt>::initialize() 
     22namespace pico 
    2723{ 
    28 } 
     24 
     25 
     26#if 0 
     27    template <> 
     28        void PicoLPSubclass < OsiGlpkSolverInterface, 
     29        PicoLPCutMngmnt >::initialize () 
     30    { 
     31    } 
     32#endif 
    2933 
    3034// 
    3135// 
    32 template<> 
    33 bool PicoLPSubclass<OsiGlpkSolverInterface,PicoLPCutMngmnt>::isTimeLimitReached() const 
    34 { 
     36    template <> 
     37        bool PicoLPSubclass < OsiGlpkSolverInterface, 
     38        PicoLPCutMngmnt >::isTimeLimitReached () const 
     39    { 
     40        LPX *const model = getModelPtr (); 
     41        double tmlim = lpx_get_real_parm (model, LPX_K_TMLIM); 
     42 
     43        if (fabs (tmlim) < 1e-8) 
     44              return true; 
     45        else 
     46              return false; 
     47 
     48    } 
     49 
     50 
     51    template <> 
     52        bool PicoLPSubclass < OsiGlpkSolverInterface, 
     53        PicoLPCutMngmnt >::isProvenPrimalUnbounded () const 
     54    { 
     55        LPX *model = getModelPtr (); 
     56        int prim = lpx_get_prim_stat (model); 
     57        int dual = lpx_get_dual_stat (model); 
     58 
     59        if (prim == LPX_P_FEAS && dual == LPX_D_NOFEAS) 
     60            return true; 
     61        else 
     62              return false; 
     63    } 
     64 
     65 
     66    template <> 
     67        bool PicoLPSubclass < OsiGlpkSolverInterface, 
     68        PicoLPCutMngmnt >::isProvenDualUnbounded () const 
     69    { 
     70        LPX *model = getModelPtr (); 
     71        int prim = lpx_get_prim_stat (model); 
     72        int dual = lpx_get_dual_stat (model); 
     73 
     74        if (prim == LPX_P_NOFEAS && dual == LPX_D_FEAS) 
     75            return true; 
     76        else 
     77              return false; 
     78    } 
     79 
     80 
    3581#if 0 
    36 int stat = CPXgetstat( const_cast<PicoLPSubclass<OsiGlpkSolverInterface,PicoLPCutMngmnt>*>(this)->OsiGlpkSolverInterface::getEnvironmentPtr(), getConstLpPtr() ); 
    37 #if (CPX_VERSION >= 800) 
    38 return stat == CPXMIP_TIME_LIM_INFEAS || stat == CPXMIP_TIME_LIM_FEAS; 
    39 #else 
    40 return stat == CPX_TIME_LIM_INFEAS || stat == CPX_TIME_LIM_FEAS; 
     82    template <> 
     83        double PicoLPSubclass < OsiGlpkSolverInterface, 
     84        PicoLPCutMngmnt >::getColLower (int whichVariable) const 
     85    { 
     86        return getColLower ()[whichVariable]; 
     87    } 
     88 
     89 
     90    template <> 
     91        double PicoLPSubclass < OsiGlpkSolverInterface, 
     92        PicoLPCutMngmnt >::getColUpper (int whichVariable) const 
     93    { 
     94        return getColUpper ()[whichVariable]; 
     95    } 
     96 
     97 
     98    template <> 
     99        double PicoLPSubclass < OsiGlpkSolverInterface, 
     100        PicoLPCutMngmnt >::getRowLower (int whichVariable) const 
     101    { 
     102        return getRowLower ()[whichVariable]; 
     103    } 
     104 
     105 
     106    template <> 
     107        double PicoLPSubclass < OsiGlpkSolverInterface, 
     108        PicoLPCutMngmnt >::getRowUpper (int whichVariable) const 
     109    { 
     110        return getRowUpper ()[whichVariable]; 
     111    } 
     112 
     113 
     114    template <> 
     115        double PicoLPSubclass < OsiGlpkSolverInterface, 
     116        PicoLPCutMngmnt >::getRightHandSide (int whichConstraint) const 
     117    { 
     118        return getRightHandSide ()[whichConstraint]; 
     119    } 
     120 
     121 
     122    template <> 
     123        PicoLPInterface::constraintSense PicoLPSubclass < 
     124        OsiGlpkSolverInterface, 
     125        PicoLPCutMngmnt >::getRowSense (int whichConstraint) const 
     126    { 
     127        return getRowSense ()[whichConstraint]; 
     128    } 
     129 
     130 
     131    template <> 
     132        double PicoLPSubclass < OsiGlpkSolverInterface, 
     133        PicoLPCutMngmnt >::getObjCoefficient (int whichVariable) const 
     134    { 
     135        return getObjCoefficients ()[whichVariable]; 
     136    } 
     137 
     138 
     139    template <> 
     140        double PicoLPSubclass < OsiGlpkSolverInterface, 
     141        PicoLPCutMngmnt >::getColSolution (const int whichCol) const 
     142    { 
     143        return getColSolution ()[whichCol]; 
     144    } 
     145 
     146 
     147    template <> 
     148        double PicoLPSubclass < OsiGlpkSolverInterface, 
     149        PicoLPCutMngmnt >::getRowPrice (const int whichRow) const 
     150    { 
     151        return getRowPrice ()[whichRow]; 
     152    } 
     153 
     154 
     155    template <> 
     156        double PicoLPSubclass < OsiGlpkSolverInterface, 
     157        PicoLPCutMngmnt >::getReducedCost (const int whichCol) const 
     158    { 
     159        return getReducedCost ()[whichCol]; 
     160    } 
    41161#endif 
     162 
     163 
     164    template <> 
     165        void PicoLPSubclass < OsiGlpkSolverInterface, 
     166        PicoLPCutMngmnt >::getBasis (BasisArray & basisBuffer) const 
     167    { 
     168        LPX *model = getModelPtr (); 
     169 
     170        /* Get the basis status for all the structural variables */ 
     171        for (int i = 0; i < getNumCols (); i++) 
     172            switch (lpx_get_col_stat (model, i + 1)) 
     173              { 
     174              case LPX_BS: 
     175                  basisBuffer.put (i, basic); 
     176                  break; 
     177                  case LPX_NL:basisBuffer.put (i, atLower); 
     178                  break; 
     179                  case LPX_NU:basisBuffer.put (i, atUpper); 
     180                  break; 
     181                  default:basisBuffer.put (i, other); 
     182                  break; 
     183              } 
     184 
     185        /* Get the basis status for all the auxillary variables */ 
     186        for (int j = 0; j < getNumRows (); j++) 
     187            switch (lpx_get_row_stat (model, j + 1)) 
     188              { 
     189              case LPX_BS: 
     190                  basisBuffer.put (getNumCols () + j, basic); 
     191                  break; 
     192              case LPX_NL: 
     193                  basisBuffer.put (getNumCols () + j, atLower); 
     194                  break; 
     195              case LPX_NU: 
     196                  basisBuffer.put (getNumCols () + j, atUpper); 
     197                  break; 
     198              default: 
     199                  basisBuffer.put (getNumCols () + j, other); 
     200                  break; 
     201              } 
     202    } 
     203 
     204    template <> 
     205        basisState PicoLPSubclass < OsiGlpkSolverInterface, 
     206        PicoLPCutMngmnt >::getBasis (int whichVariable) const 
     207    { 
     208        LPX *model = getModelPtr (); 
     209        int var; 
     210 
     211        // If we need an structural variable */ 
     212        if (whichVariable < getNumCols ()) 
     213              var = lpx_get_col_stat (model, whichVariable + 1); 
     214        else 
     215              var = 
     216                lpx_get_row_stat (model, whichVariable - getNumCols () + 1); 
     217        switch (var) 
     218          { 
     219          case LPX_BS: 
     220              return basic; 
     221              case LPX_NL:return atLower; 
     222              case LPX_NU:return atUpper; 
     223              default:return other; 
     224          } 
     225    } 
     226 
     227 
     228    template <> 
     229        void PicoLPSubclass < OsiGlpkSolverInterface, 
     230        PicoLPCutMngmnt >::setBasis (BasisArray & basisBuffer) 
     231    { 
     232        LPX *model = getModelPtr (); 
     233 
     234        /* Set the basis status of all the structural variables */ 
     235        for (int i = 0; i < getNumCols (); i++) 
     236            switch (basisBuffer (i)) 
     237              { 
     238              case basic: 
     239                  lpx_set_col_stat (model, i + 1, LPX_BS); 
     240                  break; 
     241              case atLower: 
     242                  lpx_set_col_stat (model, i + 1, LPX_NL); 
     243                  break; 
     244              case atUpper: 
     245                  lpx_set_col_stat (model, i + 1, LPX_NU); 
     246                  break; 
     247              } 
     248 
     249        /* Set the basis status for all the auxillary variables */ 
     250        for (int j = 0; j < getNumRows (); j++) 
     251            switch (basisBuffer (getNumCols () + j)) 
     252              { 
     253              case basic: 
     254                  lpx_set_col_stat (model, j + 1, LPX_BS); 
     255                  break; 
     256              case atLower: 
     257                  lpx_set_col_stat (model, j + 1, LPX_NL); 
     258                  break; 
     259              case atUpper: 
     260                  lpx_set_col_stat (model, j + 1, LPX_NU); 
     261                  break; 
     262              } 
     263    } 
     264 
     265 
     266    template <> 
     267        priceRule PicoLPSubclass < OsiGlpkSolverInterface, 
     268        PicoLPCutMngmnt >::getPricingRule ()const 
     269    { 
     270        LPX *model = getModelPtr (); 
     271 
     272        switch (lpx_get_int_parm (model, LPX_K_PRICE)) 
     273          { 
     274              /* Textbook pricing */ 
     275          case 0: 
     276              return defaultPricing; 
     277              /* Steepest edge pricing */ 
     278              case 1:return steepestEdgePricing; 
     279          } 
     280    } 
     281 
     282 
     283    template <> 
     284        void PicoLPSubclass < OsiGlpkSolverInterface, 
     285        PicoLPCutMngmnt >::setPricingRule (priceRule rule) 
     286    { 
     287        LPX *model = getModelPtr (); 
     288        switch (rule) 
     289          { 
     290              /* Textbook pricing */ 
     291          case defaultPricing: 
     292              lpx_set_int_parm (model, LPX_K_PRICE, 0); 
     293              break; 
     294              /* Steepest edge pricing */ 
     295          case steepestEdgePricing: 
     296              lpx_set_int_parm (model, LPX_K_PRICE, 1); 
     297              break; 
     298          } 
     299    } 
     300 
     301 
     302    template <> 
     303        double PicoLPSubclass < OsiGlpkSolverInterface, 
     304        PicoLPCutMngmnt >::getTimeLimit () const 
     305    { 
     306        LPX *model = getModelPtr (); 
     307          return lpx_get_real_parm (model, LPX_K_TMLIM); 
     308    } 
     309 
     310 
     311    template <> 
     312        void PicoLPSubclass < OsiGlpkSolverInterface, 
     313        PicoLPCutMngmnt >::setTimeLimit (double time) 
     314    { 
     315        LPX *model = getModelPtr (); 
     316        lpx_set_real_parm (model, LPX_K_TMLIM, time); 
     317    } 
     318 
     319 
     320    template <> 
     321        clockType PicoLPSubclass < OsiGlpkSolverInterface, 
     322        PicoLPCutMngmnt >::getClockType ()const 
     323    { 
     324        return wallTime; 
     325    } 
     326 
     327 
     328    template <> 
     329        void PicoLPSubclass < OsiGlpkSolverInterface, 
     330        PicoLPCutMngmnt >::setClockType (clockType cType) 
     331    { 
     332        /* GLPK only allows a time limit to be set using the wall clock */ 
     333    } 
     334 
     335 
     336 
     337    template <> 
     338        PicoLPSubclass < OsiGlpkSolverInterface, 
     339        PicoLPCutMngmnt >::PicoLPSubclass () 
     340    { 
     341    } 
     342 
     343    template <> 
     344        void PicoLPSubclass < OsiGlpkSolverInterface, 
     345        PicoLPCutMngmnt >::write (char *filename, ilp_format format) 
     346    { 
     347        LPX *model = getModelPtr (); 
     348 
     349        switch (format) 
     350          { 
     351          case mps_format: 
     352          case glpk_mps_format: 
     353              lpx_write_mps (model, filename); 
     354              break; 
     355          case cplex_mps_format: 
     356              lpx_write_cpxlp (model, filename); 
     357              break; 
     358          } 
     359 
     360    } 
     361 
     362    template <> 
     363        void PicoLPSubclass < OsiGlpkSolverInterface, 
     364        PicoLPCutMngmnt >::printBrokenInfo () 
     365    { 
     366    } 
     367 
     368    template <> 
     369        void PicoLPSubclass < OsiGlpkSolverInterface, 
     370        PicoLPCutMngmnt >::setMatrixCoeff (int row, int col, double newValue) 
     371    { 
     372    } 
     373 
     374    typedef PicoLPSubclass < OsiGlpkSolverInterface, 
     375        PicoLPCutMngmnt > PicoGlpkLP; 
     376}                               // namespace pico 
     377 
    42378#endif 
    43 return false; 
    44 } 
    45  
    46  
    47 template<> 
    48 bool PicoLPSubclass<OsiGlpkSolverInterface,PicoLPCutMngmnt>::isProvenPrimalUnbounded() const 
    49 { 
    50 #if 0 
    51 int stat = CPXgetstat( const_cast<PicoLPSubclass<OsiGlpkSolverInterface,PicoLPCutMngmnt>*>(this)->OsiGlpkSolverInterface::getEnvironmentPtr(), getConstLpPtr() ); 
    52 #if (CPX_VERSION >= 800) 
    53 return stat == CPX_STAT_UNBOUNDED; 
    54 #else 
    55 int method = CPXgetmethod(const_cast<PicoLPSubclass<OsiGlpkSolverInterface,PicoLPCutMngmnt>*>(this)->OsiGlpkSolverInterface::getEnvironmentPtr(), getConstLpPtr() ); 
    56 // stat for version < 8 is relative to solver. If running dual simplex and stat is 
    57 // infeasible, we do not necessarily know the primal is unbounded (could be infeasible). 
    58  return ((method == CPX_ALG_PRIMAL && stat == CPX_UNBOUNDED)); 
     379 
    59380#endif 
    60 #endif 
    61 return false; 
    62 } 
    63  
    64  
    65 template<> 
    66 bool PicoLPSubclass<OsiGlpkSolverInterface,PicoLPCutMngmnt>::isProvenDualUnbounded() const 
    67 { 
    68 #if 0 
    69   // Version 8.0 and up returns status wrt the primal only.  There is no primal status that 
    70   // proves dual unboundedness.  CAP. 
    71 #if (CPX_VERSION < 800) 
    72 int stat =  
    73 #endif 
    74 CPXgetstat( const_cast<PicoLPSubclass<OsiGlpkSolverInterface,PicoLPCutMngmnt>*>(this)->OsiGlpkSolverInterface::getEnvironmentPtr(), getConstLpPtr() ); 
    75 #if (CPX_VERSION >= 800) 
    76 return false; 
    77 #else 
    78 int method = CPXgetmethod(const_cast<PicoLPSubclass<OsiGlpkSolverInterface,PicoLPCutMngmnt>*>(this)->OsiGlpkSolverInterface::getEnvironmentPtr(), getConstLpPtr() ); 
    79 // stat for version < 8 is relative to solver. If running primal simplex and stat is 
    80 // infeasible, we do not necessarily know the dual is unbounded (could be infeasible). 
    81  return ((method == CPX_ALG_DUAL && stat == CPX_UNBOUNDED)); 
    82 #endif 
    83 #endif 
    84 return false; 
    85 } 
    86  
    87  
    88 template<> 
    89 double PicoLPSubclass<OsiGlpkSolverInterface,PicoLPCutMngmnt>::getColLower(int whichVariable) const 
    90 { 
    91 #if 0 
    92 double ans; 
    93 CPXgetlb(const_cast<PicoLPSubclass<OsiGlpkSolverInterface,PicoLPCutMngmnt>*>(this)->OsiGlpkSolverInterface::getEnvironmentPtr(),getConstLpPtr(),&ans,whichVariable,whichVariable); 
    94 return ans; 
    95 #endif 
    96 return -999.0; 
    97 } 
    98  
    99  
    100 template<> 
    101 double PicoLPSubclass<OsiGlpkSolverInterface,PicoLPCutMngmnt>::getColUpper(int whichVariable) const 
    102 { 
    103 #if 0 
    104 double ans; 
    105 CPXgetub(const_cast<PicoLPSubclass<OsiGlpkSolverInterface,PicoLPCutMngmnt>*>(this)->OsiGlpkSolverInterface::getEnvironmentPtr(),getConstLpPtr(),&ans,whichVariable,whichVariable); 
    106 return ans; 
    107 #endif 
    108 return -999.0; 
    109 } 
    110  
    111  
    112 template<> 
    113 double PicoLPSubclass<OsiGlpkSolverInterface,PicoLPCutMngmnt>::getRowLower(int whichVariable) const 
    114 { 
    115 #if 0 
    116 char sense; 
    117 CPXgetsense(const_cast<PicoLPSubclass<OsiGlpkSolverInterface,PicoLPCutMngmnt>*>(this)->OsiGlpkSolverInterface::getEnvironmentPtr(),getConstLpPtr(),&sense,whichVariable,whichVariable); 
    118 double rhs; 
    119 CPXgetrhs(const_cast<PicoLPSubclass<OsiGlpkSolverInterface,PicoLPCutMngmnt>*>(this)->OsiGlpkSolverInterface::getEnvironmentPtr(),getConstLpPtr(),&rhs,whichVariable,whichVariable); 
    120 double range; 
    121 CPXgetrngval(const_cast<PicoLPSubclass<OsiGlpkSolverInterface,PicoLPCutMngmnt>*>(this)->OsiGlpkSolverInterface::getEnvironmentPtr(),getConstLpPtr(),&range,whichVariable,whichVariable); 
    122 double lower, upper; 
    123 convertSenseToBound(sense, rhs, range, lower, upper); 
    124 return lower; 
    125 #endif 
    126 return -999.0; 
    127 } 
    128  
    129  
    130 template<> 
    131 double PicoLPSubclass<OsiGlpkSolverInterface,PicoLPCutMngmnt>::getRowUpper(int whichVariable) const 
    132 { 
    133 #if 0 
    134 char sense; 
    135 CPXgetsense(const_cast<PicoLPSubclass<OsiGlpkSolverInterface,PicoLPCutMngmnt>*>(this)->OsiGlpkSolverInterface::getEnvironmentPtr(),getConstLpPtr(),&sense,whichVariable,whichVariable); 
    136 double rhs; 
    137 CPXgetrhs(const_cast<PicoLPSubclass<OsiGlpkSolverInterface,PicoLPCutMngmnt>*>(this)->OsiGlpkSolverInterface::getEnvironmentPtr(),getConstLpPtr(),&rhs,whichVariable,whichVariable); 
    138 double range; 
    139 CPXgetrngval(const_cast<PicoLPSubclass<OsiGlpkSolverInterface,PicoLPCutMngmnt>*>(this)->OsiGlpkSolverInterface::getEnvironmentPtr(),getConstLpPtr(),&range,whichVariable,whichVariable); 
    140 double lower, upper; 
    141 convertSenseToBound(sense, rhs, range, lower, upper); 
    142 return upper; 
    143 #endif 
    144 return -999.0; 
    145 } 
    146  
    147  
    148 template<> 
    149 double PicoLPSubclass<OsiGlpkSolverInterface,PicoLPCutMngmnt>::getRightHandSide(int whichConstraint) const 
    150 { 
    151 #if 0 
    152 double rhs; 
    153 CPXgetrhs(const_cast<PicoLPSubclass<OsiGlpkSolverInterface,PicoLPCutMngmnt>*>(this)->OsiGlpkSolverInterface::getEnvironmentPtr(),getConstLpPtr(),&rhs,whichConstraint,whichConstraint); 
    154 return rhs; 
    155 #endif 
    156 return -999.0; 
    157 } 
    158  
    159  
    160 template<> 
    161 PicoLPInterface::constraintSense PicoLPSubclass<OsiGlpkSolverInterface,PicoLPCutMngmnt>::getRowSense(int whichConstraint) const 
    162 { 
    163 #if 0 
    164 char csense; 
    165 CPXgetsense( const_cast<PicoLPSubclass<OsiGlpkSolverInterface,PicoLPCutMngmnt>*>(this)->OsiGlpkSolverInterface::getEnvironmentPtr(),getConstLpPtr(), &csense, whichConstraint, whichConstraint); 
    166  
    167 PicoLPInterface::constraintSense sense = notRestricted; 
    168 switch (csense) { 
    169   case 'L':     sense = lessOrEqual; break; 
    170   case 'G':     sense = greaterOrEqual; break; 
    171   case 'E':     sense = equal; break; 
    172   case 'R':     sense = ranged; break; 
    173   case 'N':     sense = notRestricted; break; 
    174   default: 
    175         EXCEPTION_MNGR(runtime_error,"PicoLPSubclass::getRowSense - bad sense type=" << csense); 
    176   }; 
    177 return sense; 
    178 #endif 
    179 return notRestricted; 
    180 } 
    181  
    182  
    183 template<> 
    184 double PicoLPSubclass<OsiGlpkSolverInterface,PicoLPCutMngmnt>::getObjCoefficient(int whichVariable) const 
    185 { 
    186 #if 0 
    187 double ans; 
    188 int err = CPXgetobj(const_cast<PicoLPSubclass<OsiGlpkSolverInterface,PicoLPCutMngmnt>*>(this)->OsiGlpkSolverInterface::getEnvironmentPtr(),getConstLpPtr(),&ans,whichVariable,whichVariable); 
    189 checkCPXerror( err, "CPXgetobj", "getObjCoefficient" ); 
    190 return ans; 
    191 #endif  
    192 return -999.0; 
    193 } 
    194  
    195  
    196 template<> 
    197 double PicoLPSubclass<OsiGlpkSolverInterface,PicoLPCutMngmnt>::getColSolution(const int whichCol) const 
    198 { 
    199 #if 0 
    200 double ans = 0.0; 
    201 int probType = CPXgetprobtype(const_cast<PicoLPSubclass<OsiGlpkSolverInterface,PicoLPCutMngmnt>*>(this)->OsiGlpkSolverInterface::getEnvironmentPtr(),getConstLpPtr()); 
    202 #if (CPX_VERSION >= 800) 
    203 if ( probType == CPXPROB_MILP ) { 
    204 #else 
    205 if ( probType == CPXPROB_MIP ) { 
    206 #endif 
    207    int err = CPXgetmipx( const_cast<PicoLPSubclass<OsiGlpkSolverInterface,PicoLPCutMngmnt>*>(this)->OsiGlpkSolverInterface::getEnvironmentPtr(),getConstLpPtr(), &ans, whichCol, whichCol); 
    208    if ( err == CPXERR_NO_INT_SOLN ) 
    209       ans = 0.0; 
    210    else 
    211       checkCPXerror( err, "CPXgetmipx", "getColSolution" ); 
    212    } 
    213 else { 
    214    int err = CPXgetx( const_cast<PicoLPSubclass<OsiGlpkSolverInterface,PicoLPCutMngmnt>*>(this)->OsiGlpkSolverInterface::getEnvironmentPtr(),getConstLpPtr(), &ans, whichCol, whichCol ); 
    215    if ( err == CPXERR_NO_SOLN ) 
    216       ans = 0.0; 
    217    else 
    218       checkCPXerror( err, "CPXgetx", "getColSolution" ); 
    219    } 
    220 return ans; 
    221 #endif 
    222 return -999.0; 
    223 } 
    224  
    225  
    226 template<> 
    227 double PicoLPSubclass<OsiGlpkSolverInterface,PicoLPCutMngmnt>::getRowPrice(const int whichRow) const 
    228 { 
    229 #if 0 
    230 double ans; 
    231 int err = CPXgetpi(const_cast<PicoLPSubclass<OsiGlpkSolverInterface,PicoLPCutMngmnt>*>(this)->OsiGlpkSolverInterface::getEnvironmentPtr(),getConstLpPtr(),&ans,whichRow,whichRow); 
    232 if (err == CPXERR_NO_SOLN) 
    233    ans = 0.0; 
    234 else 
    235    checkCPXerror( err, "CPXgetpi", "getRowPrice" ); 
    236 return ans; 
    237 #endif 
    238 return -999.0; 
    239 } 
    240  
    241  
    242 template<> 
    243 double PicoLPSubclass<OsiGlpkSolverInterface,PicoLPCutMngmnt>::getReducedCost(const int whichCol) const 
    244 { 
    245 #if 0 
    246 double ans; 
    247 int err = CPXgetdj(const_cast<PicoLPSubclass<OsiGlpkSolverInterface,PicoLPCutMngmnt>*>(this)->OsiGlpkSolverInterface::getEnvironmentPtr(),getConstLpPtr(),&ans,whichCol,whichCol); 
    248 if (err == CPXERR_NO_SOLN) 
    249    ans = 0.0; 
    250 else 
    251    checkCPXerror( err, "CPXgetdj", "getReducedCost" ); 
    252 return ans; 
    253 #endif 
    254 return -999.0; 
    255 } 
    256  
    257  
    258 template <> 
    259 void PicoLPSubclass<OsiGlpkSolverInterface,PicoLPCutMngmnt>::getBasis(BasisArray& basisBuffer) const 
    260 { 
    261 #if 0 
    262 int numCols = getNumCols(); 
    263 int basisSize = numCols + getNumRows(); 
    264 utilib::IntVector tempBasis(basisSize); 
    265 int tmp = CPXgetbase(const_cast<PicoLPSubclass<OsiGlpkSolverInterface,PicoLPCutMngmnt>*>(this)->OsiGlpkSolverInterface::getEnvironmentPtr(),getConstLpPtr(),(int*)(tempBasis.data()),(int*)(&tempBasis[numCols])); 
    266 if (tmp) 
    267    EXCEPTION_MNGR(runtime_error,"CPLEX would not retreive basis"); 
    268 for (int i = 0; i < basisSize; i++) { 
    269   int val = tempBasis[i]; 
    270   if (val == 0) basisBuffer.put(i, atLower); 
    271   else if (val == 3) basisBuffer.put(i, other); 
    272   else basisBuffer.put(i, (basisState)val); 
    273   } 
    274 #endif 
    275 } 
    276  
    277 template <> 
    278 basisState PicoLPSubclass<OsiGlpkSolverInterface,PicoLPCutMngmnt>::getBasis(int whichVariable) const 
    279 { 
    280 #if 0 
    281 int numCols = getNumCols(); 
    282 utilib::IntVector tempBasis(numCols + getNumRows()); 
    283 int tmp = CPXgetbase(const_cast<PicoLPSubclass<OsiGlpkSolverInterface,PicoLPCutMngmnt>*>(this)->OsiGlpkSolverInterface::getEnvironmentPtr(),getConstLpPtr(), 
    284                 (int*)(tempBasis.data()),(int*)(&tempBasis[numCols])); 
    285 if (tmp) 
    286   EXCEPTION_MNGR(runtime_error, "PicoLPSubclass<T,V>::getBasis -- " 
    287                  "Couldn't retreive basis"); 
    288 int val = tempBasis[whichVariable]; 
    289 // 
    290 // Convert to Osi standard representation for the basis 
    291 // 
    292 if (val == 0) return atLower; 
    293 if (val == 3) return other; 
    294 return (basisState)val; 
    295 #endif 
    296 return other; 
    297 } 
    298  
    299  
    300 template <> 
    301 void PicoLPSubclass<OsiGlpkSolverInterface,PicoLPCutMngmnt>::setBasis(BasisArray& basisBuffer) 
    302 { 
    303 #if 0 
    304 static BasicArray<int> tempBasis; 
    305  
    306 int basisSize = getNumRows() + getNumCols(); 
    307 tempBasis.resize(basisSize); 
    308 for (int i = 0; i < basisSize; i++) 
    309   tempBasis[i] = (int)basisBuffer(i); 
    310 status = CPXcopybase(const_cast<PicoLPSubclass<OsiGlpkSolverInterface,PicoLPCutMngmnt>*>(this)->OsiGlpkSolverInterface::getEnvironmentPtr(),getConstLpPtr(),(int*)(tempBasis.data()), 
    311                                         (int*)(&tempBasis[getNumCols() ])); 
    312 if (status && lpWarnings) 
    313    ucout << "Warning: cplex would not load basis, status = " << status; 
    314 else 
    315   { 
    316   // We may want to rethink at some point.  I don't think the MIP uses this  
    317   // and I don't think we suppress basis copying if this is false. 
    318   have_basis = true; 
    319   // If you change the basis, presumably there needs to be some 
    320   // computation to make it a solution to the problem. 
    321   myState= unsolved; 
    322   } 
    323 #endif 
    324 } 
    325  
    326  
    327 template<> 
    328 priceRule PicoLPSubclass<OsiGlpkSolverInterface,PicoLPCutMngmnt>::getPricingRule() const 
    329 { 
    330 /// TODO 
    331 return defaultPricing; 
    332 } 
    333  
    334  
    335 template<> 
    336 void PicoLPSubclass<OsiGlpkSolverInterface,PicoLPCutMngmnt>::setPricingRule(priceRule rule) 
    337 { 
    338 /// TODO 
    339 } 
    340  
    341  
    342 template<> 
    343 double PicoLPSubclass<OsiGlpkSolverInterface,PicoLPCutMngmnt>::getTimeLimit() const 
    344 { 
    345 #if 0 
    346 double ans; 
    347 int tmp = CPXgetdblparam(const_cast<PicoLPSubclass<OsiGlpkSolverInterface,PicoLPCutMngmnt>*>(this)->OsiGlpkSolverInterface::getEnvironmentPtr(),CPX_PARAM_TILIM,&ans); 
    348 if (tmp != 0) 
    349   { 
    350     EXCEPTION_MNGR(runtime_error, "Unable to get time limit"); 
    351   } 
    352 return ans; 
    353 #endif 
    354 return -999.0; 
    355 } 
    356  
    357  
    358 template<> 
    359 void PicoLPSubclass<OsiGlpkSolverInterface,PicoLPCutMngmnt>::setTimeLimit(double time) 
    360 { 
    361 #if 0 
    362 int tmp = CPXsetdblparam(const_cast<PicoLPSubclass<OsiGlpkSolverInterface,PicoLPCutMngmnt>*>(this)->OsiGlpkSolverInterface::getEnvironmentPtr(),CPX_PARAM_TILIM,time); 
    363 if (tmp) 
    364   EXCEPTION_MNGR(runtime_error,"Unable to set time limit"); 
    365 #endif 
    366 } 
    367  
    368  
    369 template<> 
    370 clockType PicoLPSubclass<OsiGlpkSolverInterface,PicoLPCutMngmnt>::getClockType() const 
    371 { 
    372 #if 0 
    373 int ans; 
    374 int tmp = CPXgetintparam(const_cast<PicoLPSubclass<OsiGlpkSolverInterface,PicoLPCutMngmnt>*>(this)->OsiGlpkSolverInterface::getEnvironmentPtr(),CPX_PARAM_CLOCKTYPE,&ans); 
    375 if (tmp != 0) 
    376   { 
    377     EXCEPTION_MNGR(runtime_error,"Unable to get clock type"); 
    378   } 
    379 if ((clockType) ans != cpuTime && (clockType)ans != wallTime) 
    380   EXCEPTION_MNGR(runtime_error, "Unknown clock type " <<  ans) 
    381 return (clockType)ans; 
    382 #endif 
    383 return (clockType)0.0; 
    384 } 
    385  
    386  
    387 template<> 
    388 void PicoLPSubclass<OsiGlpkSolverInterface,PicoLPCutMngmnt>::setClockType(clockType cType) 
    389 { 
    390 #if 0 
    391 if (cType != cpuTime && cType != wallTime) 
    392   EXCEPTION_MNGR(runtime_error, "Improper clock type " << cType) 
    393 int tmp = CPXsetintparam(const_cast<PicoLPSubclass<OsiGlpkSolverInterface,PicoLPCutMngmnt>*>(this)->OsiGlpkSolverInterface::getEnvironmentPtr(),CPX_PARAM_CLOCKTYPE, (int)cType); 
    394 if (tmp) 
    395   EXCEPTION_MNGR(runtime_error, "Unable to set clock type") 
    396 #endif 
    397 } 
    398  
    399  
    400  
    401 template<> 
    402 PicoLPSubclass<OsiGlpkSolverInterface,PicoLPCutMngmnt>::PicoLPSubclass() 
    403 { 
    404 #if 0 
    405 solverMethod = primalSimplex; 
    406 // TODO 
    407 // Turn cplex preprocessing off till we handle presolve infeasibility 
    408 // errors more gracefully 
    409 CPXsetintparam(const_cast<PicoLPSubclass<OsiGlpkSolverInterface,PicoLPCutMngmnt>*>(this)->OsiGlpkSolverInterface::getEnvironmentPtr(), CPX_PARAM_PREIND, 0); 
    410 #endif 
    411 } 
    412  
    413 template<> 
    414 void PicoLPSubclass<OsiGlpkSolverInterface,PicoLPCutMngmnt>::write(char *filename, ilp_format format) 
    415 { 
    416 #if 0 
    417   // actually just use cplex mps and lp formats for now. 
    418 int writeStatus; 
    419 if (format == mps_format) 
    420   { 
    421     // This will write with original names, but since PICO currently 
    422     // doesn't give the real variable names (etc) to the cplex solver, 
    423     // it will be equivalent to the "REW" filetype = generic names 
    424   writeStatus = CPXwriteprob(getEnvironmentPtr(), getConstLpPtr(), filename, "MPS"); 
    425   if (writeStatus) 
    426     ucout << "Error writing lp to file\n"; 
    427   return; 
    428   } 
    429 if (format == lp_format) 
    430   { 
    431   writeStatus = CPXwriteprob(getEnvironmentPtr(), getConstLpPtr(), filename, "LP"); 
    432   if (status) 
    433     ucout << "Error writing lp to file\n"; 
    434   return; 
    435   } 
    436 // default for the other formats. 
    437  PicoLPInterface::write(filename, format); 
    438 #endif 
    439 } 
    440  
    441 template<> 
    442 void PicoLPSubclass<OsiGlpkSolverInterface,PicoLPCutMngmnt>::printBrokenInfo() 
    443 { 
    444 #if 0 
    445     int stat = CPXgetstat( getEnvironmentPtr(), getConstLpPtr() ); 
    446     cout << "Broken LP has cplex status " << stat << "\n"; 
    447 #endif 
    448 } 
    449  
    450 template<> 
    451 void PicoLPSubclass<OsiGlpkSolverInterface,PicoLPCutMngmnt>::setMatrixCoeff(int row, int col, double newValue) 
    452 { 
    453 #if 0 
    454     int stat = CPXchgcoef(getEnvironmentPtr(), getConstLpPtr(), row, col, newValue); 
    455     if (stat != 0) EXCEPTION_MNGR(runtime_error, "Cplex error setting matrix coefficient for (" << row << ", " << col << ")") 
    456 #endif 
    457 } 
    458  
    459 typedef PicoLPSubclass<OsiGlpkSolverInterface,PicoLPCutMngmnt> PicoGlpkLP; 
    460  
    461 } // namespace pico 
    462  
    463 #endif 
    464  
    465 #endif