Changeset 29


Ignore:
Timestamp:
Oct 4, 2002 4:58:06 PM (17 years ago)
Author:
forrest
Message:

Presolve (no changes to Makefile)

Location:
branches/devel-1
Files:
32 added
9 edited

Legend:

Unmodified
Added
Removed
  • branches/devel-1/ClpDualRowSteepest.cpp

    r27 r29  
    493493  delete savedWeights_;
    494494  savedWeights_ = NULL;
    495 }
    496 
     495  state_ =-1;
     496}
     497
  • branches/devel-1/ClpMessage.cpp

    r23 r29  
    4949  {CLP_DUAL_CHECK,106,4,"Btran alpha %g, ftran alpha %g"},
    5050  {CLP_PRIMAL_DJ,107,4,"Btran dj %g, ftran dj %g"},
     51  {CLP_PRESOLVE_COLINFEAS,501,2,"Problem is infeasible due to column %d, %g %g"},
     52  {CLP_PRESOLVE_ROWINFEAS,502,2,"Problem is infeasible due to row %d, %g %g"},
     53  {CLP_PRESOLVE_COLUMNBOUNDA,503,2,"Problem looks unbounded above due to column %d, %g %g"},
     54  {CLP_PRESOLVE_COLUMNBOUNDB,504,2,"Problem looks unbounded below due to column %d, %g %g"},
     55  {CLP_PRESOLVE_NONOPTIMAL,505,1,"Problem not optimal, resolve after postsolve"},
     56  {CLP_PRESOLVE_STATS,506,1,"Presolve %d (%d) rows, %d (%d) columns and %d (%d) elements"},
     57  {CLP_PRESOLVE_INFEAS,507,0,"Presolve determined that the problem was infeasible with tolerance of %g"},
     58  {CLP_PRESOLVE_UNBOUND,508,0,"Presolve thinks problem is unbounded"},
     59  {CLP_PRESOLVE_INFEASUNBOUND,509,0,"Presolve thinks problem is infeasible AND unbounded???"},
     60  {CLP_PRESOLVE_INTEGERMODS,510,1,"Presolve is modifying %d integer bounds and re-presolving"},
     61  {CLP_PRESOLVE_POSTSOLVE,511,0,"After Postsolve, objective %g, infeasibilities - dual %g (%d), primal %g (%d)"},
    5162  {CLP_PACKEDSCALE_INITIAL,1001,2,"Initial range of elements is %g to %g"},
    5263  {CLP_PACKEDSCALE_WHILE,1002,3,"Range of elements is %g to %g"},
     
    6071  {CLP_IMPORT_RESULT,18,1,"Model was imported from %s in %g seconds"},
    6172  {CLP_IMPORT_ERRORS,3001,1," There were %d errors when importing model from %s"},
     73  {CLP_EMPTY_PROBLEM,3002,0,"Not solving empty problem - %d rows, %d columns and %d elements"},
    6274  {CLP_DUMMY_END,999999,0,""}
    6375};
  • branches/devel-1/ClpPrimalColumnSteepest.cpp

    r27 r29  
    954954  delete [] reference_;
    955955  reference_ = NULL;
    956 }
     956  pivotSequence_=-1;
     957  state_ = -1;
     958  savedPivotSequence_ = -1;
     959  savedSequenceOut_ = -1; 
     960  devex_ = 0.0;
     961}
  • branches/devel-1/ClpSimplex.cpp

    r28 r29  
    30913091  // put in standard form
    30923092  createRim(7+8+16);
     3093  dualTolerance_=dblParam_[ClpDualTolerance];
     3094  primalTolerance_=dblParam_[ClpPrimalTolerance];
    30933095  checkPrimalSolution( rowActivityWork_, columnActivityWork_);
    30943096  checkDualSolution();
  • branches/devel-1/ClpSimplexDual.cpp

    r28 r29  
    444444#endif
    445445    // choose row to go out
     446    // dualRow will go to virtual row pivot choice algorithm
    446447    dualRow();
    447448    if (pivotRow_>=0) {
  • branches/devel-1/Test/ClpMain.cpp

    r26 r29  
    3030#include "ClpPrimalColumnSteepest.hpp"
    3131#include "ClpPrimalColumnDantzig.hpp"
     32
     33#include "Presolve.hpp"
    3234// For Branch and bound
    3335//  #include "OsiClpSolverInterface.hpp"
     
    6668
    6769int mainTest (int argc, const char *argv[],bool doDual,
    68               ClpSimplex empty);
     70              ClpSimplex empty, bool doPresolve);
    6971enum ClpParameterType {
    7072  GENERALQUERY=-100,
     
    7577 
    7678  DIRECTION=201,DUALPIVOT,SCALING,ERRORSALLOWED,KEEPNAMES,SPARSEFACTOR,
    77   PRIMALPIVOT,
     79  PRIMALPIVOT,PRESOLVE,
    7880 
    7981  DIRECTORY=301,IMPORT,EXPORT,RESTORE,SAVE,DUALSIMPLEX,PRIMALSIMPLEX,BAB,
     
    794796    parameters[numberParameters-1].append("off");
    795797    parameters[numberParameters++]=
     798      ClpItem("presolve","Whether to presolve problem",
     799              "off",PRESOLVE);
     800    parameters[numberParameters-1].append("on");
     801    parameters[numberParameters++]=
    796802      ClpItem("spars!eFactor","Whether factorization treated as sparse",
    797803              "on",SPARSEFACTOR);
     
    888894    int allowImportErrors=0;
    889895    int keepImportNames=1;
     896    int preSolve=0;
    890897   
    891898    int iModel=0;
     
    10501057              keepImportNames = 1-action;
    10511058              break;
     1059            case PRESOLVE:
     1060              preSolve = action;
     1061              break;
    10521062            default:
    10531063              abort();
     
    10631073            if (goodModels[iModel]) {
    10641074              int saveMaxIterations = models[iModel].maximumIterations();
     1075              Presolve pinfo;
     1076              ClpSimplex * model2 = models+iModel;
     1077              if (preSolve)
     1078                model2 = pinfo.presolvedModel(models[iModel],1.0e-8);
     1079
    10651080#ifdef READLINE     
    1066               currentModel = models+iModel;
     1081              currentModel = model2;
    10671082#endif
    10681083              if (type==DUALSIMPLEX)
    1069                 models[iModel].dual();
     1084                model2->dual();
    10701085              else
    1071                 models[iModel].primal();
     1086                model2->primal();
     1087              if (preSolve) {
     1088                pinfo.postsolve(true);
     1089               
     1090                delete model2;
     1091                printf("Resolving from postsolved model\n");
     1092               
     1093#ifdef READLINE     
     1094                currentModel = models+iModel;
     1095#endif
     1096                models[iModel].primal(1);
     1097              }
    10721098              models[iModel].setMaximumIterations(saveMaxIterations);
    10731099              time2 = cpuTime();
     
    13221348              else
    13231349                std::cerr<<"Doing netlib with primal agorithm"<<std::endl;
    1324               mainTest(nFields,fields,(type==NETLIB_DUAL),models[iModel]);
     1350              mainTest(nFields,fields,(type==NETLIB_DUAL),models[iModel],
     1351                       (preSolve!=0));
    13251352            }
    13261353            break;
     
    13361363                nFields=3;
    13371364              }
    1338               mainTest(nFields,fields,false,models[iModel]);
     1365              mainTest(nFields,fields,false,models[iModel],(preSolve!=0));
    13391366            }
    13401367            break;
  • branches/devel-1/Test/unitTest.cpp

    r26 r29  
    3030#include "ClpPrimalColumnDantzig.hpp"
    3131#include "ClpParameters.hpp"
     32
     33#include "Presolve.hpp"
    3234
    3335//#############################################################################
     
    5557
    5658int mainTest (int argc, const char *argv[],bool doDual,
    57               ClpSimplex empty)
     59              ClpSimplex empty, bool doPresolve)
    5860{
    5961  int i;
     
    252254                           mps.getRowLower(),mps.getRowUpper());
    253255
    254       if (doDual) {
    255 #if 0
    256         solution.scaling(1);
    257         solution.setDualBound(1.0e6);
    258         solution.setDualTolerance(1.0e-7);
    259         // set objective sense,
    260         if(min[m])
    261           solution.setOptimizationDirection(1);
    262         else       
    263           solution.setOptimizationDirection(-1);
    264         ClpDualRowSteepest steep;
    265         solution.setDualRowPivotAlgorithm(steep);
    266 #endif
    267         solution.setDblParam(ClpObjOffset,mps.objectiveOffset());
    268         solution.dual();
     256      solution.setDblParam(ClpObjOffset,mps.objectiveOffset());
     257      if (doPresolve) {
     258        Presolve pinfo;
     259        ClpSimplex * model2 = pinfo.presolvedModel(solution,1.0e-8);
     260        if (doDual)
     261          model2->dual();
     262        else
     263          model2->primal();
     264        pinfo.postsolve(true);
     265       
     266        delete model2;
     267        printf("Resolving from postsolved model\n");
     268        // later try without (1) and check duals before solve
     269        solution.primal(1);
     270        if (solution.numberIterations())
     271          printf("****** iterated %d\n",solution.numberIterations());
     272        solution.checkSolution();
     273        printf("%g dual %g(%d) Primal %g(%d)\n",
     274               solution.objectiveValue(),
     275               solution.sumDualInfeasibilities(),
     276               solution.numberDualInfeasibilities(),
     277               solution.sumPrimalInfeasibilities(),
     278               solution.numberPrimalInfeasibilities());
     279        {
     280          Presolve pinfoA;
     281          model2 = pinfoA.presolvedModel(solution,1.0e-8);
     282
     283          printf("Resolving from presolved optimal solution\n");
     284          model2->primal(1);
     285               
     286          delete model2;
     287        }
     288
    269289      } else {
    270 #if 0
    271         solution.setPrimalTolerance(1.0e-8);
    272         solution.scaling(1);
    273         ClpPrimalColumnSteepest steep;
    274         solution.setPrimalColumnPivotAlgorithm(steep);
    275         // set objective sense,
    276         if(min[m])
    277           solution.setOptimizationDirection(1);
    278         else       
    279           solution.setOptimizationDirection(-1);
    280         solution.setInfeasibilityCost(1.0e6);
    281 #endif
    282         solution.setDblParam(ClpObjOffset,mps.objectiveOffset());
    283         solution.primal();
     290        if (doDual) {
     291          solution.dual();
     292        } else {
     293          solution.primal();
     294        }
    284295      }
    285296      // Test objective solution value
  • branches/devel-1/include/ClpMessage.hpp

    r23 r29  
    3939  CLP_RIMSTATISTICS2,
    4040  CLP_RIMSTATISTICS3,
     41  CLP_PRESOLVE_COLINFEAS,
     42  CLP_PRESOLVE_ROWINFEAS,
     43  CLP_PRESOLVE_COLUMNBOUNDA,
     44  CLP_PRESOLVE_COLUMNBOUNDB,
     45  CLP_PRESOLVE_NONOPTIMAL,
     46  CLP_PRESOLVE_STATS,
     47  CLP_PRESOLVE_INFEAS,
     48  CLP_PRESOLVE_UNBOUND,
     49  CLP_PRESOLVE_INFEASUNBOUND,
     50  CLP_PRESOLVE_INTEGERMODS,
     51  CLP_PRESOLVE_POSTSOLVE,
    4152  CLP_POSSIBLELOOP,
    4253  CLP_SMALLELEMENTS,
     
    5970  CLP_IMPORT_RESULT,
    6071  CLP_IMPORT_ERRORS,
     72  CLP_EMPTY_PROBLEM,
    6173  CLP_DUMMY_END
    6274};
  • branches/devel-1/include/ClpPrimalColumnSteepest.hpp

    r27 r29  
    55
    66#include "ClpPrimalColumnPivot.hpp"
     7#include <bitset>
    78
    89//#############################################################################
Note: See TracChangeset for help on using the changeset viewer.