Changeset 1480


Ignore:
Timestamp:
Dec 12, 2009 9:38:55 PM (10 years ago)
Author:
ladanyi
Message:

exposed the idiot code through the C interface

Location:
trunk/Clp/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Clp/src/Clp_C_Interface.cpp

    r1402 r1480  
    1313#include "ClpSimplex.hpp"
    1414#include "ClpInterior.hpp"
     15#ifndef SLIM_CLP
     16#include "Idiot.hpp"
     17#endif
    1518#include <cfloat>
    1619// Get C stuff but with extern C
     
    993996{
    994997  return model->model_->getObjSense();
     998}
     999/* Direction of optimization (1 - minimize, -1 - maximize, 0 - ignore */
     1000COINLIBAPI void COINLINKAGE
     1001Clp_setObjSense(Clp_Simplex * model, double objsen)
     1002{
     1003  model->model_->setOptimizationDirection(objsen);
    9951004}
    9961005/* Primal row solution */
     
    11551164  }
    11561165}
     1166
     1167#ifndef SLIM_CLP
     1168/** Solve the problem with the idiot code */
     1169/* tryhard values:
     1170   tryhard & 7:
     1171      0: NOT lightweight, 105 iterations within a pass (when mu stays fixed)
     1172      1: lightweight, but focus more on optimality (mu is high)
     1173         (23 iters in a pass)
     1174      2: lightweight, but focus more on feasibility (11 iters in a pass)
     1175      3: lightweight, but focus more on feasibility (23 iters in a pass, so it
     1176         goes closer to opt than option 2)
     1177   tryhard >> 3:
     1178      number of passes, the larger the number the closer it gets to optimality
     1179*/
     1180COINLIBAPI void COINLINKAGE
     1181Clp_idiot(Clp_Simplex * model, int tryhard)
     1182{
     1183   ClpSimplex *clp = model->model_;
     1184   Idiot info(*clp);
     1185   int numberpass = tryhard >> 3;
     1186   int lightweight = tryhard & 7;
     1187   info.setLightweight(lightweight);
     1188   info.crash(numberpass, clp->messageHandler(), clp->messagesPointer(), false);
     1189}
     1190#endif
     1191
    11571192#if defined(__MWERKS__)
    11581193#pragma export off
  • trunk/Clp/src/Clp_C_Interface.h

    r1370 r1480  
    266266  /** Primal algorithm - see ClpSimplexPrimal.hpp for method */
    267267  COINLIBAPI int COINLINKAGE Clp_primal(Clp_Simplex * model, int ifValuesPass);
     268#ifndef SLIM_CLP
     269  /** Solve the problem with the idiot code */
     270  COINLIBAPI void COINLINKAGE Clp_idiot(Clp_Simplex * model, int tryhard);
     271#endif
    268272  /** Sets or unsets scaling, 0 -off, 1 equilibrium, 2 geometric, 3, auto, 4 dynamic(later) */
    269273  COINLIBAPI void COINLINKAGE Clp_scaling(Clp_Simplex * model, int mode);
     
    363367  /** Direction of optimization (1 - minimize, -1 - maximize, 0 - ignore */
    364368  COINLIBAPI double COINLINKAGE Clp_getObjSense(Clp_Simplex * model);
     369  /** Direction of optimization (1 - minimize, -1 - maximize, 0 - ignore */
     370  COINLIBAPI void COINLINKAGE Clp_setObjSense(Clp_Simplex * model, double objsen);
    365371  /** Primal row solution */
    366372  COINLIBAPI const double * COINLINKAGE Clp_getRowActivity(Clp_Simplex * model);
  • trunk/Clp/src/Idiot.cpp

    r1453 r1480  
    324324}
    325325void
    326 Idiot::crash(int numberPass, CoinMessageHandler * handler,const CoinMessages *messages)
     326Idiot::crash(int numberPass, CoinMessageHandler * handler,
     327             const CoinMessages *messages, bool doCrossover)
    327328{
    328329  // lightweight options
     
    363364  solve2(handler,messages);
    364365#ifndef OSI_IDIOT
    365   double averageInfeas = model_->sumPrimalInfeasibilities()/static_cast<double> (model_->numberRows());
    366   if ((averageInfeas<0.01&&(strategy_&512)!=0)||(strategy_&8192)!=0)
    367     crossOver(16+1);
    368   else
    369     crossOver(majorIterations_<1000000 ? 3 : 2);
     366  if (doCrossover) {
     367     double averageInfeas = model_->sumPrimalInfeasibilities()/static_cast<double> (model_->numberRows());
     368     if ((averageInfeas<0.01&&(strategy_&512)!=0)||(strategy_&8192)!=0)
     369        crossOver(16+1);
     370     else
     371        crossOver(majorIterations_<1000000 ? 3 : 2);
     372  }
    370373#endif
    371374}
     375
    372376void
    373377Idiot::solve()
  • trunk/Clp/src/Idiot.hpp

    r1370 r1480  
    7272  void solve();
    7373  /// Lightweight "crash"
    74   void crash(int numberPass,CoinMessageHandler * handler ,const CoinMessages * messages);
     74   void crash(int numberPass, CoinMessageHandler * handler,
     75              const CoinMessages * messages, bool doCrossover = true);
    7576  /** Use simplex to get an optimal solution
    7677      mode is how many steps the simplex crossover should take to
Note: See TracChangeset for help on using the changeset viewer.