Ignore:
Timestamp:
Mar 8, 2007 12:41:22 PM (13 years ago)
Author:
forrest
Message:

for bob

File:
1 edited

Legend:

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

    r487 r571  
    77
    88#include "CoinPragma.hpp"
    9 #include "CoinHelperFunctions.hpp"
    10 #include "CoinPackedMatrix.hpp"
     9//#include "CoinHelperFunctions.hpp"
     10//#include "CoinPackedMatrix.hpp"
    1111#include "CoinTime.hpp"
    1212
     
    1919//  bobe including extras.h to get strdup()
    2020#if defined(__MWERKS__)
    21 #include <extras.h>
     21// #include <extras.h>  // bobe 06-02-14
    2222#endif
    2323
     
    212212#endif
    213213
     214/* Version */
     215COINLIBAPI double COINLINKAGE Cbc_getVersion()
     216{
     217  double v = 1.0;
     218  return v;
     219}
     220
    214221/* Default Cbc_Model constructor */
    215222COINLIBAPI Cbc_Model *  COINLINKAGE
     
    217224{
    218225  const char prefix[] = "Cbc_C_Interface::Cbc_newModel(): ";
    219   // const int  VERBOSE = 1;
     226// const int  VERBOSE = 1;
    220227  if (VERBOSE>0) printf("%s begin\n",prefix);
    221228 
     
    236243{
    237244  const char prefix[] = "Cbc_C_Interface::Cbc_deleteModel(): ";
    238   // const int  VERBOSE = 1;
     245// const int  VERBOSE = 1;
    239246  if (VERBOSE>0) printf("%s begin\n",prefix); fflush(stdout);
    240247 
     
    327334Cbc_writeMps(Cbc_Model * model,const char *filename)
    328335{
    329   const char prefix[] = "Cbc_C_Interface::Cbc_readMps(): ";
     336  const char prefix[] = "Cbc_C_Interface::Cbc_writeMps(): ";
    330337//  const int  VERBOSE = 2;
    331338  if (VERBOSE>0) printf("%s begin\n",prefix);
     
    393400//    OsiClpSolverInterface::setContinuous
    394401//tbd  model->model_->deleteIntegerInformation();
    395   printf("%s ERROR: NOT IMPLEMENTED\n",prefix);
     402  if (VERBOSE>0) printf("%s WARNING: NOT IMPLEMENTED\n",prefix);
    396403
    397404  if (VERBOSE>0) printf("%s return\n",prefix);
     
    407414// cannot find this in Cbc, Osi, or OsiClp
    408415//tbd  model->model_->solver()->resize(newNumberRows,newNumberColumns);
    409   printf("%s ERROR: NOT IMPLEMENTED\n",prefix);
     416  if (VERBOSE>0) printf("%s WARNING: NOT IMPLEMENTED\n",prefix);
    410417
    411418  if (VERBOSE>0) printf("%s return\n",prefix);
     
    437444// available through OsiClp
    438445//tbd  model->model_->addRows(number,rowLower,rowUpper,rowStarts,columns,elements);
    439   printf("%s ERROR: NOT IMPLEMENTED\n",prefix);
     446  if (VERBOSE>0) printf("%s WARNING: NOT IMPLEMENTED\n",prefix);
    440447
    441448  if (VERBOSE>0) printf("%s return\n",prefix);
     
    470477//tbd  model->model_->addColumns(number,columnLower,columnUpper,objective,
    471478//tbd                       columnStarts,rows,elements);
    472   printf("%s ERROR: NOT IMPLEMENTED\n",prefix);
     479  if (VERBOSE>0) printf("%s WARNING: NOT IMPLEMENTED\n",prefix);
    473480
    474481  if (VERBOSE>0) printf("%s return\n",prefix);
     
    484491// cannot find names in Cbc, Osi, or OsiClp
    485492//tbd  model->model_->dropNames();
    486   printf("%s ERROR: NOT IMPLEMENTED\n",prefix);
     493  if (VERBOSE>0) printf("%s WARNING: NOT IMPLEMENTED\n",prefix);
    487494
    488495  if (VERBOSE>0) printf("%s return\n",prefix);
     
    659666// cannot find names in Cbc, Osi, or OsiClp
    660667//tbd  return model->model_->objectiveOffset();
    661   printf("%s ERROR: NOT IMPLEMENTED\n",prefix);
     668  if (VERBOSE>0) printf("%s WARNING: NOT IMPLEMENTED\n",prefix);
    662669
    663670  if (VERBOSE>0) printf("%s return %g\n",prefix,result);
     
    673680// cannot find names in Cbc, Osi, or OsiClp
    674681//tbd  model->model_->solver()->setObjectiveOffset(value);
    675   printf("%s ERROR: NOT IMPLEMENTED\n",prefix);
     682  if (VERBOSE>0) printf("%s WARNING: NOT IMPLEMENTED\n",prefix);
    676683
    677684  if (VERBOSE>0) printf("%s return\n",prefix);
     
    730737// cannot find this in Cbc, Osi, or OsiClp
    731738//tbd  model->model_->setNumberIterations(numberIterations);
    732   printf("%s ERROR: NOT IMPLEMENTED\n",prefix);
     739  if (VERBOSE>0) printf("%s WARNING: NOT IMPLEMENTED\n",prefix);
    733740
    734741  if (VERBOSE>0) printf("%s return\n",prefix);
     
    744751
    745752  int result = 0;
    746   model->model_->solver()->getIntParam(OsiMaxNumIteration,result);
     753// cannot find this in Cbc, Osi, or OsiClp
     754//tbd  result = model->model_->solver()->maximumIterations();
     755  if (VERBOSE>0) printf("%s WARNING: NOT IMPLEMENTED\n",prefix);
    747756
    748757  if (VERBOSE>0) printf("%s return %i\n",prefix,result);
     
    756765  if (VERBOSE>0) printf("%s begin\n",prefix);
    757766
    758   model->model_->solver()->setIntParam(OsiMaxNumIteration,value);
     767// cannot find this in Cbc, Osi, or OsiClp
     768//tbd  model->model_->setMaximumIterations(value);
     769  if (VERBOSE>0) printf("%s WARNING: NOT IMPLEMENTED\n",prefix);
    759770
    760771  if (VERBOSE>0) printf("%s return\n",prefix);
     
    846857// cannot find names in Cbc, Osi, or OsiClp
    847858//tbd  result = model->model_->solver()->hitMaximumIterations() ? 1 : 0;
    848   printf("%s ERROR: NOT IMPLEMENTED\n",prefix);
     859  if (VERBOSE>0) printf("%s WARNING: NOT IMPLEMENTED\n",prefix);
    849860
    850861  if (VERBOSE>0) printf("%s return %i\n",prefix,result);
     
    859870*/
    860871COINLIBAPI int COINLINKAGE
    861 Cbc_LPstatus(Cbc_Model * model)
    862 {
    863   const char prefix[] = "Cbc_C_Interface::Cbc_LPstatus(): ";
    864 //  const int  VERBOSE = 1;
    865   if (VERBOSE>0) printf("%s begin\n",prefix);
    866 
    867   int result = 0;
    868   OsiClpSolverInterface * solver  =  dynamic_cast< OsiClpSolverInterface*> (model->model_->solver());
    869   result = solver->getModelPtr()->status();
     872Cbc_status(Cbc_Model * model)
     873{
     874  const char prefix[] = "Cbc_C_Interface::Cbc_status(): ";
     875//  const int  VERBOSE = 1;
     876  if (VERBOSE>0) printf("%s begin\n",prefix);
     877
     878  int result = 0;
     879  result = model->model_->status();
    870880
    871881  if (VERBOSE>0) printf("%s return %i\n",prefix,result);
     
    874884/* Set problem status */
    875885COINLIBAPI void COINLINKAGE
    876 Cbc_setProblemLPStatus(Cbc_Model * model, int problemStatus)
    877 {
    878   const char prefix[] = "Cbc_C_Interface::Cbc_setLPProblemStatus(): ";
    879 //  const int  VERBOSE = 1;
    880   if (VERBOSE>0) printf("%s begin\n",prefix);
    881 
    882   OsiClpSolverInterface * solver  =  dynamic_cast< OsiClpSolverInterface*> (model->model_->solver());
    883   solver->getModelPtr()->setProblemStatus(problemStatus);
     886Cbc_setProblemStatus(Cbc_Model * model, int problemStatus)
     887{
     888  const char prefix[] = "Cbc_C_Interface::Cbc_setProblemStatus(): ";
     889//  const int  VERBOSE = 1;
     890  if (VERBOSE>0) printf("%s begin\n",prefix);
     891
     892// cannot find this in Cbc, Osi, or OsiClp
     893//tbd  model->model_->setProblemStatus(problemStatus);
     894  if (VERBOSE>0) printf("%s WARNING: NOT IMPLEMENTED\n",prefix);
    884895
    885896  if (VERBOSE>0) printf("%s return\n",prefix);
     
    893904*/
    894905COINLIBAPI int COINLINKAGE
    895 Cbc_secondaryLPStatus(Cbc_Model * model)
    896 {
    897   const char prefix[] = "Cbc_C_Interface::Cbc_secondaryLPStatus(): ";
    898 //  const int  VERBOSE = 1;
    899   if (VERBOSE>0) printf("%s begin\n",prefix);
    900 
    901   int result = 0;
    902   OsiClpSolverInterface * solver  =  dynamic_cast< OsiClpSolverInterface*> (model->model_->solver());
    903   result = solver->getModelPtr()->secondaryStatus();
    904 
    905   if (VERBOSE>0) printf("%s return %i\n",prefix,result);
    906   return result;
    907 }
    908 COINLIBAPI void COINLINKAGE
    909 Cbc_setSecondaryLPStatus(Cbc_Model * model, int status)
    910 {
    911   const char prefix[] = "Cbc_C_Interface::Cbc_setSecondaryLPStatus(): ";
    912 //  const int  VERBOSE = 1;
    913   if (VERBOSE>0) printf("%s begin\n",prefix);
    914 
    915   OsiClpSolverInterface * solver  =  dynamic_cast< OsiClpSolverInterface*> (model->model_->solver());
    916   solver->getModelPtr()->setSecondaryStatus(status);
    917 
    918   if (VERBOSE>0) printf("%s return\n",prefix);
    919 }
    920 /* Final status of BAB problem
    921    Some of these can be found out by is...... functions
    922    -1 before branchAndBound
    923    0 finished - check isProvenOptimal or isProvenInfeasible to see if solution found
    924    (or check value of best solution)
    925    1 stopped - on maxnodes, maxsols, maxtime
    926    2 difficulties so run was abandoned
    927    (5 event user programmed event occurred)
    928 */
    929 COINLIBAPI int COINLINKAGE
    930 Cbc_status(Cbc_Model * model)
    931 {
    932   const char prefix[] = "Cbc_C_Interface::Cbc_status(): ";
    933 //  const int  VERBOSE = 1;
    934   if (VERBOSE>0) printf("%s begin\n",prefix);
    935 
    936   int result = 0;
    937   result = model->model_->status();
    938 
    939   if (VERBOSE>0) printf("%s return %i\n",prefix,result);
    940   return result;
    941 }
    942 /* Set problem status */
    943 COINLIBAPI void COINLINKAGE
    944 Cbc_setProblemStatus(Cbc_Model * model, int problemStatus)
    945 {
    946   const char prefix[] = "Cbc_C_Interface::Cbc_setProblemStatus(): ";
    947 //  const int  VERBOSE = 1;
    948   if (VERBOSE>0) printf("%s begin\n",prefix);
    949 
    950   model->model_->setProblemStatus(problemStatus);
    951 
    952   if (VERBOSE>0) printf("%s return\n",prefix);
    953 }
    954 /* Secondary status of BAB problem
    955    -1 unset (status_ will also be -1)
    956    0 search completed with solution
    957    1 linear relaxation not feasible (or worse than cutoff)
    958    2 stopped on gap
    959    3 stopped on nodes
    960    4 stopped on time
    961    5 stopped on user event
    962    6 stopped on solutions
    963    7 linear relaxation unbounded
    964 */
    965 COINLIBAPI int COINLINKAGE
    966906Cbc_secondaryStatus(Cbc_Model * model)
    967907{
     
    971911
    972912  int result = 0;
    973   result = model->model_->secondaryStatus();
     913// cannot find this in Cbc, Osi, or OsiClp
     914//tbd  result = model->model_->secondaryStatus();
     915  if (VERBOSE>0) printf("%s WARNING: NOT IMPLEMENTED\n",prefix);
    974916
    975917  if (VERBOSE>0) printf("%s return %i\n",prefix,result);
     
    983925  if (VERBOSE>0) printf("%s begin\n",prefix);
    984926
    985   model->model_->setSecondaryStatus(status);
     927// cannot find this in Cbc, Osi, or OsiClp
     928//tbd  model->model_->setSecondaryStatus(status);
     929  if (VERBOSE>0) printf("%s WARNING: NOT IMPLEMENTED\n",prefix);
    986930
    987931  if (VERBOSE>0) printf("%s return\n",prefix);
     
    1006950  const char prefix[] = "Cbc_C_Interface::Cbc_setOptimizationDirection(): ";
    1007951//  const int  VERBOSE = 1;
    1008   if (VERBOSE>0) printf("%s begin\n",prefix);
     952  if (VERBOSE>0) printf("%s begin, value = %g\n",prefix,value);
    1009953
    1010954  model->model_->setObjSense(value);
     
    1026970// may have to make it somehow
    1027971//tbd  return model->model_->primalRowSolution();
    1028   printf("%s ERROR: NOT IMPLEMENTED\n",prefix);
     972  if (VERBOSE>0) printf("%s WARNING: NOT IMPLEMENTED\n",prefix);
    1029973
    1030974  if (VERBOSE>0) printf("%s return %p\n",prefix,result);
     
    1043987// may have to make it somehow
    1044988//  result = model->model_->getColSolution();
    1045   printf("%s ERROR: NOT IMPLEMENTED\n",prefix);
     989  if (VERBOSE>0) printf("%s WARNING: NOT IMPLEMENTED\n",prefix);
    1046990
    1047991  if (VERBOSE>0) printf("%s return %p\n",prefix,result);
     
    10601004// may have to make it somehow
    10611005//tbd  return model->model_->dualRowSolution();
    1062   printf("%s ERROR: NOT IMPLEMENTED\n",prefix);
     1006  if (VERBOSE>0) printf("%s WARNING: NOT IMPLEMENTED\n",prefix);
    10631007
    10641008  if (VERBOSE>0) printf("%s return %p\n",prefix,result);
     
    10771021// may have to make it somehow
    10781022//tbd  return model->model_->dualColumnSolution();
    1079   printf("%s ERROR: NOT IMPLEMENTED\n",prefix);
     1023  if (VERBOSE>0) printf("%s WARNING: NOT IMPLEMENTED\n",prefix);
    10801024
    10811025  if (VERBOSE>0) printf("%s return %p\n",prefix,result);
     
    10941038// may have to make it somehow
    10951039//tbd  return model->model_->rowLower();
    1096   printf("%s ERROR: NOT IMPLEMENTED\n",prefix);
     1040  if (VERBOSE>0) printf("%s WARNING: NOT IMPLEMENTED\n",prefix);
    10971041
    10981042  if (VERBOSE>0) printf("%s return %p\n",prefix,result);
     
    11111055// may have to make it somehow
    11121056//tbd  return model->model_->rowUpper();
    1113   printf("%s ERROR: NOT IMPLEMENTED\n",prefix);
     1057  if (VERBOSE>0) printf("%s WARNING: NOT IMPLEMENTED\n",prefix);
    11141058
    11151059  if (VERBOSE>0) printf("%s return %p\n",prefix,result);
     
    11281072// may have to make it somehow
    11291073//  result = model->model_->objective();
    1130   printf("%s ERROR: NOT IMPLEMENTED\n",prefix);
     1074  if (VERBOSE>0) printf("%s WARNING: NOT IMPLEMENTED\n",prefix);
    11311075
    11321076  if (VERBOSE>0) printf("%s return %p\n",prefix,result);
     
    11451089// may have to make it somehow
    11461090//tbd  return model->model_->columnLower();
    1147   printf("%s ERROR: NOT IMPLEMENTED\n",prefix);
     1091  if (VERBOSE>0) printf("%s WARNING: NOT IMPLEMENTED\n",prefix);
    11481092
    11491093  if (VERBOSE>0) printf("%s return %p\n",prefix,result);
     
    11621106// may have to make it somehow
    11631107//tbd  return model->model_->columnUpper();
    1164   printf("%s ERROR: NOT IMPLEMENTED\n",prefix);
     1108  if (VERBOSE>0) printf("%s WARNING: NOT IMPLEMENTED\n",prefix);
    11651109
    11661110  if (VERBOSE>0) printf("%s return %p\n",prefix,result);
     
    12691213  //
    12701214//tbd  result = model->model_->infeasibilityRay();
    1271   printf("%s ERROR: NOT IMPLEMENTED\n",prefix);
     1215  if (VERBOSE>0) printf("%s WARNING: NOT IMPLEMENTED\n",prefix);
    12721216
    12731217  if (VERBOSE>0) printf("%s return %p\n",prefix,result);
     
    12861230  //
    12871231//tbd  result = model->model_->unboundedRay();
    1288   printf("%s ERROR: NOT IMPLEMENTED\n",prefix);
     1232  if (VERBOSE>0) printf("%s WARNING: NOT IMPLEMENTED\n",prefix);
    12891233
    12901234  if (VERBOSE>0) printf("%s return %p\n",prefix,result);
     
    13011245  int result = 0;
    13021246//tbd  result = model->model_->statusExists() ? 1 : 0;
    1303   printf("%s ERROR: NOT IMPLEMENTED\n",prefix);
     1247  if (VERBOSE>0) printf("%s WARNING: NOT IMPLEMENTED\n",prefix);
    13041248
    13051249  if (VERBOSE>0) printf("%s return %i\n",prefix,result);
     
    13161260// have to figure this out
    13171261//tbd  model->model_->solver()->getBasisStatus(cstat, rstat);
    1318   printf("%s ERROR: NOT IMPLEMENTED\n",prefix);
     1262  if (VERBOSE>0) printf("%s WARNING: NOT IMPLEMENTED\n",prefix);
    13191263
    13201264  if (VERBOSE>0) printf("%s return\n",prefix);
     
    13301274
    13311275//  model->model_->solver()->setBasisStatus(cstat, rstat);
    1332   printf("%s ERROR: NOT IMPLEMENTED\n",prefix);
     1276  if (VERBOSE>0) printf("%s WARNING: NOT IMPLEMENTED\n",prefix);
    13331277
    13341278  if (VERBOSE>0) printf("%s return\n",prefix);
     
    13461290  //
    13471291//tbd  model->model_->setUserPointer(pointer);
    1348   printf("%s ERROR: NOT IMPLEMENTED\n",prefix);
     1292  if (VERBOSE>0) printf("%s WARNING: NOT IMPLEMENTED\n",prefix);
    13491293
    13501294  if (VERBOSE>0) printf("%s return\n",prefix);
     
    13611305  //
    13621306//tbd result = model->model_->getUserPointer();
    1363   printf("%s ERROR: NOT IMPLEMENTED\n",prefix);
     1307  if (VERBOSE>0) printf("%s WARNING: NOT IMPLEMENTED\n",prefix);
    13641308
    13651309  if (VERBOSE>0) printf("%s return %p\n",prefix,result);
     
    14091353{
    14101354  const char prefix[] = "Cbc_C_Interface::Cbc_setLogLevel(): ";
    1411 //  const int  VERBOSE = 2;
     1355//  const int  VERBOSE = 1;
    14121356  if (VERBOSE>0) printf("%s begin\n",prefix);
    14131357  if (VERBOSE>1) printf("%s value = %i\n",prefix, value);
     
    14411385// cannot find names in Cbc, Osi, or OsiClp
    14421386//tbd  result = model->model_->lengthNames();
    1443   printf("%s ERROR: NOT IMPLEMENTED\n",prefix);
     1387  if (VERBOSE>0) printf("%s WARNING: NOT IMPLEMENTED\n",prefix);
    14441388
    14451389  if (VERBOSE>0) printf("%s return %i\n",prefix,result);
     
    15081452  try {
    15091453    model->model_->branchAndBound();
     1454    model->model_->solver()->resolve();
    15101455  } catch (CoinError e) {
    15111456    printf("%s ERROR: %s::%s, %s\n", prefix,
     
    15411486// try to use OsiSolverInterface::getHintParam(OsiDoScale, ???)
    15421487//tbd  result = model->model_->scalingFlag();
    1543   printf("%s ERROR: NOT IMPLEMENTED\n",prefix);
     1488  if (VERBOSE>0) printf("%s WARNING: NOT IMPLEMENTED\n",prefix);
    15441489
    15451490  if (VERBOSE>0) printf("%s return %i\n",prefix,result);
     
    15701515// cannot find names in Cbc, Osi, or OsiClp
    15711516//tbd  result = model->model_->crash(gap,pivot);
    1572   printf("%s ERROR: NOT IMPLEMENTED\n",prefix);
     1517  if (VERBOSE>0) printf("%s WARNING: NOT IMPLEMENTED\n",prefix);
    15731518
    15741519  if (VERBOSE>0) printf("%s return %i\n",prefix,result);
     
    16161561// cannot find in Cbc, Osi, or OsiClp
    16171562//tbd  result = model->model_->dualBound();
    1618   printf("%s ERROR: NOT IMPLEMENTED\n",prefix);
     1563  if (VERBOSE>0) printf("%s WARNING: NOT IMPLEMENTED\n",prefix);
    16191564
    16201565  if (VERBOSE>0) printf("%s return %g\n",prefix,result);
     
    16301575// cannot find names in Cbc, Osi, or OsiClp
    16311576//tbd  model->model_->setDualBound(value);
    1632   printf("%s ERROR: NOT IMPLEMENTED\n",prefix);
     1577  if (VERBOSE>0) printf("%s WARNING: NOT IMPLEMENTED\n",prefix);
    16331578
    16341579  if (VERBOSE>0) printf("%s return\n",prefix);
     
    16451590// cannot find names in Cbc, Osi, or OsiClp
    16461591//tbd  result = model->model_->solver()->infeasibilityCost();
    1647   printf("%s ERROR: NOT IMPLEMENTED\n",prefix);
     1592  if (VERBOSE>0) printf("%s WARNING: NOT IMPLEMENTED\n",prefix);
    16481593
    16491594  if (VERBOSE>0) printf("%s return %g\n",prefix,result);
     
    16591604// cannot find names in Cbc, Osi, or OsiClp
    16601605//tbd  model->model_->setInfeasibilityCost(value);
    1661   printf("%s ERROR: NOT IMPLEMENTED\n",prefix);
     1606  if (VERBOSE>0) printf("%s WARNING: NOT IMPLEMENTED\n",prefix);
    16621607
    16631608  if (VERBOSE>0) printf("%s return\n",prefix);
     
    16811626// cannot find names in Cbc, Osi, or OsiClp
    16821627//tbd  result = model->model_->perturbation();
    1683   printf("%s ERROR: NOT IMPLEMENTED\n",prefix);
     1628  if (VERBOSE>0) printf("%s WARNING: NOT IMPLEMENTED\n",prefix);
    16841629
    16851630  if (VERBOSE>0) printf("%s return %i\n",prefix,result);
     
    16951640// cannot find names in Cbc, Osi, or OsiClp
    16961641//tbd  model->model_->setPerturbation(value);
    1697   printf("%s ERROR: NOT IMPLEMENTED\n",prefix);
     1642  if (VERBOSE>0) printf("%s WARNING: NOT IMPLEMENTED\n",prefix);
    16981643
    16991644  if (VERBOSE>0) printf("%s return\n",prefix);
     
    17101655// cannot find names in Cbc, Osi, or OsiClp
    17111656//tbd  result = model->model_->algorithm();
    1712   printf("%s ERROR: NOT IMPLEMENTED\n",prefix);
     1657  if (VERBOSE>0) printf("%s WARNING: NOT IMPLEMENTED\n",prefix);
    17131658
    17141659  if (VERBOSE>0) printf("%s return %i\n",prefix,result);
     
    17251670// cannot find names in Cbc, Osi, or OsiClp
    17261671//tbd  model->model_->setAlgorithm(value);
    1727   printf("%s ERROR: NOT IMPLEMENTED\n",prefix);
     1672  if (VERBOSE>0) printf("%s WARNING: NOT IMPLEMENTED\n",prefix);
    17281673
    17291674  if (VERBOSE>0) printf("%s return\n",prefix);
     
    17401685// cannot find names in Cbc, Osi, or OsiClp
    17411686//tbd  result = model->model_->sumDualInfeasibilities();
    1742   printf("%s ERROR: NOT IMPLEMENTED\n",prefix);
     1687  if (VERBOSE>0) printf("%s WARNING: NOT IMPLEMENTED\n",prefix);
    17431688
    17441689  if (VERBOSE>0) printf("%s return %g\n",prefix,result);
     
    17561701// cannot find names in Cbc, Osi, or OsiClp
    17571702//tbd  result = model->model_->numberDualInfeasibilities();
    1758   printf("%s ERROR: NOT IMPLEMENTED\n",prefix);
     1703  if (VERBOSE>0) printf("%s WARNING: NOT IMPLEMENTED\n",prefix);
    17591704
    17601705  if (VERBOSE>0) printf("%s return %i\n",prefix,result);
     
    17721717// cannot find names in Cbc, Osi, or OsiClp
    17731718//tbd result = model->model_->sumPrimalInfeasibilities();
    1774   printf("%s ERROR: NOT IMPLEMENTED\n",prefix);
     1719  if (VERBOSE>0) printf("%s WARNING: NOT IMPLEMENTED\n",prefix);
    17751720
    17761721  if (VERBOSE>0) printf("%s return %g\n",prefix,result);
     
    17871732  int result = 0;
    17881733//tbd  result = model->model_->getContinuousInfeasibilities();
    1789   printf("%s ERROR: NOT IMPLEMENTED\n",prefix);
     1734  if (VERBOSE>0) printf("%s WARNING: NOT IMPLEMENTED\n",prefix);
    17901735
    17911736  if (VERBOSE>0) printf("%s return %i\n",prefix,result);
     
    18081753// there is a writeMPS method in Osi
    18091754//tbd  result = model->model_->saveModel(fileName);
    1810   printf("%s ERROR: NOT IMPLEMENTED\n",prefix);
     1755  if (VERBOSE>0) printf("%s WARNING: NOT IMPLEMENTED\n",prefix);
    18111756
    18121757  if (VERBOSE>0) printf("%s return %i\n",prefix,result);
     
    18251770// there is a readMPS method in Osi
    18261771//tbd  result = model->model_->restoreModel(fileName);
    1827   printf("%s ERROR: NOT IMPLEMENTED\n",prefix);
     1772  if (VERBOSE>0) printf("%s WARNING: NOT IMPLEMENTED\n",prefix);
    18281773
    18291774  if (VERBOSE>0) printf("%s return %i\n",prefix,result);
     
    22592204{
    22602205  const char prefix[] = "Cbc_C_Interface::Cbc_clone(): ";
    2261   // const int  VERBOSE = 1;
     2206  const int  VERBOSE = 1;
    22622207  if (VERBOSE>0) printf("%s begin\n",prefix);
    22632208 
    22642209  Cbc_Model * result = new Cbc_Model;
    22652210  result->model_     = new CbcModel(*(model->model_));
    2266   result->solver_    =  dynamic_cast< OsiClpSolverInterface*> (result->model_->solver());
     2211  result->solver_    = dynamic_cast< OsiClpSolverInterface*> (result->model_->solver());
    22672212  result->handler_   = NULL;
    22682213
     
    22972242/* Add an SOS constraint to the model */
    22982243COINLIBAPI void  COINLINKAGE
    2299 Cbc_addSOS(Cbc_Model * model, int numberMembers,
    2300            const int * which, const double * weights, int identifier, int type)
    2301 {
    2302   const char prefix[] = "Cbc_C_Interface::Cbc_addSOS(): ";
    2303 //  const int  VERBOSE = 2;
    2304   if (VERBOSE>0) printf("%s begin\n",prefix);
    2305   if (VERBOSE>1) {
    2306     int i;
    2307     printf("%s numberMembers = %i, identifier = %i, type = %i\n",
    2308       prefix,numberMembers, identifier, type); fflush(stdout);
    2309     for (i=0;i<numberMembers;i++)
    2310       printf("%s which[%i] = %d, weights[%i] = %g\n",
    2311         prefix, i, which[i], i, weights[i]); fflush(stdout);
    2312   }
    2313  
    2314   CbcObject ** objects = new CbcObject * [1];
    2315   if (VERBOSE>1) printf("%s new CbcSOS()\n",prefix);
    2316   objects[0] = new CbcSOS(model->model_,numberMembers,which,weights,identifier,type);
    2317   if (objects[0] == NULL) {
    2318     printf("%s ERROR: objects[0] == NULL\n",prefix); fflush(stdout);
    2319     assert(objects[0] != NULL);
     2244Cbc_addSOS_Dense(Cbc_Model * model, int numObjects, const int * len,
     2245           const int ** which, const double * weights, const int type)
     2246{
     2247  const char prefix[] = "Cbc_C_Interface::Cbc_addSOS_Dense(): ";
     2248  const int  VERBOSE = 2;
     2249  if (VERBOSE>0) printf("%sbegin\n",prefix);
     2250 
     2251  assert(1>0);// this is probably broken
     2252  int i,j,l;
     2253  const int *w;
     2254  // I think this is a different model due to overriding = operator
     2255  CbcModel m = *(model->model_);
     2256 
     2257  CbcObject ** objects = new CbcObject * [numObjects];
     2258
     2259  if (VERBOSE>1) printf("%s numObjects = %i\n",prefix,numObjects);
     2260  for (i=0;i<numObjects;i++) {
     2261    if (VERBOSE>1) {
     2262      printf("%s len[%i] = %i, identifier = %i, type = %i\n",
     2263        prefix,i,len[i], i, type);
     2264      fflush(stdout);
     2265      for (j=0;j<len[i];j++) {
     2266        if (VERBOSE>2 || j==0 || j==(len[i]-1)) {
     2267          printf("%s which[%i][%i] = %d, weights[%i] = %g\n",
     2268            prefix, i,j, which[i][j], j, weights[j]);
     2269          fflush(stdout);
     2270        }
     2271      }
     2272    }
     2273   
     2274    // Make a CbcSOS and assign it to objects
     2275    printf("%s len[%i] = %i\n",prefix, i, len[i]);
     2276    l = len[i];
     2277    w = which[i];
     2278    if (VERBOSE>1) printf("%s new CbcSOS()\n",prefix);
     2279    // ***
     2280    objects[i] = new CbcSOS(model->model_, (int)(len[i]),
     2281      (const int*)which[i], (const double*)weights, (int)i, (int)type);
     2282    // ***
     2283    if (objects[i] == NULL) {
     2284      printf("%s ERROR: objects[%i] == NULL\n",prefix,i); fflush(stdout);
     2285      assert(objects[i] != NULL);
     2286    }
    23202287  }
    23212288  if (VERBOSE>1) printf("%s calling addObjects()\n",prefix);
    23222289  fflush(stdout);
    2323   model->model_->addObjects(1, objects);
     2290  model->model_->addObjects(numObjects, objects);
    23242291  if (VERBOSE>1) printf("%s finished addObjects()\n",prefix);
    2325   delete objects[0];
     2292 
     2293  for (i=0;i<numObjects;i++) delete objects[i];
    23262294  delete [] objects;
    23272295
    2328   if (VERBOSE>0) printf("%s return\n",prefix);
     2296  if (VERBOSE>0) printf("%sreturn\n",prefix);
    23292297  return;
    23302298}
     2299/* Add SOS constraints to the model using row-order matrix */
     2300COINLIBAPI void  COINLINKAGE
     2301Cbc_addSOS_Sparse(Cbc_Model * model, const int * rowStarts,
     2302           const int * rowIndices, const double * weights, const int type)
     2303{
     2304  const char prefix[] = "Cbc_C_Interface::Cbc_addSOS_Sparse(): ";
     2305//  const int  VERBOSE = 1;
     2306  if (VERBOSE>0) printf("%sbegin\n",prefix);
     2307 
     2308  int numRows = Cbc_numberRows(model);
     2309  if (VERBOSE>0) printf("%s numRows = %i\n",prefix,numRows);
     2310 
     2311  // The passed sparse matrix must have the same number of rows as the model
     2312  assert(numRows==Cbc_numberRows(model));
     2313 
     2314  int row, i;
     2315  const int *colIndex;
     2316  const double *colWeight;
     2317 
     2318  // loop on rows and count number of objects according to numWeights>0
     2319  int numObjects = 0;
     2320  for (row=0; row<numRows; row++) {
     2321    if (VERBOSE>2) {
     2322      printf("%s row = %i\n",prefix,row);
     2323      printf("%s rowStarts[%i] = %i\n",prefix,row,rowStarts[row]);
     2324      printf("%s rowStarts[%i+1] = %i\n",prefix,row,rowStarts[row+1]);
     2325      fflush(stdout);
     2326    }
     2327    const int numWeights = rowStarts[row+1]-rowStarts[row];
     2328    if (VERBOSE>2) printf("%s  numWeights = %i\n",prefix,numWeights);
     2329    if (numWeights>0) numObjects++;   
     2330  }
     2331 
     2332  // make objects
     2333  CbcObject ** objects = new CbcObject * [numObjects];
     2334//  if (VERBOSE>1) printf("%s numObjects = %i, objects = %X\n",prefix,numObjects,objects);
     2335
     2336  // loop on rows and make an object when numWeights>0
     2337  int objNum = 0;
     2338  for (row=0; row<numRows; row++) {
     2339    if (VERBOSE>2) {
     2340      printf("%s row = %i\n",prefix,row);
     2341      printf("%s rowStarts[%i] = %i\n",prefix,row,rowStarts[row]);
     2342      printf("%s rowStarts[%i+1] = %i\n",prefix,row,rowStarts[row+1]);
     2343    }
     2344    const int numWeights = rowStarts[row+1]-rowStarts[row];
     2345    if (VERBOSE>2) printf("%s  numWeights = %i\n",prefix,numWeights);
     2346    colIndex    = rowIndices+rowStarts[row];
     2347    colWeight   = weights+rowStarts[row];
     2348    if (numWeights>0) {
     2349      // Make a CbcSOS and assign it to objects
     2350      if (VERBOSE>3) {
     2351        for (i=0;i<numWeights;i++) {
     2352          printf("%s  colIndex [%i] = %i\n",prefix,i,colIndex[i]);
     2353          printf("%s  colWeight[%i] = %f\n",prefix,i,colWeight[i]);
     2354        }
     2355        fflush(stdout);
     2356      }
     2357      objects[objNum] = new CbcSOS(model->model_, (int)(numWeights),
     2358        (const int*)colIndex, (const double*)colWeight, (int)objNum, (int)type);
     2359//      if (VERBOSE>2) printf("%s objects[%i] = %X\n",prefix,objNum,objects[objNum]);
     2360      if (objects[objNum] == NULL) {
     2361        printf("%s ERROR: objects[%i] == NULL\n",prefix,objNum); fflush(stdout);
     2362        assert(objects[objNum] != NULL);
     2363      }
     2364      objNum++;
     2365    }
     2366  }
     2367  if (VERBOSE>2) {
     2368    printf("%s calling addObjects()\n",prefix);
     2369/*
     2370    printf("%s numObjects = %i, objects = %X\n",prefix,numObjects,objects);
     2371    for (row=0; row<numObjects; row++)
     2372      printf("%s  objects[%i] = %X\n",prefix,row,objects[row]);   
     2373*/   
     2374  }
     2375  fflush(stdout);
     2376  model->model_->addObjects(numObjects, objects);
     2377  if (VERBOSE>1) printf("%s finished addObjects()\n",prefix);
     2378 
     2379  for (objNum=0;objNum<numObjects;objNum++) delete objects[objNum];
     2380  delete [] objects;
     2381
     2382  if (VERBOSE>0) printf("%sreturn\n",prefix);
     2383  return;
     2384}
     2385
    23312386/* Print the solution */
    23322387COINLIBAPI void  COINLINKAGE
Note: See TracChangeset for help on using the changeset viewer.