Changeset 2449 for stable/1.17/Clp


Ignore:
Timestamp:
Apr 7, 2019 11:34:28 PM (6 months ago)
Author:
stefan
Message:

sync with trunk

Location:
stable/1.17/Clp
Files:
16 edited

Legend:

Unmodified
Added
Removed
  • stable/1.17/Clp

  • stable/1.17/Clp/examples/driver3.cpp

    r2431 r2449  
    3434int ClpMain1(int argc, const char *argv[],AbcSimplex * model);
    3535#endif
     36/*
     37  Somehow with some BLAS we get multithreaded by default
     38  For 99.99% of problems this is not a good idea.
     39  The openblas_set_num_threads(1) seems to work even with other blas
     40 */
     41#if CLP_USE_OPENBLAS
     42extern "C" {
     43void openblas_set_num_threads(int num_threads);
     44}
     45#endif
    3646int main (int argc, const char *argv[])
    3747{
    3848
     49#if CLP_USE_OPENBLAS
     50  openblas_set_num_threads(CLP_USE_OPENBLAS);
     51#endif
    3952#ifndef ABC_INHERIT
    4053  ClpSimplex model;
  • stable/1.17/Clp/examples/testGub.cpp

    r2278 r2449  
    443443          printf("obj offset is %g\n", model2.objectiveOffset());
    444444          printf("Primal took %g seconds\n", CoinCpuTime() - time1);
     445     } else {
     446       printf("No gub rows - this is just example code so exiting\n");
     447       exit(77);
    445448     }
    446449     delete [] mark;
  • stable/1.17/Clp/src

  • stable/1.17/Clp/src/CbcOrClpParam.cpp

    r2392 r2449  
    33883388    p.append("boundsint");
    33893389    p.append("boundsall");
     3390    p.append("fixint");
     3391    p.append("fixall");
    33903392    p.setLonghelp(
    33913393      "This changes the amount and format of printing a solution:\nnormal - nonzero column variables \n\
  • stable/1.17/Clp/src/ClpPrimalColumnSteepest.cpp

    r2431 r2449  
    31693169  if (mode == 6) {
    31703170    // If incoming weight is 1.0 then return else as 5
    3171     assert(weights_);
    31723171    int sequenceIn = model_->sequenceIn();
    31733172    assert(sequenceIn >= 0 && sequenceIn < model_->numberRows() + model_->numberColumns());
    3174     if (weights_[sequenceIn] == (mode_ != 1) ? 1.0 : 1.0 + ADD_ONE)
     3173    // possible weights_ was never set up // assert(weights_);
     3174    if (weights_ && weights_[sequenceIn] == (mode_ != 1) ? 1.0 : 1.0 + ADD_ONE)
    31753175      return;
    31763176    else
     
    43154315      int iSequence;
    43164316      for (iSequence = start; iSequence < end; iSequence++) {
     4317        assert (iSequence>=numberColumns);
    43174318        if (iSequence != sequenceOut) {
    43184319          double value;
  • stable/1.17/Clp/src/ClpSimplex.cpp

    r2437 r2449  
    19231923  //}
    19241924  //}
    1925 #if 0 //ndef _MSC_VER                                                              \
    1926   // The local static var k is a problem when trying to build a DLL. Since this is \
    1927   // just for debugging (likely done on *nix), just hide it from Windows           \
     1925#if 0 //ndef _MSC_VER                                                           
     1926  // The local static var k is a problem when trying to build a DLL. Since this is
     1927  // just for debugging (likely done on *nix), just hide it from Windows       
    19281928  // -- lh, 101016 --
    19291929     if (0)  {
     
    76417641  // set problem name
    76427642  setStrParam(ClpProbName, m.getProblemName());
     7643  // set objective function offest
     7644  setDblParam(ClpObjOffset, m.objectiveOffset());
    76437645  // no errors
     7646#ifndef SWITCH_BACK_TO_MAXIMIZATION
     7647#define SWITCH_BACK_TO_MAXIMIZATION 1
     7648#endif
     7649#if SWITCH_BACK_TO_MAXIMIZATION
     7650  double * originalObj = NULL;
     7651  if (m.wasMaximization()) {
     7652    // switch back
     7653    setDblParam(ClpObjOffset, -m.objectiveOffset());
     7654    int numberColumns = m.getNumCols();
     7655    originalObj = CoinCopyOfArray(m.getObjCoefficients(),numberColumns);
     7656    for (int i=0;i < numberColumns;i++)
     7657      originalObj[i] = - originalObj[i];
     7658    setOptimizationDirection(-1.0);
     7659    handler_->message(CLP_GENERAL, messages_)
     7660      << "Switching back to maximization to get correct duals etc"
     7661      << CoinMessageEol;
     7662  }
     7663  loadProblem(*m.getMatrixByRow(), m.getColLower(), m.getColUpper(),
     7664              !originalObj ? m.getObjCoefficients() : originalObj,
     7665              m.getRowLower(), m.getRowUpper());
     7666  delete [] originalObj;
     7667#else
    76447668  loadProblem(*m.getMatrixByRow(), m.getColLower(), m.getColUpper(),
    76457669    m.getObjCoefficients(), m.getRowLower(), m.getRowUpper());
     7670#endif
    76467671
    76477672  if (m.integerColumns()) {
  • stable/1.17/Clp/src/ClpSimplexDual.cpp

    r2385 r2449  
    14121412#endif
    14131413              //#define FEB_TRY
    1414 #if 1 //def FEB_TRY \
    1415   // Make safer?
     1414#if 1
     1415              // Make safer?
    14161416              factorization_->saferTolerances(-0.99, -1.03);
    14171417#endif
     
    19431943#endif
    19441944                  // Get rid of objective
    1945                   if ((specialOptions_ & 16384) == 0)
     1945                  if ((specialOptions_ & 16384) == 0 &&
     1946                      (moreSpecialOptions_ & 256) == 0)
    19461947                    objective_ = new ClpLinearObjective(NULL, numberColumns_);
    19471948                }
     
    19621963#endif
    19631964                  // Get rid of objective
    1964                   if ((specialOptions_ & 16384) == 0)
     1965                  if ((specialOptions_ & 16384) == 0 &&
     1966                      (moreSpecialOptions_ & 256) == 0)
    19651967                    objective_ = new ClpLinearObjective(NULL, numberColumns_);
    19661968                }
     
    46504652      const double *reducedCost;
    46514653      double tentativeTheta = 1.0e15;
    4652       double upperTheta = 1.0e31;
     4654      //double upperTheta = 1.0e31;
    46534655      bestPossible = 0.0;
    4654       double multiplier[] = { -1.0, 1.0 };
     4656      //double multiplier[] = { -1.0, 1.0 };
    46554657      double dualT = -dualTolerance_;
    46564658      int nSections = 2;
  • stable/1.17/Clp/src/ClpSimplexNonlinear.cpp

    r2438 r2449  
    20992099      //objTheta=-1.0; // so we fall through
    21002100    }
    2101     if (theta_ >= 1.0e30) // odd
    2102       ordinaryDj=true;
     2101    if (theta_ >= 1.0e30) { // odd
     2102      returnCode=2;
     2103      break;
     2104    }
    21032105    // See if we need to pivot
    21042106    if (theta_ == basicTheta || ordinaryDj) {
     
    23082310      longArray->clear();
    23092311      if (ordinaryDj) {
     2312        assert (sequenceIn_>=0);
    23102313        valueIn_ = solution_[sequenceIn_];
    23112314        dualIn_ = dj_[sequenceIn_];
  • stable/1.17/Clp/src/ClpSimplexPrimal.cpp

    r2385 r2449  
    32123212              << CoinMessageEol;
    32133213            setFlagged(sequenceIn_);
    3214 #if 1 //def FEB_TRY \
     3214#if 1 //def FEB_TRY
    32153215  // could do conditional reset of weights to get larger djs
    32163216            primalColumnPivot_->saveWeights(this, 6);
  • stable/1.17/Clp/src/ClpSolve.cpp

    r2438 r2449  
    35023502          model2->defaultFactorizationFrequency();
    35033503        }
    3504 #if 1 //ndef ABC_INHERIT //#if 1 \
     3504#if 1 //ndef ABC_INHERIT
    35053505  // throw some into basis
    35063506        if (!forceFixing) {
  • stable/1.17/Clp/src/ClpSolver.cpp

    r2390 r2449  
    24072407              }
    24082408              // Write solution header (suggested by Luigi Poderico)
    2409               double objValue = models[iModel].getObjValue() * models[iModel].getObjSense();
     2409              double objValue = models[iModel].getObjValue();
    24102410              int iStat = models[iModel].status();
    24112411              if (iStat == 0) {
    2412                 fprintf(fp, "optimal\n");
     2412                fprintf(fp, "Optimal");
    24132413              } else if (iStat == 1) {
    24142414                // infeasible
    2415                 fprintf(fp, "infeasible\n");
     2415                fprintf(fp, "Infeasible");
    24162416              } else if (iStat == 2) {
    24172417                // unbounded
    2418                 fprintf(fp, "unbounded\n");
     2418                fprintf(fp, "Unbounded");
    24192419              } else if (iStat == 3) {
    2420                 fprintf(fp, "stopped on iterations or time\n");
     2420                fprintf(fp, "Stopped on iterations or time");
    24212421              } else if (iStat == 4) {
    2422                 fprintf(fp, "stopped on difficulties\n");
     2422                fprintf(fp, "Stopped on difficulties");
    24232423              } else if (iStat == 5) {
    2424                 fprintf(fp, "stopped on ctrl-c\n");
     2424                fprintf(fp, "Stopped on ctrl-c");
    24252425              } else {
    2426                 fprintf(fp, "status unknown\n");
     2426                fprintf(fp, "Status unknown");
    24272427              }
    24282428              char printFormat[50];
    2429               sprintf(printFormat, "Objective value %s\n",
     2429              sprintf(printFormat, " - objective value %s\n",
    24302430                CLP_QUOTE(CLP_OUTPUT_FORMAT));
    24312431              fprintf(fp, printFormat, objValue);
  • stable/1.17/Clp/src/Clp_C_Interface.cpp

    r2385 r2449  
    264264    collb, colub, obj, rowlb, rowub);
    265265}
     266
    266267/* read quadratic part of the objective (the matrix part) */
    267268COINLIBAPI void COINLINKAGE
     
    284285  return model->model_->readMps(filename, keepNames != 0, ignoreErrors != 0);
    285286}
     287/* Write an MPS file to the given filename */
     288COINLIBAPI int COINLINKAGE
     289Clp_writeMps(Clp_Simplex *model, const char *filename,
     290  int formatType,
     291  int numberAcross,
     292  double objSense)
     293{
     294  return model->model_->writeMps(filename, formatType, numberAcross, objSense);
     295}
    286296/* Copy in integer informations */
    287297COINLIBAPI void COINLINKAGE
     
    364374{
    365375  model->model_->chgObjCoefficients(objIn);
     376}
     377/* Change matrix coefficients */
     378COINLIBAPI void COINLINKAGE
     379Clp_modifyCoefficient(Clp_Simplex *model, int row, int column, double newElement,
     380  bool keepZero)
     381{
     382  model->model_->modifyCoefficient(row, column, newElement, keepZero);
    366383}
    367384/* Drops names - makes lengthnames 0 and names empty */
     
    772789  std::string columnName = model->model_->columnName(iColumn);
    773790  strcpy(name, columnName.c_str());
     791}
     792
     793/** Set row name - Nice if they are short - 8 chars or less I think */
     794COINLIBAPI void COINLINKAGE Clp_setRowName(Clp_Simplex *model, int iRow, char *name)
     795{
     796  std::string sName = name; // Copies the memory AFAIK
     797  model->model_->setRowName(iRow, sName);
     798}
     799/** Set column name - Nice if they are short - 8 chars or less I think */
     800COINLIBAPI void COINLINKAGE Clp_setColumnName(Clp_Simplex *model, int iColumn, char *name)
     801{
     802  std::string sName = name; // Copies the memory AFAIK
     803  model->model_->setColumnName(iColumn, sName);
    774804}
    775805
  • stable/1.17/Clp/src/Clp_C_Interface.h

    r2385 r2449  
    104104  int keepNames,
    105105  int ignoreErrors);
     106/** Write an mps file to the given filename */
     107/** Format type is 0 = normal, 1 = extra or 2 = hex.
     108    Number across is 1 or 2.
     109    Use objSense = -1D to flip the objective function around. */
     110COINLIBAPI int COINLINKAGE Clp_writeMps(Clp_Simplex *model, const char *filename,
     111  int formatType,
     112  int numberAcross,
     113  double objSense);
    106114/** Copy in integer informations */
    107115COINLIBAPI void COINLINKAGE Clp_copyInIntegerInformation(Clp_Simplex *model, const char *information);
     
    136144/** Change objective coefficients */
    137145COINLIBAPI void COINLINKAGE Clp_chgObjCoefficients(Clp_Simplex *model, const double *objIn);
     146/** Change matrix coefficients */
     147COINLIBAPI void COINLINKAGE Clp_modifyCoefficient(Clp_Simplex *model, int row, int column, double newElement,
     148  bool keepZero);
    138149/** Drops names - makes lengthnames 0 and names empty */
    139150COINLIBAPI void COINLINKAGE Clp_dropNames(Clp_Simplex *model);
     
    294305/** Fill in array (at least lengthNames+1 long) with a column name */
    295306COINLIBAPI void COINLINKAGE Clp_columnName(Clp_Simplex *model, int iColumn, char *name);
     307/** Set row name - Nice if they are short - 8 chars or less I think */
     308COINLIBAPI void COINLINKAGE Clp_setRowName(Clp_Simplex *model, int iRow, char *name);
     309/** Set column name - Nice if they are short - 8 chars or less I think */
     310COINLIBAPI void COINLINKAGE Clp_setColumnName(Clp_Simplex *model, int iColumn, char *name);
    296311
    297312/*@}*/
  • stable/1.17/Clp/src/OsiClp

  • stable/1.17/Clp/src/OsiClp/OsiClpSolverInterface.cpp

    r2438 r2449  
    58095809  setObjName(m.getObjName());
    58105810
    5811   // no errors
     5811#ifndef SWITCH_BACK_TO_MAXIMIZATION
     5812#define SWITCH_BACK_TO_MAXIMIZATION 1
     5813#endif
     5814#if SWITCH_BACK_TO_MAXIMIZATION
     5815  double * originalObj = NULL;
     5816  if (m.wasMaximization()) {
     5817    // switch back
     5818    setDblParam(OsiObjOffset, -m.objectiveOffset());
     5819    int numberColumns = m.getNumCols();
     5820    originalObj = CoinCopyOfArray(m.getObjCoefficients(),numberColumns);
     5821    for (int i=0;i < numberColumns;i++)
     5822      originalObj[i] = - originalObj[i];
     5823    modelPtr_->setOptimizationDirection(-1.0);
     5824    handler_->message(COIN_GENERAL_INFO, messages_)
     5825      << "Switching back to maximization to get correct duals etc"
     5826      << CoinMessageEol;
     5827  }
     5828  loadProblem(*m.getMatrixByRow(), m.getColLower(), m.getColUpper(),
     5829              !originalObj ? m.getObjCoefficients() : originalObj,
     5830              m.getRowLower(), m.getRowUpper());
     5831  delete [] originalObj;
     5832#else
    58125833  loadProblem(*m.getMatrixByRow(), m.getColLower(), m.getColUpper(),
    58135834    m.getObjCoefficients(), m.getRowLower(), m.getRowUpper());
     5835#endif
    58145836
    58155837  char *integer = const_cast< char * >(m.integerColumns());
Note: See TracChangeset for help on using the changeset viewer.