Changeset 2491


Ignore:
Timestamp:
Feb 12, 2019 8:05:24 AM (4 days ago)
Author:
forrest
Message:

better SOS in mipstart, ctrl-c back, improve symmetric

Location:
trunk/Cbc/src
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Cbc/src/CbcMipStartIO.cpp

    r2467 r2491  
    1414#include <CbcModel.hpp>
    1515#include "CbcMipStartIO.hpp"
     16#include "CbcSOS.hpp"
    1617#include "CoinTime.hpp"
    1718
     
    195196      int numberObjects = model->numberObjects();
    196197      for (int i = 0; i < numberObjects; i++) {
    197         const OsiSOS *object = dynamic_cast< const OsiSOS * >(model->object(i));
     198        const CbcSOS *object = dynamic_cast< const CbcSOS * >(model->object(i));
    198199        if (object) {
    199200          int n = object->numberMembers();
  • trunk/Cbc/src/CbcModel.cpp

    r2485 r2491  
    23552355  if ((moreSpecialOptions2_ & (128 | 256)) != 0 && !parentModel_) {
    23562356    symmetryInfo_ = new CbcSymmetry();
    2357     symmetryInfo_->setupSymmetry(*continuousSolver_);
     2357    symmetryInfo_->setupSymmetry(this);
    23582358    int numberGenerators = symmetryInfo_->statsOrbits(this, 0);
    23592359    if (!symmetryInfo_->numberUsefulOrbits() && (moreSpecialOptions2_ & (128 | 256)) != (128 | 256)) {
  • trunk/Cbc/src/CbcSOS.cpp

    r2475 r2491  
    237237  }
    238238  /* ?? */
    239   preferredWay = 1;
     239  preferredWay = sum > 0 ? 1 : -1;
    240240  /*
    241241  SOS1 allows one nonzero; SOS2 allows two consecutive nonzeros. Infeasibility
  • trunk/Cbc/src/CbcSolver.cpp

    r2485 r2491  
    19771977#endif
    19781978          lpSolver = clpSolver->getModelPtr();
    1979           if (!lpSolver->integerInformation() && !numberSOS && !clpSolver->numberSOS() && !model_.numberObjects() && !clpSolver->numberObjects())
     1979          if (!lpSolver->integerInformation() && !numberSOS && !clpSolver->numberSOS() && !model_.numberObjects() && !clpSolver->numberObjects()) {
    19801980            type = CLP_PARAM_ACTION_DUALSIMPLEX;
     1981#ifdef CBC_MAXIMUM_BOUND
     1982          } else {
     1983            double * lower = lpSolver->columnLower();
     1984            double * upper = lpSolver->columnUpper();
     1985            int numberColumns = lpSolver->numberColumns();
     1986            for (int i=0;i<numberColumns;i++) {
     1987              lower[i] = CoinMax(lower[i],-CBC_MAXIMUM_BOUND);
     1988              upper[i] = CoinMin(upper[i],CBC_MAXIMUM_BOUND);
     1989            }
     1990#endif
     1991          }
    19811992#endif
    19821993        }
     
    59415952#ifndef MAKE_SOS_CLIQUES
    59425953                      objects[iSOS] = new CbcSOS(babModel_, n, which + iStart, weight + iStart,
    5943                         iSOS, type[iSOS]);
     5954                                                iSOS, type[iSOS]);
    59445955#else
    59455956                      objects[iSOS] = new CbcClique(babModel_, 1, n, which + iStart,
     
    1239612407    //int maxN=5000000;
    1239712408    //OsiSolverInterface * solver = model.solver();
    12398     symmetryInfo.setupSymmetry(*solver);
     12409    symmetryInfo.setupSymmetry(&model);
    1239912410    int numberGenerators = symmetryInfo.statsOrbits(&model, 0);
    1240012411    if (numberGenerators) {
  • trunk/Cbc/src/CbcSymmetry.cpp

    r2467 r2491  
    7474}
    7575
     76// simple nauty definitely not thread safe
     77static int calls = 0;
     78static int maxLevel = 0;
     79static void
     80userlevelproc(int *lab, int *ptn, int level, int *orbits, statsblk *stats,
     81  int tv, int index, int tcellsize,
     82  int numcells, int childcount, int n)
     83{
     84  calls++;
     85  if (level > maxLevel) {
     86    printf("Level %d after %d calls\n", level, calls);
     87    fprintf(stderr, "Level %d after %d calls\n", level, calls);
     88    maxLevel = level;
     89  }
     90  if (level > 1500) {
     91    throw CoinError("May take too long", "", "CbcSymmetry");
     92  }
     93  //}
     94  return;
     95}
    7696void CbcSymmetry::Compute_Symmetry() const
    7797{
    7898
     99  nauty_info_->options()->userlevelproc = userlevelproc;
    79100  std::sort(node_info_.begin(), node_info_.end(), node_sort);
    80101
     
    325346  }
    326347}
    327 void CbcSymmetry::setupSymmetry(const OsiSolverInterface &solver)
    328 {
     348void CbcSymmetry::setupSymmetry(CbcModel * model)
     349{
     350  OsiSolverInterface * solver = model->continuousSolver();
    329351  double startCPU = CoinCpuTime();
    330   const double *objective = solver.getObjCoefficients();
    331   const double *columnLower = solver.getColLower();
    332   const double *columnUpper = solver.getColUpper();
    333   int numberColumns = solver.getNumCols();
    334   int numberRows = solver.getNumRows();
     352  const double *objective = solver->getObjCoefficients();
     353  const double *columnLower = solver->getColLower();
     354  const double *columnUpper = solver->getColUpper();
     355  int numberColumns = solver->getNumCols();
     356  int numberRows = solver->getNumRows();
    335357  int iRow, iColumn;
    336358
    337359  // Row copy
    338   CoinPackedMatrix matrixByRow(*solver.getMatrixByRow());
     360  CoinPackedMatrix matrixByRow(*solver->getMatrixByRow());
    339361  const double *elementByRow = matrixByRow.getElements();
    340362  const int *column = matrixByRow.getIndices();
     
    342364  const int *rowLength = matrixByRow.getVectorLengths();
    343365
    344   const double *rowLower = solver.getRowLower();
    345   const double *rowUpper = solver.getRowUpper();
     366  const double *rowLower = solver->getRowLower();
     367  const double *rowUpper = solver->getRowUpper();
    346368  //  // Find Coefficients
    347369
     
    619641  nautyFixes_ = 0.0;
    620642  nautyOtherBranches_ = 0.0;
    621   Compute_Symmetry();
     643  try {
     644    Compute_Symmetry();
     645  } catch (CoinError &e) {
     646    char general[200];
     647    sprintf(general, "Nauty - initial level %d - will probably take too long",
     648        maxLevel);
     649    model->messageHandler()->message(CBC_GENERAL,model->messages())
     650      <<general <<CoinMessageEol;
     651  }
    622652  fillOrbits();
    623653  //whichOrbit_[2]=numberUsefulOrbits_;
  • trunk/Cbc/src/CbcSymmetry.hpp

    r2467 r2491  
    165165
    166166  /// empty if no NTY, symmetry data structure setup otherwise
    167   void setupSymmetry(const OsiSolverInterface &solver);
     167  void setupSymmetry(CbcModel * model);
    168168
    169169private:
     
    237237  }
    238238#endif
     239  /// Pointer to options
     240  inline optionblk *options() const
     241  {
     242    return options_;
     243  }
    239244  /**
    240245   * Methods to classify orbits.  Not horribly efficient, but gets the job done
  • trunk/Cbc/src/CoinSolve.cpp

    r2479 r2491  
    336336
    337337    CbcSolverUsefulData cbcData;
     338#ifndef CBC_NO_INTERRUPT
     339    cbcData.useSignalHandler_ = true;
     340#endif
    338341    cbcData.noPrinting_ = false;
    339342    // initialize
Note: See TracChangeset for help on using the changeset viewer.