source: stable/2.4/Cbc/src/Cbc_C_Interface.cpp @ 1271

Last change on this file since 1271 was 1271, checked in by forrest, 10 years ago

Creating new stable branch 2.4 from trunk (rev 1270)

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 77.2 KB
Line 
1// Copyright (C) 2004, International Business Machines
2// Corporation and others.  All Rights Reserved.
3
4
5#include <math.h>
6#include <cfloat>
7
8#include "CoinPragma.hpp"
9//#include "CoinHelperFunctions.hpp"
10//#include "CoinPackedMatrix.hpp"
11#include "CoinTime.hpp"
12
13#include "CbcModel.hpp"
14#include "CbcBranchActual.hpp"
15
16#include "CoinMessageHandler.hpp"
17#include "OsiClpSolverInterface.hpp"
18
19//  bobe including extras.h to get strdup()
20#if defined(__MWERKS__)
21// #include <extras.h>  // bobe 06-02-14
22#endif
23
24// Get C stuff but with extern C
25#define CBC_EXTERN_C
26#include "Coin_C_defines.h"
27
28const int  VERBOSE = 0;
29
30// To allow call backs
31class Cbc_MessageHandler 
32 : public CoinMessageHandler
33  {
34 
35public:
36  /**@name Overrides */
37  //@{
38  virtual int print();
39  //@}
40  /**@name set and get */
41  //@{
42  /// Model
43  const Cbc_Model * model() const;
44  void setModel(Cbc_Model * model);
45  /// Call back
46  void setCallBack(cbc_callback callback);
47  //@}
48
49  /**@name Constructors, destructor */
50  //@{
51  /** Default constructor. */
52  Cbc_MessageHandler();
53  /// Constructor with pointer to model
54  Cbc_MessageHandler(Cbc_Model * model,
55         FILE * userPointer=NULL);
56  /** Destructor */
57  virtual ~Cbc_MessageHandler();
58  //@}
59
60  /**@name Copy method */
61  //@{
62  /** The copy constructor. */
63  Cbc_MessageHandler(const Cbc_MessageHandler&);
64  /** The copy constructor from an CoinSimplexMessageHandler. */
65  Cbc_MessageHandler(const CoinMessageHandler&);
66 
67  Cbc_MessageHandler& operator=(const Cbc_MessageHandler&);
68  /// Clone
69  virtual CoinMessageHandler * clone() const ;
70  //@}
71   
72   
73protected:
74  /**@name Data members
75     The data members are protected to allow access for derived classes. */
76  //@{
77  /// Pointer back to model
78  Cbc_Model * model_;
79  /// call back
80  cbc_callback callback_;
81  //@}
82};
83
84
85//-------------------------------------------------------------------
86// Default Constructor
87//-------------------------------------------------------------------
88Cbc_MessageHandler::Cbc_MessageHandler () 
89  : CoinMessageHandler(),
90    model_(NULL),
91    callback_(NULL)
92{
93}
94
95//-------------------------------------------------------------------
96// Copy constructor
97//-------------------------------------------------------------------
98Cbc_MessageHandler::Cbc_MessageHandler (const Cbc_MessageHandler & rhs) 
99 : CoinMessageHandler(rhs),
100    model_(rhs.model_),
101    callback_(rhs.callback_)
102{ 
103}
104
105Cbc_MessageHandler::Cbc_MessageHandler (const CoinMessageHandler & rhs) 
106  : CoinMessageHandler(rhs),
107    model_(NULL),
108    callback_(NULL)
109{ 
110}
111
112// Constructor with pointer to model
113Cbc_MessageHandler::Cbc_MessageHandler(Cbc_Model * model,
114                                       FILE * /*userPointer*/)
115  : CoinMessageHandler(),
116    model_(model),
117    callback_(NULL)
118{
119}
120
121//-------------------------------------------------------------------
122// Destructor
123//-------------------------------------------------------------------
124Cbc_MessageHandler::~Cbc_MessageHandler ()
125{
126}
127
128//----------------------------------------------------------------
129// Assignment operator
130//-------------------------------------------------------------------
131Cbc_MessageHandler &
132Cbc_MessageHandler::operator=(const Cbc_MessageHandler& rhs)
133{
134  if (this != &rhs) {
135    CoinMessageHandler::operator=(rhs);
136    model_ = rhs.model_;
137    callback_ = rhs.callback_;
138  }
139  return *this;
140}
141//-------------------------------------------------------------------
142// Clone
143//-------------------------------------------------------------------
144CoinMessageHandler * Cbc_MessageHandler::clone() const
145{
146  return new Cbc_MessageHandler(*this);
147}
148int 
149Cbc_MessageHandler::print()
150{
151  if (callback_) {
152    int messageNumber = currentMessage().externalNumber();
153    if (currentSource()!="Cbc")
154      messageNumber += 1000000;
155    int i;
156    int nDouble=numberDoubleFields();
157    assert (nDouble<=200);
158    double vDouble[200];
159    for (i=0;i<nDouble;i++)
160      vDouble[i]=doubleValue(i);
161    int nInt=numberIntFields();
162    assert (nInt<=200);
163    int vInt[200];
164    for (i=0;i<nInt;i++)
165      vInt[i]=intValue(i);
166    int nString=numberStringFields();
167    assert (nString<=200);
168    char * vString[200];
169    for (i=0;i<nString;i++) {
170      std::string value = stringValue(i);
171      vString[i]=strdup(value.c_str());
172    }
173    callback_(model_,messageNumber,
174        nDouble,vDouble,
175        nInt,vInt,
176        nString,vString);
177    for (i=0;i<nString;i++) 
178      free(vString[i]);
179   
180  }
181  return CoinMessageHandler::print();
182  return 0;
183}
184const Cbc_Model *
185Cbc_MessageHandler::model() const
186{
187  return model_;
188}
189void 
190Cbc_MessageHandler::setModel(Cbc_Model * model)
191{
192  model_ = model;
193}
194// Call back
195void 
196Cbc_MessageHandler::setCallBack(cbc_callback callback)
197{
198  callback_ = callback;
199}
200/**
201  *
202  *  C Interface Routines
203  *
204  */
205#include "Cbc_C_Interface.h"
206#include <string>
207#include <stdio.h>
208#include <iostream>
209
210#if defined(__MWERKS__)
211#pragma export on
212#endif
213
214/* Version */
215COINLIBAPI double COINLINKAGE Cbc_getVersion()
216{
217  double v = 1.0;
218  return v;
219}
220
221/* Default Cbc_Model constructor */
222COINLIBAPI Cbc_Model *  COINLINKAGE
223Cbc_newModel()
224{
225  const char prefix[] = "Cbc_C_Interface::Cbc_newModel(): ";
226//  const int  VERBOSE = 1;
227  if (VERBOSE>0) printf("%s begin\n",prefix);
228 
229  Cbc_Model * model = new Cbc_Model;
230  OsiClpSolverInterface solver1;
231  model->solver_    = &solver1;
232  model->solver_->OsiClpSolverInterface::setHintParam(OsiDoReducePrint,true,OsiHintTry);
233  model->model_     = new CbcModel(solver1);
234  model->handler_   = NULL;
235  model->information_ = NULL;
236 
237  if (VERBOSE>0) printf("%s return\n",prefix);
238  return model;
239}
240/* Cbc_Model Destructor */
241COINLIBAPI void COINLINKAGE
242Cbc_deleteModel(Cbc_Model * model)
243{
244  const char prefix[] = "Cbc_C_Interface::Cbc_deleteModel(): ";
245//  const int  VERBOSE = 1;
246  if (VERBOSE>0) printf("%s begin\n",prefix); fflush(stdout);
247 
248  if (VERBOSE>1) printf("%s delete model->model_\n",prefix); fflush(stdout);
249  delete model->model_;
250 
251  if (VERBOSE>1) printf("%s delete model->handler_\n",prefix); fflush(stdout);
252  delete model->handler_;
253 
254  if (VERBOSE>1) printf("%s free model->information_\n",prefix); fflush(stdout);
255  if (model->information_) free(model->information_);
256 
257  if (VERBOSE>1) printf("%s delete model\n",prefix); fflush(stdout);
258  delete model;
259
260  if (VERBOSE>0) printf("%s return\n",prefix); fflush(stdout);
261}
262
263/* Loads a problem (the constraints on the
264    rows are given by lower and upper bounds). If a pointer is NULL then the
265    following values are the default:
266    <ul>
267    <li> <code>colub</code>: all columns have upper bound infinity
268    <li> <code>collb</code>: all columns have lower bound 0
269    <li> <code>rowub</code>: all rows have upper bound infinity
270    <li> <code>rowlb</code>: all rows have lower bound -infinity
271    <li> <code>obj</code>: all variables have 0 objective coefficient
272    </ul>
273
274   Just like the other loadProblem() method except that the matrix is
275   given in a standard column major ordered format (without gaps).
276*/
277COINLIBAPI void COINLINKAGE
278Cbc_loadProblem (Cbc_Model * model,  const int numcols, const int numrows,
279     const CoinBigIndex * start, const int* index,
280     const double* value,
281     const double* collb, const double* colub,   
282     const double* obj,
283     const double* rowlb, const double* rowub)
284{
285  const char prefix[] = "Cbc_C_Interface::Cbc_loadProblem(): ";
286//  const int  VERBOSE = 2;
287  if (VERBOSE>0) printf("%s begin\n",prefix);
288
289  OsiSolverInterface * solver = model->model_->solver();
290
291  if (VERBOSE>1) {
292    printf("%s numcols = %i, numrows = %i\n", 
293      prefix, numcols, numrows);
294    printf("%s model = %p, start = %p, index = %p, value = %p\n",
295      prefix, static_cast<void*>(model), static_cast<const void*>(start),
296           static_cast<const void*>(index), static_cast<const void*>(value));
297    printf("%s collb = %p, colub = %p, obj = %p, rowlb = %p, rowub = %p\n",
298      prefix, static_cast<const void*>(collb),
299           static_cast<const void*>(colub), static_cast<const void*>(obj),
300           static_cast<const void*>(rowlb), static_cast<const void*>(rowub));
301  }
302
303  if (VERBOSE>1) printf("%s Calling solver->loadProblem()\n",prefix);
304  fflush(stdout);
305 
306  if (1) {
307    solver->loadProblem(numcols,numrows,start,index,value,
308             collb,colub,obj,rowlb,rowub);
309  } else {
310    solver->loadProblem(0,0,NULL,NULL,NULL,
311             NULL,NULL,NULL,NULL,NULL);
312  }
313  if (VERBOSE > 1) printf("%s Finished solver->loadProblem()\n",prefix);
314  fflush(stdout);
315
316  if (VERBOSE>0) printf("%s return\n",prefix);
317} //  Cbc_loadProblem()
318
319/* Read an mps file from the given filename */
320COINLIBAPI int COINLINKAGE
321Cbc_readMps(Cbc_Model * model,const char *filename)
322{
323  const char prefix[] = "Cbc_C_Interface::Cbc_readMps(): ";
324//  const int  VERBOSE = 2;
325  if (VERBOSE>0) printf("%s begin\n",prefix);
326  if (VERBOSE>1) printf("%s filename = '%s'\n",prefix,filename);
327
328  int result = 1;
329  result = model->model_->solver()->readMps(filename);
330  assert(result==0);
331
332  if (VERBOSE>0) printf("%s return %i\n",prefix, result);
333  return result;
334}
335/* Write an mps file from the given filename */
336COINLIBAPI void COINLINKAGE
337Cbc_writeMps(Cbc_Model * model,const char *filename)
338{
339  const char prefix[] = "Cbc_C_Interface::Cbc_writeMps(): ";
340//  const int  VERBOSE = 2;
341  if (VERBOSE>0) printf("%s begin\n",prefix);
342  if (VERBOSE>1) printf("%s filename = '%s'\n",prefix,filename);
343
344  model->model_->solver()->writeMps(filename,"mps",Cbc_optimizationDirection(model));
345
346  if (VERBOSE>0) printf("%s return\n",prefix);
347  return;
348}
349/* Integer information */
350COINLIBAPI char * COINLINKAGE
351Cbc_integerInformation(Cbc_Model * model)
352{
353  const char prefix[] = "Cbc_C_Interface::Cbc_integerInformation(): ";
354//  const int  VERBOSE = 1;
355  if (VERBOSE>0) printf("%s begin\n",prefix);
356
357  int col;
358  int numcols = Cbc_getNumCols(model);
359
360  // allocate model->information_ if null
361  // this is freed in Cbc_deleteModel() if not null
362  if (!model->information_) 
363    model->information_ = (char *) malloc(numcols*sizeof(char));
364
365  for (col=0; col<numcols; col++) 
366    if (model->model_->solver()->isContinuous(col)) 
367      model->information_[col] = 0;
368    else
369      model->information_[col] = 1;
370
371  char * result = model->information_;
372
373  if (VERBOSE>0) printf("%s return %p\n",prefix,result);
374  return result;
375}
376/* Copy in integer information */
377COINLIBAPI void COINLINKAGE
378Cbc_copyInIntegerInformation(Cbc_Model * model, const char * information)
379{
380  const char prefix[] = "Cbc_C_Interface::Cbc_copyInIntegerInformation(): ";
381//  const int  VERBOSE = 1;
382  if (VERBOSE>0) printf("%s begin\n",prefix);
383
384  int col;
385  int numcols = Cbc_getNumCols(model);
386  for (col=0; col<numcols; col++) 
387    if (information[col]) 
388      model->model_->solver()->setInteger(col);
389    else
390      model->model_->solver()->setContinuous(col);
391 
392  if (VERBOSE>0) printf("%s return\n",prefix);
393}
394/* Drop integer informations */
395COINLIBAPI void COINLINKAGE
396Cbc_deleteIntegerInformation(Cbc_Model * /*model*/)
397{
398  const char prefix[] = "Cbc_C_Interface::Cbc_deleteIntegerInformation(): ";
399//  const int  VERBOSE = 1;
400  if (VERBOSE>0) printf("%s begin\n",prefix);
401
402//  available through
403//    OsiClpSolverInterface::setContinuous
404//tbd  model->model_->deleteIntegerInformation();
405  if (VERBOSE>0) printf("%s WARNING: NOT IMPLEMENTED\n",prefix);
406
407  if (VERBOSE>0) printf("%s return\n",prefix);
408}
409/* Resizes rim part of model  */
410COINLIBAPI void COINLINKAGE
411Cbc_resize (Cbc_Model * /*model*/, int /*newNumberRows*/, 
412            int /*newNumberColumns*/)
413{
414  const char prefix[] = "Cbc_C_Interface::Cbc_resize(): ";
415//  const int  VERBOSE = 1;
416  if (VERBOSE>0) printf("%s begin\n",prefix);
417
418// cannot find this in Cbc, Osi, or OsiClp
419//tbd  model->model_->solver()->resize(newNumberRows,newNumberColumns);
420  if (VERBOSE>0) printf("%s WARNING: NOT IMPLEMENTED\n",prefix);
421
422  if (VERBOSE>0) printf("%s return\n",prefix);
423}
424/* Deletes rows */
425COINLIBAPI void COINLINKAGE
426Cbc_deleteRows(Cbc_Model * model, int number, const int * which)
427{
428  const char prefix[] = "Cbc_C_Interface::Cbc_deleteRows(): ";
429//  const int  VERBOSE = 1;
430  if (VERBOSE>0) printf("%s begin\n",prefix);
431
432  OsiSolverInterface * solver = model->model_->solver();
433  solver->deleteRows(number,which);
434
435  if (VERBOSE>0) printf("%s return\n",prefix);
436}
437/* Add rows */
438COINLIBAPI void COINLINKAGE
439Cbc_addRows(Cbc_Model * /*model*/, const int /*number*/, 
440            const double * /*rowLower*/, 
441            const double * /*rowUpper*/,
442            const int * /*rowStarts*/, const int * /*columns*/,
443            const double * /*elements*/)
444{
445  const char prefix[] = "Cbc_C_Interface::Cbc_addRows(): ";
446//  const int  VERBOSE = 1;
447  if (VERBOSE>0) printf("%s begin\n",prefix);
448
449// available through OsiClp
450//tbd  model->model_->addRows(number,rowLower,rowUpper,rowStarts,columns,elements);
451  if (VERBOSE>0) printf("%s WARNING: NOT IMPLEMENTED\n",prefix);
452
453  if (VERBOSE>0) printf("%s return\n",prefix);
454}
455
456/* Deletes columns */
457COINLIBAPI void COINLINKAGE
458Cbc_deleteColumns(Cbc_Model * model, int number, const int * which)
459{
460  const char prefix[] = "Cbc_C_Interface::Cbc_deleteColumns(): ";
461//  const int  VERBOSE = 1;
462  if (VERBOSE>0) printf("%s begin\n",prefix);
463
464  OsiSolverInterface * solver = model->model_->solver();
465  solver->deleteCols(number,which);
466
467  if (VERBOSE>0) printf("%s return\n",prefix);
468}
469/* Add columns */
470COINLIBAPI void COINLINKAGE
471Cbc_addColumns(Cbc_Model * /*model*/, int /*number*/, 
472               const double * /*columnLower*/, 
473               const double * /*columnUpper*/,
474               const double * /*objective*/,
475               const int * /*columnStarts*/, const int * /*rows*/,
476               const double * /*elements*/)
477{
478  const char prefix[] = "Cbc_C_Interface::Cbc_addColumns(): ";
479//  const int  VERBOSE = 1;
480  if (VERBOSE>0) printf("%s begin\n",prefix);
481
482// available through OsiClp
483//tbd  model->model_->addColumns(number,columnLower,columnUpper,objective,
484//tbd                       columnStarts,rows,elements);
485  if (VERBOSE>0) printf("%s WARNING: NOT IMPLEMENTED\n",prefix);
486
487  if (VERBOSE>0) printf("%s return\n",prefix);
488}
489/* Drops names - makes lengthnames 0 and names empty */
490COINLIBAPI void COINLINKAGE
491Cbc_dropNames(Cbc_Model * /*model*/)
492{
493  const char prefix[] = "Cbc_C_Interface::Cbc_dropNames(): ";
494//  const int  VERBOSE = 1;
495  if (VERBOSE>0) printf("%s begin\n",prefix);
496 
497// cannot find names in Cbc, Osi, or OsiClp
498//tbd  model->model_->dropNames();
499  if (VERBOSE>0) printf("%s WARNING: NOT IMPLEMENTED\n",prefix);
500
501  if (VERBOSE>0) printf("%s return\n",prefix);
502}
503/* Copies in names */
504COINLIBAPI void COINLINKAGE
505Cbc_copyNames(Cbc_Model * /*model*/, const char * const * /*rowNamesIn*/,
506              const char * const * /*columnNamesIn*/)
507{
508  const char prefix[] = "Cbc_C_Interface::Cbc_copyNames(): ";
509//  const int  VERBOSE = 1;
510  if (VERBOSE>0) printf("%s begin\n",prefix);
511
512// cannot find names in Cbc, Osi, or OsiClp
513/*clean
514  int iRow;
515  std::vector<std::string> rowNames;
516  int numberRows = model->model_->getNumRows();
517  rowNames.reserve(numberRows);
518  for (iRow=0;iRow<numberRows;iRow++) {
519    rowNames.push_back(rowNamesIn[iRow]);
520  }
521 
522  int iColumn;
523  std::vector<std::string> columnNames;
524  int numberColumns = model->model_->getNumCols();
525  columnNames.reserve(numberColumns);
526  for (iColumn=0;iColumn<numberColumns;iColumn++) {
527    columnNames.push_back(columnNamesIn[iColumn]);
528  }
529  model->model_->copyNames(rowNames,columnNames);
530*/
531
532  if (VERBOSE>0) printf("%s return\n",prefix);
533}
534
535/* Number of rows */
536COINLIBAPI int COINLINKAGE
537Cbc_numberRows(Cbc_Model * model)
538{
539  const char prefix[] = "Cbc_C_Interface::Cbc_numberRows(): ";
540//  const int  VERBOSE = 1;
541  if (VERBOSE>0) printf("%s begin\n",prefix);
542
543  int result = 0;
544  result = model->model_->getNumRows();
545
546  if (VERBOSE>0) printf("%s return %i\n",prefix,result);
547  return result;
548}
549/* Number of columns */
550COINLIBAPI int COINLINKAGE
551Cbc_numberColumns(Cbc_Model * model)
552{
553  const char prefix[] = "Cbc_C_Interface::Cbc_numberColumns(): ";
554//  const int  VERBOSE = 1;
555  if (VERBOSE>0) printf("%s begin\n",prefix);
556
557  int result = 0;
558  result = model->model_->getNumCols();
559
560  if (VERBOSE>0) printf("%s return %i\n",prefix,result);
561  return result;
562}
563/* Primal tolerance to use */
564COINLIBAPI double COINLINKAGE
565Cbc_primalTolerance(Cbc_Model * model)
566{
567  const char prefix[] = "Cbc_C_Interface::Cbc_primalTolerance(): ";
568//  const int  VERBOSE = 1;
569  if (VERBOSE>0) printf("%s begin\n",prefix);
570
571  double result = 0.0;
572  model->model_->solver()->getDblParam(OsiPrimalTolerance,result) ;
573
574  if (VERBOSE>0) printf("%s return %g\n",prefix,result);
575  return result;
576}
577COINLIBAPI void COINLINKAGE
578Cbc_setPrimalTolerance(Cbc_Model * model,  double value) 
579{
580  const char prefix[] = "Cbc_C_Interface::Cbc_setPrimalTolerance(): ";
581//  const int  VERBOSE = 1;
582  if (VERBOSE>0) printf("%s begin\n",prefix);
583
584  model->model_->solver()->setDblParam(OsiPrimalTolerance,value) ;
585
586  if (VERBOSE>0) printf("%s return\n",prefix);
587}
588/* Dual tolerance to use */
589COINLIBAPI double COINLINKAGE
590Cbc_dualTolerance(Cbc_Model * model)
591{
592  const char prefix[] = "Cbc_C_Interface::Cbc_dualTolerance(): ";
593//  const int  VERBOSE = 1;
594  if (VERBOSE>0) printf("%s begin\n",prefix);
595
596  double result = 0.0;
597  model->model_->solver()->getDblParam(OsiDualTolerance,result) ;
598
599  if (VERBOSE>0) printf("%s return %g\n",prefix,result);
600  return result;
601}
602COINLIBAPI void COINLINKAGE
603Cbc_setDualTolerance(Cbc_Model * model,  double value) 
604{
605  const char prefix[] = "Cbc_C_Interface::Cbc_setDualTolerance(): ";
606//  const int  VERBOSE = 1;
607  if (VERBOSE>0) printf("%s begin\n",prefix);
608
609  model->model_->solver()->setDblParam(OsiDualTolerance,value) ;
610
611  if (VERBOSE>0) printf("%s return\n",prefix);
612}
613/* Integer tolerance to use */
614COINLIBAPI double COINLINKAGE
615Cbc_integerTolerance(Cbc_Model * model)
616{
617  const char prefix[] = "Cbc_C_Interface::Cbc_primalTolerance(): ";
618//  const int  VERBOSE = 1;
619  if (VERBOSE>0) printf("%s begin\n",prefix);
620
621  double result = 0.0;
622  result = model->model_->getDblParam(CbcModel::CbcIntegerTolerance) ;
623
624  if (VERBOSE>0) printf("%s return %g\n",prefix,result);
625  return result;
626}
627COINLIBAPI void COINLINKAGE
628Cbc_setIntegerTolerance(Cbc_Model * model,  double value) 
629{
630  const char prefix[] = "Cbc_C_Interface::Cbc_setPrimalTolerance(): ";
631//  const int  VERBOSE = 1;
632  if (VERBOSE>0) printf("%s begin\n",prefix);
633
634  model->model_->setDblParam(CbcModel::CbcIntegerTolerance,value) ;
635
636  if (VERBOSE>0) printf("%s return\n",prefix);
637}
638/* Dual objective limit */
639COINLIBAPI double COINLINKAGE
640Cbc_dualObjectiveLimit(Cbc_Model * model)
641{
642  const char prefix[] = "Cbc_C_Interface::Cbc_dualObjectiveLimit(): ";
643//  const int  VERBOSE = 1;
644  if (VERBOSE>0) printf("%s begin\n",prefix);
645
646  double result = 0.0;
647  model->model_->solver()->getDblParam(OsiDualObjectiveLimit,result) ;
648
649  if (VERBOSE>0) printf("%s return %g\n",prefix,result);
650  return result;
651}
652COINLIBAPI void COINLINKAGE
653Cbc_setDualObjectiveLimit(Cbc_Model * model, double value)
654{
655  const char prefix[] = "Cbc_C_Interface::Cbc_setDualObjectiveLimit(): ";
656//  const int  VERBOSE = 1;
657  if (VERBOSE>0) printf("%s begin\n",prefix);
658
659  model->model_->solver()->setDblParam(OsiDualObjectiveLimit,value) ;
660
661  if (VERBOSE>0) printf("%s return\n",prefix);
662}
663/* Objective offset */
664COINLIBAPI double COINLINKAGE
665Cbc_objectiveOffset(Cbc_Model * /*model*/)
666{
667  const char prefix[] = "Cbc_C_Interface::Cbc_objectiveOffset(): ";
668//  const int  VERBOSE = 1;
669  if (VERBOSE>0) printf("%s begin\n",prefix);
670
671  double result = 0.0;
672// cannot find names in Cbc, Osi, or OsiClp
673//tbd  return model->model_->objectiveOffset();
674  if (VERBOSE>0) printf("%s WARNING: NOT IMPLEMENTED\n",prefix);
675
676  if (VERBOSE>0) printf("%s return %g\n",prefix,result);
677  return result;
678}
679COINLIBAPI void COINLINKAGE
680Cbc_setObjectiveOffset(Cbc_Model * /*model*/, double /*value*/)
681{
682  const char prefix[] = "Cbc_C_Interface::Cbc_setObjectiveOffset(): ";
683//  const int  VERBOSE = 1;
684  if (VERBOSE>0) printf("%s begin\n",prefix);
685
686// cannot find names in Cbc, Osi, or OsiClp
687//tbd  model->model_->solver()->setObjectiveOffset(value);
688  if (VERBOSE>0) printf("%s WARNING: NOT IMPLEMENTED\n",prefix);
689
690  if (VERBOSE>0) printf("%s return\n",prefix);
691}
692/* Fills in array with problem name  */
693COINLIBAPI void COINLINKAGE
694Cbc_problemName(Cbc_Model * model, int maxNumberCharacters, char * array)
695{
696  const char prefix[] = "Cbc_C_Interface::Cbc_problemName(): ";
697//  const int  VERBOSE = 1;
698  if (VERBOSE>0) printf("%s begin\n",prefix);
699
700  std::string name;
701  model->model_->solver()->getStrParam(OsiProbName,name);
702  maxNumberCharacters = CoinMin(maxNumberCharacters,(int)strlen(name.c_str()));
703  strncpy(array,name.c_str(),maxNumberCharacters-1);
704  array[maxNumberCharacters-1]='\0';
705
706  if (VERBOSE>0) printf("%s return\n",prefix);
707}
708/* Sets problem name.  Must have \0 at end.  */
709COINLIBAPI int COINLINKAGE
710Cbc_setProblemName(Cbc_Model * model, int /*maxNumberCharacters*/, char * array)
711{
712  const char prefix[] = "Cbc_C_Interface::Cbc_setProblemName(): ";
713//  const int  VERBOSE = 1;
714  if (VERBOSE>0) printf("%s begin\n",prefix);
715
716  bool result = false;
717  result = model->model_->solver()->setStrParam(OsiProbName, array);
718
719  if (VERBOSE>0) printf("%s return\n",prefix);
720  return (result) ? 1 : 0;
721}
722/* Number of iterations */
723COINLIBAPI int COINLINKAGE
724Cbc_numberIterations(Cbc_Model * model)
725{
726  const char prefix[] = "Cbc_C_Interface::Cbc_numberIterations(): ";
727//  const int  VERBOSE = 1;
728  if (VERBOSE>0) printf("%s begin\n",prefix);
729
730  int result = 0;
731  result = model->model_->getIterationCount();
732
733  if (VERBOSE>0) printf("%s return %i\n",prefix,result);
734  return result;
735}
736COINLIBAPI void COINLINKAGE
737Cbc_setNumberIterations(Cbc_Model * /*model*/, int /*numberIterations*/)
738{
739  const char prefix[] = "Cbc_C_Interface::Cbc_setNumberIterations(): ";
740//  const int  VERBOSE = 1;
741  if (VERBOSE>0) printf("%s begin\n",prefix);
742
743// cannot find this in Cbc, Osi, or OsiClp
744//tbd  model->model_->setNumberIterations(numberIterations);
745  if (VERBOSE>0) printf("%s WARNING: NOT IMPLEMENTED\n",prefix);
746
747  if (VERBOSE>0) printf("%s return\n",prefix);
748  return;
749}
750/* Maximum number of iterations */
751COINLIBAPI int COINLINKAGE
752Cbc_maximumIterations(Cbc_Model * /*model*/)
753{
754  const char prefix[] = "Cbc_C_Interface::Cbc_maximumIterations(): ";
755//  const int  VERBOSE = 1;
756  if (VERBOSE>0) printf("%s begin\n",prefix);
757
758  int result = 0;
759// cannot find this in Cbc, Osi, or OsiClp
760//tbd  result = model->model_->solver()->maximumIterations();
761  if (VERBOSE>0) printf("%s WARNING: NOT IMPLEMENTED\n",prefix);
762
763  if (VERBOSE>0) printf("%s return %i\n",prefix,result);
764  return result;
765}
766COINLIBAPI void COINLINKAGE
767Cbc_setMaximumIterations(Cbc_Model * /*model*/, int /*value*/)
768{
769  const char prefix[] = "Cbc_C_Interface::Cbc_setMaximumIterations(): ";
770//  const int  VERBOSE = 1;
771  if (VERBOSE>0) printf("%s begin\n",prefix);
772
773// cannot find this in Cbc, Osi, or OsiClp
774//tbd  model->model_->setMaximumIterations(value);
775  if (VERBOSE>0) printf("%s WARNING: NOT IMPLEMENTED\n",prefix);
776
777  if (VERBOSE>0) printf("%s return\n",prefix);
778}
779/* Maximum number of nodes */
780COINLIBAPI int COINLINKAGE
781Cbc_maxNumNode(Cbc_Model * model)
782{
783  const char prefix[] = "Cbc_C_Interface::Cbc_maxNumNode(): ";
784//  const int  VERBOSE = 1;
785  if (VERBOSE>0) printf("%s begin\n",prefix);
786
787  int result = 0;
788  result = model->model_->getIntParam(CbcModel::CbcMaxNumNode);
789
790  if (VERBOSE>0) printf("%s return %i\n",prefix,result);
791  return result;
792}
793COINLIBAPI void COINLINKAGE
794Cbc_setMaxNumNode(Cbc_Model * model, int value)
795{
796  const char prefix[] = "Cbc_C_Interface::Cbc_setMaxNumNode(): ";
797//  const int  VERBOSE = 1;
798  if (VERBOSE>0) printf("%s begin\n",prefix);
799
800  model->model_->setIntParam(CbcModel::CbcMaxNumNode, value);
801
802  if (VERBOSE>0) printf("%s return\n",prefix);
803}
804/* Maximum number of solutions */
805COINLIBAPI int COINLINKAGE
806Cbc_maxNumSol(Cbc_Model * model)
807{
808  const char prefix[] = "Cbc_C_Interface::maxNumSol(): ";
809//  const int  VERBOSE = 1;
810  if (VERBOSE>0) printf("%s begin\n",prefix);
811
812  int result = 0;
813  result = model->model_->getIntParam(CbcModel::CbcMaxNumSol);
814
815  if (VERBOSE>0) printf("%s return %i\n",prefix,result);
816  return result;
817}
818COINLIBAPI void COINLINKAGE
819Cbc_setMaxNumSol(Cbc_Model * model, int value)
820{
821  const char prefix[] = "Cbc_C_Interface::Cbc_setMaxNumSol(): ";
822//  const int  VERBOSE = 1;
823  if (VERBOSE>0) printf("%s begin\n",prefix);
824
825  model->model_->setIntParam(CbcModel::CbcMaxNumSol, value);
826
827  if (VERBOSE>0) printf("%s return\n",prefix);
828}
829/* Maximum time in seconds (from when set called) */
830COINLIBAPI double COINLINKAGE
831Cbc_maximumSeconds(Cbc_Model * model)
832{
833  const char prefix[] = "Cbc_C_Interface::Cbc_maximumSeconds(): ";
834//  const int  VERBOSE = 1;
835  if (VERBOSE>0) printf("%s begin\n",prefix);
836
837  double result = 0.0;
838  result = model->model_->getDblParam(CbcModel::CbcMaximumSeconds);
839
840  if (VERBOSE>0) printf("%s return %g\n",prefix,result);
841  return result;
842}
843COINLIBAPI void COINLINKAGE
844Cbc_setMaximumSeconds(Cbc_Model * model, double value)
845{
846  const char prefix[] = "Cbc_C_Interface::Cbc_setMaximumSeconds(): ";
847//  const int  VERBOSE = 1;
848  if (VERBOSE>0) printf("%s begin\n",prefix);
849
850  model->model_->setDblParam(CbcModel::CbcMaximumSeconds, value);
851
852  if (VERBOSE>0) printf("%s return\n",prefix);
853}
854/* Returns true if hit maximum iteratio`ns (or time) */
855COINLIBAPI int COINLINKAGE
856Cbc_hitMaximumIterations(Cbc_Model * /*model*/)
857{
858  const char prefix[] = "Cbc_C_Interface::Cbc_hitMaximumIterations(): ";
859//  const int  VERBOSE = 1;
860  if (VERBOSE>0) printf("%s begin\n",prefix);
861
862  int result = 0;
863// cannot find names in Cbc, Osi, or OsiClp
864//tbd  result = model->model_->solver()->hitMaximumIterations() ? 1 : 0;
865  if (VERBOSE>0) printf("%s WARNING: NOT IMPLEMENTED\n",prefix);
866
867  if (VERBOSE>0) printf("%s return %i\n",prefix,result);
868  return result;
869}
870/* Status of problem:
871   0 - optimal
872   1 - primal infeasible
873   2 - dual infeasible
874   3 - stopped on iterations etc
875   4 - stopped due to errors
876*/
877COINLIBAPI int COINLINKAGE
878Cbc_status(Cbc_Model * model)
879{
880  const char prefix[] = "Cbc_C_Interface::Cbc_status(): ";
881//  const int  VERBOSE = 1;
882  if (VERBOSE>0) printf("%s begin\n",prefix);
883
884  int result = 0;
885  result = model->model_->status();
886
887  if (VERBOSE>0) printf("%s return %i\n",prefix,result);
888  return result;
889}
890/* Set problem status */
891COINLIBAPI void COINLINKAGE
892Cbc_setProblemStatus(Cbc_Model * /*model*/, int /*problemStatus*/)
893{
894  const char prefix[] = "Cbc_C_Interface::Cbc_setProblemStatus(): ";
895//  const int  VERBOSE = 1;
896  if (VERBOSE>0) printf("%s begin\n",prefix);
897
898// cannot find this in Cbc, Osi, or OsiClp
899//tbd  model->model_->setProblemStatus(problemStatus);
900  if (VERBOSE>0) printf("%s WARNING: NOT IMPLEMENTED\n",prefix);
901
902  if (VERBOSE>0) printf("%s return\n",prefix);
903}
904/* Secondary status of problem - may get extended
905   0 - none
906   1 - primal infeasible because dual limit reached
907   2 - scaled problem optimal - unscaled has primal infeasibilities
908   3 - scaled problem optimal - unscaled has dual infeasibilities
909   4 - scaled problem optimal - unscaled has both dual and primal infeasibilities
910*/
911COINLIBAPI int COINLINKAGE
912Cbc_secondaryStatus(Cbc_Model * model)
913{
914  const char prefix[] = "Cbc_C_Interface::Cbc_secondaryStatus(): ";
915//  const int  VERBOSE = 1;
916  if (VERBOSE>0) printf("%s begin\n",prefix);
917
918  int result = 0;
919// cannot find this in Cbc, Osi, or OsiClp
920  result = model->model_->secondaryStatus();
921  if (VERBOSE>0) printf("%s WARNING: NOT IMPLEMENTED\n",prefix);
922
923  if (VERBOSE>0) printf("%s return %i\n",prefix,result);
924  return result;
925}
926COINLIBAPI void COINLINKAGE
927Cbc_setSecondaryStatus(Cbc_Model * /*model*/, int /*status*/)
928{
929  const char prefix[] = "Cbc_C_Interface::Cbc_setSecondaryStatus(): ";
930//  const int  VERBOSE = 1;
931  if (VERBOSE>0) printf("%s begin\n",prefix);
932
933// cannot find this in Cbc, Osi, or OsiClp
934//tbd  model->model_->setSecondaryStatus(status);
935  if (VERBOSE>0) printf("%s WARNING: NOT IMPLEMENTED\n",prefix);
936
937  if (VERBOSE>0) printf("%s return\n",prefix);
938}
939/* Direction of optimization (1 - minimize, -1 - maximize, 0 - ignore */
940COINLIBAPI double COINLINKAGE
941Cbc_optimizationDirection(Cbc_Model * model)
942{
943  const char prefix[] = "Cbc_C_Interface::Cbc_optimizationDirection(): ";
944//  const int  VERBOSE = 1;
945  if (VERBOSE>0) printf("%s begin\n",prefix);
946
947  double result = 0.0;
948  result = model->model_->getObjSense();
949
950  if (VERBOSE>0) printf("%s return %g\n",prefix, result);
951  return result;
952}
953COINLIBAPI void COINLINKAGE
954Cbc_setOptimizationDirection(Cbc_Model * model, double value)
955{
956  const char prefix[] = "Cbc_C_Interface::Cbc_setOptimizationDirection(): ";
957//  const int  VERBOSE = 1;
958  if (VERBOSE>0) printf("%s begin, value = %g\n",prefix,value);
959
960  model->model_->setObjSense(value);
961//  model->model_->solver()->setObjSense(value);
962 
963  if (VERBOSE>0) printf("%s return\n",prefix);
964}
965/* Primal row solution */
966COINLIBAPI double * COINLINKAGE
967Cbc_primalRowSolution(Cbc_Model * /*model*/)
968{
969  const char prefix[] = "Cbc_C_Interface::Cbc_primalRowSolution(): ";
970//  const int  VERBOSE = 1;
971  if (VERBOSE>0) printf("%s begin\n",prefix);
972
973  double * result = NULL;
974 
975// cannot find this in Cbc, Osi, or OsiClp
976// may have to make it somehow
977//tbd  return model->model_->primalRowSolution();
978  if (VERBOSE>0) printf("%s WARNING: NOT IMPLEMENTED\n",prefix);
979
980  if (VERBOSE>0) printf("%s return %p\n",prefix, static_cast<void*>(result));
981  return result;
982}
983/* Primal column solution */
984COINLIBAPI double * COINLINKAGE
985Cbc_primalColumnSolution(Cbc_Model * /*model*/)
986{
987  const char prefix[] = "Cbc_C_Interface::Cbc_primalColumnSolution(): ";
988//  const int  VERBOSE = 1;
989  if (VERBOSE>0) printf("%s begin\n",prefix);
990
991  double * result = NULL;
992// cannot find this in Cbc, Osi, or OsiClp
993// may have to make it somehow
994//  result = model->model_->getColSolution();
995  if (VERBOSE>0) printf("%s WARNING: NOT IMPLEMENTED\n",prefix);
996
997  if (VERBOSE>0) printf("%s return %p\n",prefix, static_cast<void*>(result));
998  return result;
999}
1000/* Dual row solution */
1001COINLIBAPI double * COINLINKAGE
1002Cbc_dualRowSolution(Cbc_Model * /*model*/)
1003{
1004  const char prefix[] = "Cbc_C_Interface::Cbc_dualRowSolution(): ";
1005//  const int  VERBOSE = 1;
1006  if (VERBOSE>0) printf("%s begin\n",prefix);
1007
1008  double * result = NULL;
1009// cannot find this in Cbc, Osi, or OsiClp
1010// may have to make it somehow
1011//tbd  return model->model_->dualRowSolution();
1012  if (VERBOSE>0) printf("%s WARNING: NOT IMPLEMENTED\n",prefix);
1013
1014  if (VERBOSE>0) printf("%s return %p\n",prefix, static_cast<void*>(result));
1015  return NULL;
1016}
1017/* Reduced costs */
1018COINLIBAPI double * COINLINKAGE
1019Cbc_dualColumnSolution(Cbc_Model * /*model*/)
1020{
1021  const char prefix[] = "Cbc_C_Interface::Cbc_dualColumnSolution(): ";
1022//  const int  VERBOSE = 1;
1023  if (VERBOSE>0) printf("%s begin\n",prefix);
1024
1025  double * result = NULL;
1026// cannot find this in Cbc, Osi, or OsiClp
1027// may have to make it somehow
1028//tbd  return model->model_->dualColumnSolution();
1029  if (VERBOSE>0) printf("%s WARNING: NOT IMPLEMENTED\n",prefix);
1030
1031  if (VERBOSE>0) printf("%s return %p\n",prefix, static_cast<void*>(result));
1032  return NULL;
1033}
1034/* Row lower */
1035COINLIBAPI double * COINLINKAGE
1036Cbc_rowLower(Cbc_Model * /*model*/)
1037{
1038  const char prefix[] = "Cbc_C_Interface::Cbc_rowLower(): ";
1039//  const int  VERBOSE = 1;
1040  if (VERBOSE>0) printf("%s begin\n",prefix);
1041
1042  double * result = NULL;
1043// cannot find this in Cbc, Osi, or OsiClp
1044// may have to make it somehow
1045//tbd  return model->model_->rowLower();
1046  if (VERBOSE>0) printf("%s WARNING: NOT IMPLEMENTED\n",prefix);
1047
1048  if (VERBOSE>0) printf("%s return %p\n",prefix, static_cast<void*>(result));
1049  return NULL;
1050}
1051/* Row upper  */
1052COINLIBAPI double * COINLINKAGE
1053Cbc_rowUpper(Cbc_Model * /*model*/)
1054{
1055  const char prefix[] = "Cbc_C_Interface::Cbc_rowUpper(): ";
1056//  const int  VERBOSE = 1;
1057  if (VERBOSE>0) printf("%s begin\n",prefix);
1058
1059  double * result = NULL;
1060// cannot find this in Cbc, Osi, or OsiClp
1061// may have to make it somehow
1062//tbd  return model->model_->rowUpper();
1063  if (VERBOSE>0) printf("%s WARNING: NOT IMPLEMENTED\n",prefix);
1064
1065  if (VERBOSE>0) printf("%s return %p\n",prefix, static_cast<void*>(result));
1066  return NULL;
1067}
1068/* Objective Coefficients */
1069COINLIBAPI double * COINLINKAGE
1070Cbc_objective(Cbc_Model * /*model*/)
1071{
1072  const char prefix[] = "Cbc_C_Interface::Cbc_objective(): ";
1073//  const int  VERBOSE = 1;
1074  if (VERBOSE>0) printf("%s begin\n",prefix);
1075
1076  double * result = NULL;
1077// cannot find this in Cbc, Osi, or OsiClp
1078// may have to make it somehow
1079//  result = model->model_->objective();
1080  if (VERBOSE>0) printf("%s WARNING: NOT IMPLEMENTED\n",prefix);
1081
1082  if (VERBOSE>0) printf("%s return %p\n",prefix, static_cast<void*>(result));
1083  return NULL;
1084}
1085/* Column Lower */
1086COINLIBAPI double * COINLINKAGE
1087Cbc_columnLower(Cbc_Model * /*model*/)
1088{
1089  const char prefix[] = "Cbc_C_Interface::Cbc_columnLower(): ";
1090//  const int  VERBOSE = 1;
1091  if (VERBOSE>0) printf("%s begin\n",prefix);
1092
1093  double * result = NULL;
1094// cannot find this in Cbc, Osi, or OsiClp
1095// may have to make it somehow
1096//tbd  return model->model_->columnLower();
1097  if (VERBOSE>0) printf("%s WARNING: NOT IMPLEMENTED\n",prefix);
1098
1099  if (VERBOSE>0) printf("%s return %p\n",prefix, static_cast<void*>(result));
1100  return NULL;
1101}
1102/* Column Upper */
1103COINLIBAPI double * COINLINKAGE
1104Cbc_columnUpper(Cbc_Model * /*model*/)
1105{
1106  const char prefix[] = "Cbc_C_Interface::Cbc_columnUpper(): ";
1107//  const int  VERBOSE = 1;
1108  if (VERBOSE>0) printf("%s begin\n",prefix);
1109
1110  double * result = NULL;
1111// cannot find this in Cbc, Osi, or OsiClp
1112// may have to make it somehow
1113//tbd  return model->model_->columnUpper();
1114  if (VERBOSE>0) printf("%s WARNING: NOT IMPLEMENTED\n",prefix);
1115
1116  if (VERBOSE>0) printf("%s return %p\n",prefix, static_cast<void*>(result));
1117  return NULL;
1118}
1119/* Number of elements in matrix */
1120COINLIBAPI int COINLINKAGE
1121Cbc_getNumElements(Cbc_Model * model)
1122{
1123  const char prefix[] = "Cbc_C_Interface::Cbc_getNumElements(): ";
1124//  const int  VERBOSE = 1;
1125  if (VERBOSE>0) printf("%s begin\n",prefix);
1126
1127  int result = 0;
1128  result = model->model_->getNumElements();
1129
1130  if (VERBOSE>0) printf("%s return %i\n",prefix,result);
1131  return result;
1132}
1133
1134// Column starts in matrix
1135COINLIBAPI const CoinBigIndex * COINLINKAGE
1136Cbc_getVectorStarts(Cbc_Model * model)
1137{
1138  const CoinPackedMatrix * matrix = NULL;
1139  matrix = model->model_->solver()->getMatrixByCol();
1140  return (matrix == NULL) ? NULL : matrix->getVectorStarts();
1141}
1142// Row indices in matrix
1143COINLIBAPI const int * COINLINKAGE
1144Cbc_getIndices(Cbc_Model * model)
1145{
1146  const char prefix[] = "Cbc_C_Interface::Cbc_getIndices(): ";
1147//  const int  VERBOSE = 1;
1148  if (VERBOSE>0) printf("%s begin\n",prefix);
1149
1150  const int * result = NULL;
1151  const CoinPackedMatrix * matrix = NULL;
1152  matrix = model->model_->solver()->getMatrixByCol();
1153  result = (matrix == NULL) ? NULL : matrix->getIndices();
1154
1155  if (VERBOSE>0)
1156    printf("%s return %p\n",prefix, static_cast<const void*>(result));
1157  return result;
1158} 
1159
1160// Column vector lengths in matrix
1161COINLIBAPI const int * COINLINKAGE
1162Cbc_getVectorLengths(Cbc_Model * model)
1163{
1164  const char prefix[] = "Cbc_C_Interface::Cbc_getVectorLengths(): ";
1165//  const int  VERBOSE = 1;
1166  if (VERBOSE>0) printf("%s begin\n",prefix);
1167
1168  const int * result = NULL;
1169  const CoinPackedMatrix * matrix = NULL;
1170  matrix = model->model_->solver()->getMatrixByCol();
1171  result = (matrix == NULL) ? NULL : matrix->getVectorLengths();
1172
1173  if (VERBOSE>0)
1174    printf("%s return %p\n",prefix, static_cast<const void*>(result));
1175  return result;
1176} 
1177 
1178// Element values in matrix
1179COINLIBAPI const double * COINLINKAGE
1180Cbc_getElements(Cbc_Model * model)
1181{
1182  const char prefix[] = "Cbc_C_Interface::Cbc_getElements(): ";
1183//  const int  VERBOSE = 1;
1184  if (VERBOSE>0) printf("%s begin\n",prefix);
1185
1186  const double * result = NULL;
1187  const CoinPackedMatrix * matrix = NULL;
1188  matrix = model->model_->solver()->getMatrixByCol();
1189  result = (matrix == NULL) ? NULL : matrix->getElements();
1190
1191  if (VERBOSE>0)
1192    printf("%s return %p\n",prefix, static_cast<const void*>(result));
1193  return result;
1194}
1195// ======================================================================
1196
1197/* Objective value */
1198COINLIBAPI double COINLINKAGE
1199Cbc_objectiveValue(Cbc_Model * model)
1200{
1201  const char prefix[] = "Cbc_C_Interface::Cbc_objectiveValue(): ";
1202//  const int  VERBOSE = 1;
1203  if (VERBOSE>0) printf("%s begin\n",prefix);
1204
1205  double result = 0.0;
1206  result = model->model_->getObjValue();
1207
1208  if (VERBOSE>0) printf("%s return %g\n",prefix, result);
1209  return result;
1210}
1211/* Infeasibility/unbounded ray (NULL returned if none/wrong)
1212   Up to user to use delete [] on these arrays.  */
1213COINLIBAPI double * COINLINKAGE
1214Cbc_infeasibilityRay(Cbc_Model * /*model*/)
1215{
1216  const char prefix[] = "Cbc_C_Interface::Cbc_infeasibilityRay(): ";
1217//  const int  VERBOSE = 1;
1218  if (VERBOSE>0) printf("%s begin\n",prefix);
1219
1220  double * result = NULL;
1221  // lots of rays (probably too many) are available in
1222  // OsiClpSolverInterface::getDualRays()
1223  //
1224//tbd  result = model->model_->infeasibilityRay();
1225  if (VERBOSE>0) printf("%s WARNING: NOT IMPLEMENTED\n",prefix);
1226
1227  if (VERBOSE>0) printf("%s return %p\n",prefix, static_cast<void*>(result));
1228  return result;
1229}
1230COINLIBAPI double * COINLINKAGE
1231Cbc_unboundedRay(Cbc_Model * /*model*/)
1232{
1233  const char prefix[] = "Cbc_C_Interface::Cbc_unboundedRay(): ";
1234//  const int  VERBOSE = 1;
1235  if (VERBOSE>0) printf("%s begin\n",prefix);
1236
1237  double * result = NULL;
1238  // lots of rays (probably too many) are available in
1239  // OsiClpSolverInterface::getPrimalRays()
1240  //
1241//tbd  result = model->model_->unboundedRay();
1242  if (VERBOSE>0) printf("%s WARNING: NOT IMPLEMENTED\n",prefix);
1243
1244  if (VERBOSE>0) printf("%s return %p\n",prefix, static_cast<void*>(result));
1245  return result;
1246}
1247/* See if status array exists (partly for OsiClp) */
1248COINLIBAPI int COINLINKAGE
1249Cbc_statusExists(Cbc_Model * /*model*/)
1250{
1251  const char prefix[] = "Cbc_C_Interface::Cbc_statusExists(): ";
1252//  const int  VERBOSE = 1;
1253  if (VERBOSE>0) printf("%s begin\n",prefix);
1254
1255  int result = 0;
1256//tbd  result = model->model_->statusExists() ? 1 : 0;
1257  if (VERBOSE>0) printf("%s WARNING: NOT IMPLEMENTED\n",prefix);
1258
1259  if (VERBOSE>0) printf("%s return %i\n",prefix,result);
1260  return result;
1261}
1262/* Return address of status array (char[numberRows+numberColumns]) */
1263COINLIBAPI void  COINLINKAGE
1264Cbc_getBasisStatus(Cbc_Model * /*model*/, int * /*cstat*/, int * /*rstat*/)
1265{
1266  const char prefix[] = "Cbc_C_Interface::Cbc_getBasisStatus(): ";
1267//  const int  VERBOSE = 1;
1268  if (VERBOSE>0) printf("%s begin\n",prefix);
1269
1270// have to figure this out
1271//tbd  model->model_->solver()->getBasisStatus(cstat, rstat);
1272  if (VERBOSE>0) printf("%s WARNING: NOT IMPLEMENTED\n",prefix);
1273
1274  if (VERBOSE>0) printf("%s return\n",prefix);
1275  return;
1276}
1277/* Copy in status vector */
1278COINLIBAPI void COINLINKAGE
1279Cbc_setBasisStatus(Cbc_Model * /*model*/,  int * /*cstat*/, int * /*rstat*/)
1280{
1281  const char prefix[] = "Cbc_C_Interface::Cbc_setBasisStatus(): ";
1282//  const int  VERBOSE = 1;
1283  if (VERBOSE>0) printf("%s begin\n",prefix);
1284
1285//  model->model_->solver()->setBasisStatus(cstat, rstat);
1286  if (VERBOSE>0) printf("%s WARNING: NOT IMPLEMENTED\n",prefix);
1287
1288  if (VERBOSE>0) printf("%s return\n",prefix);
1289}
1290
1291/* User pointer for whatever reason */
1292COINLIBAPI void COINLINKAGE
1293Cbc_setUserPointer (Cbc_Model * /*model*/, void * /*pointer*/)
1294{
1295  const char prefix[] = "Cbc_C_Interface::Cbc_setUserPointer(): ";
1296//  const int  VERBOSE = 1;
1297  if (VERBOSE>0) printf("%s begin\n",prefix);
1298
1299  // not sure what this is for
1300  //
1301//tbd  model->model_->setUserPointer(pointer);
1302  if (VERBOSE>0) printf("%s WARNING: NOT IMPLEMENTED\n",prefix);
1303
1304  if (VERBOSE>0) printf("%s return\n",prefix);
1305}
1306COINLIBAPI void * COINLINKAGE
1307Cbc_getUserPointer (Cbc_Model * /*model*/)
1308{
1309  const char prefix[] = "Cbc_C_Interface::Cbc_getUserPointer(): ";
1310//  const int  VERBOSE = 1;
1311  if (VERBOSE>0) printf("%s begin\n",prefix);
1312
1313  void * result = NULL;
1314  // not sure what this is for
1315  //
1316//tbd result = model->model_->getUserPointer();
1317  if (VERBOSE>0) printf("%s WARNING:  NOT IMPLEMENTED\n",prefix);
1318
1319  if (VERBOSE>0) printf("%s return %p\n",prefix,result);
1320  return result;
1321}
1322/* Pass in Callback function */
1323COINLIBAPI void COINLINKAGE
1324Cbc_registerCallBack(Cbc_Model * model, 
1325         cbc_callback userCallBack)
1326{
1327  const char prefix[] = "Cbc_C_Interface::Cbc_registerCallBack(): ";
1328//  const int  VERBOSE = 1;
1329  if (VERBOSE>0) printf("%s begin\n",prefix);
1330
1331  // reuse existing log level
1332  int oldLogLevel = model->model_->messageHandler()->logLevel();
1333  // Will be copy of users one
1334  delete model->handler_;
1335  model->handler_ = new Cbc_MessageHandler(*(model->model_->messageHandler()));
1336  model->handler_->setCallBack(userCallBack);
1337  model->handler_->setModel(model);
1338  model->model_->passInMessageHandler(model->handler_);
1339  model->model_->messageHandler()->setLogLevel(oldLogLevel);
1340
1341  if (VERBOSE>0) printf("%s return\n",prefix);
1342}
1343/* Unset Callback function */
1344COINLIBAPI void COINLINKAGE
1345Cbc_clearCallBack(Cbc_Model * model)
1346{
1347  const char prefix[] = "Cbc_C_Interface::Cbc_clearCallBack(): ";
1348//  const int  VERBOSE = 1;
1349  if (VERBOSE>0) printf("%s begin\n",prefix);
1350 
1351  delete model->handler_;
1352  model->handler_=NULL;
1353
1354  if (VERBOSE>0) printf("%s return\n",prefix);
1355}
1356/* Amount of print out:
1357   0 - none
1358   1 - just final
1359   2 - just factorizations
1360   3 - as 2 plus a bit more
1361   4 - verbose
1362   above that 8,16,32 etc just for selective debug
1363*/
1364COINLIBAPI void COINLINKAGE
1365Cbc_setLogLevel(Cbc_Model * model, int value)
1366{
1367  const char prefix[] = "Cbc_C_Interface::Cbc_setLogLevel(): ";
1368//  const int  VERBOSE = 1;
1369  if (VERBOSE>0) printf("%s begin\n",prefix);
1370  if (VERBOSE>1) printf("%s value = %i\n",prefix, value);
1371 
1372  model->model_->messageHandler()->setLogLevel(value);
1373
1374  if (VERBOSE>0) printf("%s return\n",prefix);
1375}
1376COINLIBAPI int COINLINKAGE
1377Cbc_logLevel(Cbc_Model * model)
1378{
1379  const char prefix[] = "Cbc_C_Interface::Cbc_logLevel(): ";
1380//  const int  VERBOSE = 1;
1381  if (VERBOSE>0) printf("%s begin\n",prefix);
1382 
1383  int result = 0;
1384  result = model->model_->messageHandler()->logLevel();
1385
1386  if (VERBOSE>0) printf("%s return %i\n",prefix,result);
1387  return result;
1388}
1389/* length of names (0 means no names0 */
1390COINLIBAPI int COINLINKAGE
1391Cbc_lengthNames(Cbc_Model * /*model*/)
1392{
1393  const char prefix[] = "Cbc_C_Interface::Cbc_lengthNames(): ";
1394//  const int  VERBOSE = 1;
1395  if (VERBOSE>0) printf("%s begin\n",prefix);
1396 
1397  int result = 0;
1398// cannot find names in Cbc, Osi, or OsiClp
1399//tbd  result = model->model_->lengthNames();
1400  if (VERBOSE>0) printf("%s WARNING:  NOT IMPLEMENTED\n",prefix);
1401
1402  if (VERBOSE>0) printf("%s return %i\n",prefix,result);
1403  return result;
1404}
1405/* Fill in array (at least lengthNames+1 long) with a row name */
1406COINLIBAPI void COINLINKAGE
1407Cbc_rowName(Cbc_Model * /*model*/, int iRow, char * name)
1408{
1409  const char prefix[] = "Cbc_C_Interface::Cbc_rowName(): ";
1410//  const int  VERBOSE = 1;
1411  if (VERBOSE>0) printf("%s begin\n",prefix);
1412 
1413  sprintf(name,"ROW%5i",iRow);
1414// cannot find names in Cbc, Osi, or OsiClp
1415//tbd  std::string rowName=model->model_->rowName(iRow);
1416//tbd  strcpy(name,rowName.c_str());
1417
1418  if (VERBOSE>0) printf("%s return\n",prefix);
1419}
1420/* Fill in array (at least lengthNames+1 long) with a column name */
1421// cannot find names in Cbc, Osi, or OsiClp
1422COINLIBAPI void COINLINKAGE
1423Cbc_columnName(Cbc_Model * /*model*/, int iColumn, char * name)
1424{
1425  const char prefix[] = "Cbc_C_Interface::Cbc_columnName(): ";
1426//  const int  VERBOSE = 1;
1427  if (VERBOSE>0) printf("%s begin\n",prefix);
1428 
1429  sprintf(name,"COL%5i",iColumn);
1430//tbd  std::string columnName= model->model_->columnName(iColumn);
1431//tbd  strcpy(name,columnName.c_str());
1432
1433  if (VERBOSE>0) printf("%s return\n",prefix);
1434}
1435
1436/* General branch and bound solve algorithm which can do presolve.
1437   See  CbcSolve.hpp for options
1438*/
1439COINLIBAPI int COINLINKAGE
1440Cbc_initialSolve(Cbc_Model * model)
1441{
1442  const char prefix[] = "Cbc_C_Interface::Cbc_initialSolve(): ";
1443//  const int  VERBOSE = 1;
1444  if (VERBOSE>0) printf("%s begin\n",prefix);
1445 
1446  int result = 0;
1447  model->model_->initialSolve();
1448  result = model->model_->status();
1449
1450  if (VERBOSE>0) printf("%s return %i\n",prefix,result);
1451  return result;
1452}
1453/* General solve algorithm which can do presolve.
1454   See  CbcModel.hpp for options
1455*/
1456COINLIBAPI int COINLINKAGE
1457Cbc_branchAndBound(Cbc_Model * model)
1458{
1459  const char prefix[] = "Cbc_C_Interface::Cbc_branchAndBound(): ";
1460//  const int  VERBOSE = 3;
1461  if (VERBOSE>0) printf("%s begin\n",prefix);
1462 
1463  int result = 0;
1464  if (VERBOSE>2) Cbc_printModel(model,prefix);
1465  try {
1466    model->model_->branchAndBound();
1467    model->model_->solver()->resolve();
1468  } catch (CoinError e) {
1469    printf("%s ERROR: %s::%s, %s\n", prefix,
1470      e.className().c_str(), e.methodName().c_str(), e.message().c_str());
1471  }
1472  result = model->model_->status();
1473
1474  if (VERBOSE>0) printf("%s return %i\n",prefix,result);
1475  return result;
1476}
1477/* Sets or unsets scaling, 0 -off, 1 equilibrium, 2 geometric, 3, auto, 4 dynamic(later) */
1478COINLIBAPI void COINLINKAGE
1479Cbc_scaling(Cbc_Model * model, int mode)
1480{
1481  const char prefix[] = "Cbc_C_Interface::Cbc_scaling(): ";
1482//  const int  VERBOSE = 1;
1483  if (VERBOSE>0) printf("%s begin\n",prefix);
1484 
1485  OsiSolverInterface * solver = model->model_->solver();
1486  bool modeBool = (mode == 0);
1487  solver->setHintParam(OsiDoScale, modeBool);
1488
1489  if (VERBOSE>0) printf("%s return\n",prefix);
1490}
1491/* Gets scalingFlag */
1492COINLIBAPI int COINLINKAGE
1493Cbc_scalingFlag(Cbc_Model * /*model*/)
1494{
1495  const char prefix[] = "Cbc_C_Interface::Cbc_scalingFlag(): ";
1496//  const int  VERBOSE = 1;
1497  if (VERBOSE>0) printf("%s begin\n",prefix);
1498 
1499  int result = 0;
1500// try to use OsiSolverInterface::getHintParam(OsiDoScale, ???)
1501//tbd  result = model->model_->scalingFlag();
1502  if (VERBOSE>0) printf("%s WARNING:  NOT IMPLEMENTED\n",prefix);
1503
1504  if (VERBOSE>0) printf("%s return %i\n",prefix,result);
1505  return result;
1506}
1507/* Crash - at present just aimed at dual, returns
1508   -2 if dual preferred and crash basis created
1509   -1 if dual preferred and all slack basis preferred
1510   0 if basis going in was not all slack
1511   1 if primal preferred and all slack basis preferred
1512   2 if primal preferred and crash basis created.
1513   
1514   if gap between bounds <="gap" variables can be flipped
1515   
1516   If "pivot" is
1517   0 No pivoting (so will just be choice of algorithm)
1518   1 Simple pivoting e.g. gub
1519   2 Mini iterations
1520*/
1521COINLIBAPI int COINLINKAGE
1522Cbc_crash(Cbc_Model * /*model*/, double /*gap*/,int /*pivot*/)
1523{
1524  const char prefix[] = "Cbc_C_Interface::Cbc_crash(): ";
1525//  const int  VERBOSE = 1;
1526  if (VERBOSE>0) printf("%s begin\n",prefix);
1527 
1528  int result = 0;
1529// cannot find names in Cbc, Osi, or OsiClp
1530//tbd  result = model->model_->crash(gap,pivot);
1531  if (VERBOSE>0) printf("%s WARNING:  NOT IMPLEMENTED\n",prefix);
1532
1533  if (VERBOSE>0) printf("%s return %i\n",prefix,result);
1534  return result;
1535}
1536/* If problem is primal feasible */
1537COINLIBAPI int COINLINKAGE
1538Cbc_primalFeasible(Cbc_Model * model)
1539{
1540  const char prefix[] = "Cbc_C_Interface::Cbc_primalFeasible(): ";
1541//  const int  VERBOSE = 1;
1542  if (VERBOSE>0) printf("%s begin\n",prefix);
1543 
1544  int result = 0;
1545  OsiSolverInterface * solver = model->model_->solver();
1546  result = solver->isProvenPrimalInfeasible() ? 0 : 1;
1547
1548  if (VERBOSE>0) printf("%s return %i\n",prefix,result);
1549  return result;
1550}
1551/* If problem is dual feasible */
1552COINLIBAPI int COINLINKAGE
1553Cbc_dualFeasible(Cbc_Model * model)
1554{
1555  const char prefix[] = "Cbc_C_Interface::Cbc_dualFeasible(): ";
1556//  const int  VERBOSE = 1;
1557  if (VERBOSE>0) printf("%s begin\n",prefix);
1558 
1559  int result = 0;
1560  OsiSolverInterface * solver = model->model_->solver();
1561  result = solver->isProvenDualInfeasible() ? 0 : 1;
1562
1563  if (VERBOSE>0) printf("%s return %i\n",prefix,result);
1564  return result;
1565}
1566/* Dual bound */
1567COINLIBAPI double COINLINKAGE
1568Cbc_dualBound(Cbc_Model * /*model*/)
1569{
1570  const char prefix[] = "Cbc_C_Interface::Cbc_dualBound(): ";
1571//  const int  VERBOSE = 1;
1572  if (VERBOSE>0) printf("%s begin\n",prefix);
1573 
1574  double result = 0;
1575// cannot find in Cbc, Osi, or OsiClp
1576//tbd  result = model->model_->dualBound();
1577  if (VERBOSE>0) printf("%s WARNING:  NOT IMPLEMENTED\n",prefix);
1578
1579  if (VERBOSE>0) printf("%s return %g\n",prefix,result);
1580  return result;
1581}
1582COINLIBAPI void COINLINKAGE
1583Cbc_setDualBound(Cbc_Model * /*model*/, double /*value*/)
1584{
1585  const char prefix[] = "Cbc_C_Interface::Cbc_setDualBound(): ";
1586//  const int  VERBOSE = 1;
1587  if (VERBOSE>0) printf("%s begin\n",prefix);
1588 
1589// cannot find names in Cbc, Osi, or OsiClp
1590//tbd  model->model_->setDualBound(value);
1591  if (VERBOSE>0) printf("%s WARNING:  NOT IMPLEMENTED\n",prefix);
1592
1593  if (VERBOSE>0) printf("%s return\n",prefix);
1594}
1595/* Infeasibility cost */
1596COINLIBAPI double COINLINKAGE
1597Cbc_infeasibilityCost(Cbc_Model * /*model*/)
1598{
1599  const char prefix[] = "Cbc_C_Interface::Cbc_infeasibilityCost(): ";
1600//  const int  VERBOSE = 1;
1601  if (VERBOSE>0) printf("%s begin\n",prefix);
1602 
1603  double result = 0;
1604// cannot find names in Cbc, Osi, or OsiClp
1605//tbd  result = model->model_->solver()->infeasibilityCost();
1606  if (VERBOSE>0) printf("%s WARNING:  NOT IMPLEMENTED\n",prefix);
1607
1608  if (VERBOSE>0) printf("%s return %g\n",prefix,result);
1609  return result;
1610}
1611COINLIBAPI void COINLINKAGE
1612Cbc_setInfeasibilityCost(Cbc_Model * /*model*/, double /*value*/)
1613{
1614  const char prefix[] = "Cbc_C_Interface::Cbc_setInfeasibilityCost(): ";
1615//  const int  VERBOSE = 1;
1616  if (VERBOSE>0) printf("%s begin\n",prefix);
1617 
1618// cannot find names in Cbc, Osi, or OsiClp
1619//tbd  model->model_->setInfeasibilityCost(value);
1620  if (VERBOSE>0) printf("%s WARNING:  NOT IMPLEMENTED\n",prefix);
1621
1622  if (VERBOSE>0) printf("%s return\n",prefix);
1623}
1624/* Perturbation:
1625   50  - switch on perturbation
1626   100 - auto perturb if takes too long (1.0e-6 largest nonzero)
1627   101 - we are perturbed
1628   102 - don't try perturbing again
1629   default is 100
1630   others are for playing
1631*/
1632COINLIBAPI int COINLINKAGE
1633Cbc_perturbation(Cbc_Model * /*model*/)
1634{
1635  const char prefix[] = "Cbc_C_Interface::Cbc_perturbation(): ";
1636//  const int  VERBOSE = 1;
1637  if (VERBOSE>0) printf("%s begin\n",prefix);
1638 
1639  int result = 0;
1640// cannot find names in Cbc, Osi, or OsiClp
1641//tbd  result = model->model_->perturbation();
1642  if (VERBOSE>0) printf("%s WARNING:  NOT IMPLEMENTED\n",prefix);
1643
1644  if (VERBOSE>0) printf("%s return %i\n",prefix,result);
1645  return result;
1646}
1647COINLIBAPI void COINLINKAGE
1648Cbc_setPerturbation(Cbc_Model * /*model*/, int /*value*/)
1649{
1650  const char prefix[] = "Cbc_C_Interface::Cbc_setPerturbation(): ";
1651//  const int  VERBOSE = 1;
1652  if (VERBOSE>0) printf("%s begin\n",prefix);
1653 
1654// cannot find names in Cbc, Osi, or OsiClp
1655//tbd  model->model_->setPerturbation(value);
1656  if (VERBOSE>0) printf("%s WARNING:  NOT IMPLEMENTED\n",prefix);
1657
1658  if (VERBOSE>0) printf("%s return\n",prefix);
1659}
1660/* Current (or last) algorithm */
1661COINLIBAPI int COINLINKAGE
1662Cbc_algorithm(Cbc_Model * /*model*/)
1663{
1664  const char prefix[] = "Cbc_C_Interface::Cbc_setPerturbation(): ";
1665//  const int  VERBOSE = 1;
1666  if (VERBOSE>0) printf("%s begin\n",prefix);
1667 
1668  int result = 0;
1669// cannot find names in Cbc, Osi, or OsiClp
1670//tbd  result = model->model_->algorithm();
1671  if (VERBOSE>0) printf("%s WARNING:  NOT IMPLEMENTED\n",prefix);
1672
1673  if (VERBOSE>0) printf("%s return %i\n",prefix,result);
1674  return result;
1675}
1676/* Set algorithm */
1677COINLIBAPI void COINLINKAGE
1678Cbc_setAlgorithm(Cbc_Model * /*model*/, int /*value*/)
1679{
1680  const char prefix[] = "Cbc_C_Interface::Cbc_setAlgorithm(): ";
1681//  const int  VERBOSE = 1;
1682  if (VERBOSE>0) printf("%s begin\n",prefix);
1683 
1684// cannot find names in Cbc, Osi, or OsiClp
1685//tbd  model->model_->setAlgorithm(value);
1686  if (VERBOSE>0) printf("%s WARNING:  NOT IMPLEMENTED\n",prefix);
1687
1688  if (VERBOSE>0) printf("%s return\n",prefix);
1689}
1690/* Sum of dual infeasibilities */
1691COINLIBAPI double COINLINKAGE
1692Cbc_sumDualInfeasibilities(Cbc_Model * /*model*/)
1693{
1694  const char prefix[] = "Cbc_C_Interface::Cbc_sumDualInfeasibilities(): ";
1695//  const int  VERBOSE = 1;
1696  if (VERBOSE>0) printf("%s begin\n",prefix);
1697 
1698  double result = 0;
1699// cannot find names in Cbc, Osi, or OsiClp
1700//tbd  result = model->model_->sumDualInfeasibilities();
1701  if (VERBOSE>0) printf("%s WARNING:  NOT IMPLEMENTED\n",prefix);
1702
1703  if (VERBOSE>0) printf("%s return %g\n",prefix,result);
1704  return result;
1705}
1706/* Number of dual infeasibilities */
1707COINLIBAPI int COINLINKAGE
1708Cbc_numberDualInfeasibilities(Cbc_Model * /*model*/)
1709{
1710  const char prefix[] = "Cbc_C_Interface::Cbc_numberDualInfeasibilities(): ";
1711//  const int  VERBOSE = 1;
1712  if (VERBOSE>0) printf("%s begin\n",prefix);
1713 
1714  int result = 0;
1715// cannot find names in Cbc, Osi, or OsiClp
1716//tbd  result = model->model_->numberDualInfeasibilities();
1717  if (VERBOSE>0) printf("%s WARNING:  NOT IMPLEMENTED\n",prefix);
1718
1719  if (VERBOSE>0) printf("%s return %i\n",prefix,result);
1720  return result;
1721}
1722/* Sum of primal infeasibilities */
1723COINLIBAPI double COINLINKAGE
1724Cbc_sumPrimalInfeasibilities(Cbc_Model * /*model*/)
1725{
1726  const char prefix[] = "Cbc_C_Interface::Cbc_sumPrimalInfeasibilities(): ";
1727//  const int  VERBOSE = 1;
1728  if (VERBOSE>0) printf("%s begin\n",prefix);
1729 
1730  double result = 0;
1731// cannot find names in Cbc, Osi, or OsiClp
1732//tbd result = model->model_->sumPrimalInfeasibilities();
1733  if (VERBOSE>0) printf("%s WARNING:  NOT IMPLEMENTED\n",prefix);
1734
1735  if (VERBOSE>0) printf("%s return %g\n",prefix,result);
1736  return result;
1737}
1738/* Number of primal infeasibilities */
1739COINLIBAPI int COINLINKAGE
1740Cbc_numberPrimalInfeasibilities(Cbc_Model * /*model*/)
1741{
1742  const char prefix[] = "Cbc_C_Interface::Cbc_numberPrimalInfeasibilities(): ";
1743//  const int  VERBOSE = 1;
1744  if (VERBOSE>0) printf("%s begin\n",prefix);
1745 
1746  int result = 0;
1747//tbd  result = model->model_->getContinuousInfeasibilities();
1748  if (VERBOSE>0) printf("%s WARNING:  NOT IMPLEMENTED\n",prefix);
1749
1750  if (VERBOSE>0) printf("%s return %i\n",prefix,result);
1751  return result;
1752}
1753/* Save model to file, returns 0 if success.  This is designed for
1754   use outside algorithms so does not save iterating arrays etc.
1755   It does not save any messaging information.
1756   Does not save scaling values.
1757   It does not know about all types of virtual functions.
1758*/
1759COINLIBAPI int COINLINKAGE
1760Cbc_saveModel(Cbc_Model * /*model*/, const char * /*fileName*/)
1761{
1762  const char prefix[] = "Cbc_C_Interface::Cbc_saveModel(): ";
1763//  const int  VERBOSE = 1;
1764  if (VERBOSE>0) printf("%s begin\n",prefix);
1765 
1766  int result = 0;
1767// there is a writeMPS method in Osi
1768//tbd  result = model->model_->saveModel(fileName);
1769  if (VERBOSE>0) printf("%s WARNING:  NOT IMPLEMENTED\n",prefix);
1770
1771  if (VERBOSE>0) printf("%s return %i\n",prefix,result);
1772  return result;
1773}
1774/* Restore model from file, returns 0 if success,
1775   deletes current model */
1776COINLIBAPI int COINLINKAGE
1777Cbc_restoreModel(Cbc_Model * /*model*/, const char * /*fileName*/)
1778{
1779  const char prefix[] = "Cbc_C_Interface::Cbc_restoreModel(): ";
1780//  const int  VERBOSE = 1;
1781  if (VERBOSE>0) printf("%s begin\n",prefix);
1782 
1783  int result = 0;
1784// there is a readMPS method in Osi
1785//tbd  result = model->model_->restoreModel(fileName);
1786  if (VERBOSE>0) printf("%s WARNING:  NOT IMPLEMENTED\n",prefix);
1787
1788  if (VERBOSE>0) printf("%s return %i\n",prefix,result);
1789  return result;
1790}
1791 
1792/** Call this to really test if a valid solution can be feasible
1793    Solution is number columns in size.
1794    If fixVariables true then bounds of continuous solver updated.
1795    Returns objective value (worse than cutoff if not feasible)
1796*/
1797COINLIBAPI void COINLINKAGE
1798Cbc_checkSolution(Cbc_Model * /*model*/)
1799{
1800  const char prefix[] = "Cbc_C_Interface::Cbc_checkSolution(): ";
1801//  const int  VERBOSE = 1;
1802  if (VERBOSE>0) printf("%s begin\n",prefix);
1803 
1804  // see CbcModel::checkSolution(double cutoff, const double * solution,
1805  //           bool fixVariables);
1806//  model->model_->checkSolution();
1807
1808  if (VERBOSE>0) printf("%s return\n",prefix);
1809  return;
1810}
1811/* Number of rows */
1812COINLIBAPI int COINLINKAGE
1813Cbc_getNumRows(Cbc_Model * model)
1814{
1815  const char prefix[] = "Cbc_C_Interface::Cbc_getNumRows(): ";
1816//  const int  VERBOSE = 1;
1817  if (VERBOSE>0) printf("%s begin\n",prefix);
1818 
1819  int result = 0;
1820  result = model->model_->getNumRows();
1821
1822  if (VERBOSE>0) printf("%s return %d\n",prefix, result);
1823  return result;
1824}
1825/* Number of columns */
1826COINLIBAPI int COINLINKAGE
1827Cbc_getNumCols(Cbc_Model * model)
1828{
1829  const char prefix[] = "Cbc_C_Interface::Cbc_getNumCols(): ";
1830//  const int  VERBOSE = 1;
1831  if (VERBOSE>0) printf("%s begin\n",prefix);
1832 
1833  int result = 0;
1834  result = model->model_->getNumCols();
1835
1836  if (VERBOSE>0) printf("%s return %d\n",prefix, result);
1837  return result;
1838}
1839/* Number of iterations */
1840COINLIBAPI int COINLINKAGE
1841Cbc_getIterationCount(Cbc_Model * model)
1842{
1843  const char prefix[] = "Cbc_C_Interface::Cbc_getIterationCount(): ";
1844//  const int  VERBOSE = 1;
1845  if (VERBOSE>0) printf("%s begin\n",prefix);
1846 
1847  int result = 0;
1848  result = model->model_->getIterationCount();
1849
1850  if (VERBOSE>0) printf("%s return %d\n",prefix, result);
1851  return result;
1852}
1853/* Are there a numerical difficulties? */
1854COINLIBAPI int COINLINKAGE
1855Cbc_isAbandoned(Cbc_Model * model)
1856{
1857  const char prefix[] = "Cbc_C_Interface::Cbc_isAbandoned(): ";
1858//  const int  VERBOSE = 1;
1859  if (VERBOSE>0) printf("%s begin\n",prefix);
1860 
1861  int result = 0;
1862  result = model->model_->isAbandoned() ? 1 : 0;
1863
1864  if (VERBOSE>0) printf("%s return %i\n",prefix,result);
1865  return result;
1866}
1867/* Is optimality proven? */
1868COINLIBAPI int COINLINKAGE
1869Cbc_isProvenOptimal(Cbc_Model * model)
1870{
1871  const char prefix[] = "Cbc_C_Interface::Cbc_isProvenOptimal(): ";
1872//  const int  VERBOSE = 1;
1873  if (VERBOSE>0) printf("%s begin\n",prefix);
1874 
1875  int result = 0;
1876  result = model->model_->isProvenOptimal() ? 1 : 0;
1877
1878  if (VERBOSE>0) printf("%s return %i\n",prefix,result);
1879  return result;
1880}
1881/* Is primal infeasiblity proven? */
1882COINLIBAPI int COINLINKAGE
1883Cbc_isProvenPrimalInfeasible(Cbc_Model * model)
1884{
1885  const char prefix[] = "Cbc_C_Interface::Cbc_isProvenPrimalInfeasible(): ";
1886//  const int  VERBOSE = 1;
1887  if (VERBOSE>0) printf("%s begin\n",prefix);
1888 
1889  int result = 0;
1890  OsiSolverInterface * solver = model->model_->solver();
1891  result = solver->isProvenPrimalInfeasible() ? 1 : 0;
1892
1893  if (VERBOSE>0) printf("%s return %i\n",prefix,result);
1894  return result;
1895}
1896/* Is dual infeasiblity proven? */
1897COINLIBAPI int COINLINKAGE
1898Cbc_isProvenDualInfeasible(Cbc_Model * model)
1899{
1900  const char prefix[] = "Cbc_C_Interface::Cbc_isProvenDualInfeasible(): ";
1901//  const int  VERBOSE = 1;
1902  if (VERBOSE>0) printf("%s begin\n",prefix);
1903 
1904  int result = 0;
1905  OsiSolverInterface * solver = model->model_->solver();
1906  result = solver->isProvenDualInfeasible() ? 1 : 0;
1907
1908  if (VERBOSE>0) printf("%s return %i\n",prefix,result);
1909  return result;
1910}
1911/* Is the given primal objective limit reached? */
1912COINLIBAPI int COINLINKAGE
1913Cbc_isPrimalObjectiveLimitReached(Cbc_Model * model) 
1914{
1915  const char prefix[] = "Cbc_C_Interface::Cbc_isPrimalObjectiveLimitReached(): ";
1916//  const int  VERBOSE = 1;
1917  if (VERBOSE>0) printf("%s begin\n",prefix);
1918 
1919  int result = 0;
1920  OsiSolverInterface * solver = model->model_->solver();
1921  result = solver->isPrimalObjectiveLimitReached() ? 1 : 0;
1922
1923  if (VERBOSE>0) printf("%s return %i\n",prefix,result);
1924  return result;
1925}
1926/* Is the given dual objective limit reached? */
1927COINLIBAPI int COINLINKAGE
1928Cbc_isDualObjectiveLimitReached(Cbc_Model * model) 
1929{
1930  const char prefix[] = "Cbc_C_Interface::Cbc_isDualObjectiveLimitReached(): ";
1931//  const int  VERBOSE = 1;
1932  if (VERBOSE>0) printf("%s begin\n",prefix);
1933 
1934  int result = 0;
1935  OsiSolverInterface * solver = model->model_->solver();
1936  result = solver->isDualObjectiveLimitReached() ? 1 : 0;
1937
1938  if (VERBOSE>0) printf("%s return %i\n",prefix,result);
1939  return result;
1940}
1941/* Iteration limit reached? */
1942COINLIBAPI int COINLINKAGE
1943Cbc_isIterationLimitReached(Cbc_Model * model)
1944{
1945  const char prefix[] = "Cbc_C_Interface::Cbc_isIterationLimitReached(): ";
1946//  const int  VERBOSE = 1;
1947  if (VERBOSE>0) printf("%s begin\n",prefix);
1948 
1949  int result = 0;
1950  OsiSolverInterface * solver = model->model_->solver();
1951  result = solver->isIterationLimitReached() ? 1 : 0;
1952
1953  if (VERBOSE>0) printf("%s return %i\n",prefix,result);
1954  return result;
1955}
1956/* Direction of optimization (1 - minimize, -1 - maximize, 0 - ignore */
1957COINLIBAPI double COINLINKAGE
1958Cbc_getObjSense(Cbc_Model * model)
1959{
1960  const char prefix[] = "Cbc_C_Interface::Cbc_getObjSense(): ";
1961//  const int  VERBOSE = 1;
1962  if (VERBOSE>0) printf("%s begin\n",prefix);
1963 
1964  double result = 0;
1965  result = model->model_->getObjSense();
1966
1967  if (VERBOSE>0) printf("%s return %g\n",prefix,result);
1968  return result;
1969}
1970/* Primal row solution */
1971COINLIBAPI const double * COINLINKAGE
1972Cbc_getRowActivity(Cbc_Model * model)
1973{
1974  const char prefix[] = "Cbc_C_Interface::Cbc_getRowActivity(): ";
1975//  const int  VERBOSE = 1;
1976  if (VERBOSE>0) printf("%s begin\n",prefix);
1977 
1978  const double * result = NULL;
1979  result = model->model_->getRowActivity();
1980
1981  if (VERBOSE>0)
1982    printf("%s return %p\n",prefix, static_cast<const void*>(result));
1983  return result;
1984}
1985/* Primal column solution */
1986COINLIBAPI const double * COINLINKAGE
1987Cbc_getColSolution(Cbc_Model * model)
1988{
1989  const char prefix[] = "Cbc_C_Interface::Cbc_getColSolution(): ";
1990//  const int  VERBOSE = 1;
1991  if (VERBOSE>0) printf("%s begin\n",prefix);
1992 
1993  const double * result = NULL;
1994  result = model->model_->getColSolution();
1995
1996  if (VERBOSE>0)
1997    printf("%s return %p\n",prefix, static_cast<const void*>(result));
1998  return result;
1999}
2000COINLIBAPI void COINLINKAGE
2001Cbc_setColSolution(Cbc_Model * model, const double * input)
2002{
2003  const char prefix[] = "Cbc_C_Interface::Cbc_setColSolution(): ";
2004//  const int  VERBOSE = 1;
2005  if (VERBOSE>0) printf("%s begin\n",prefix);
2006 
2007  OsiSolverInterface * solver = model->model_->solver();
2008  solver->setColSolution(input);
2009
2010  if (VERBOSE>0) printf("%s return\n",prefix);
2011  return;
2012}
2013/* Dual row solution */
2014COINLIBAPI const double * COINLINKAGE
2015Cbc_getRowPrice(Cbc_Model * model)
2016{
2017  const char prefix[] = "Cbc_C_Interface::Cbc_getRowPrice(): ";
2018//  const int  VERBOSE = 1;
2019  if (VERBOSE>0) printf("%s begin\n",prefix);
2020 
2021  const double * result = NULL;
2022  result = model->model_->getRowPrice();
2023
2024  if (VERBOSE>0)
2025    printf("%s return %p\n",prefix, static_cast<const void*>(result));
2026  return result;
2027}
2028/* Reduced costs */
2029COINLIBAPI const double * COINLINKAGE
2030Cbc_getReducedCost(Cbc_Model * model)
2031{
2032  const char prefix[] = "Cbc_C_Interface::Cbc_getReducedCost(): ";
2033//  const int  VERBOSE = 1;
2034  if (VERBOSE>0) printf("%s begin\n",prefix);
2035 
2036  const double * result = NULL;
2037  result = model->model_->getReducedCost();
2038
2039  if (VERBOSE>0)
2040    printf("%s return %p\n",prefix, static_cast<const void*>(result));
2041  return result;
2042}
2043/* Row lower */
2044COINLIBAPI const double * COINLINKAGE
2045Cbc_getRowLower(Cbc_Model * model)
2046{
2047  const char prefix[] = "Cbc_C_Interface::Cbc_getRowLower(): ";
2048//  const int  VERBOSE = 1;
2049  if (VERBOSE>0) printf("%s begin\n",prefix);
2050 
2051  const double * result = NULL;
2052  result = model->model_->getRowLower();
2053
2054  if (VERBOSE>0)
2055    printf("%s return %p\n",prefix, static_cast<const void*>(result));
2056  return result;
2057}
2058/* Row upper  */
2059COINLIBAPI const double * COINLINKAGE
2060Cbc_getRowUpper(Cbc_Model * model)
2061{
2062  const char prefix[] = "Cbc_C_Interface::Cbc_getRowUpper(): ";
2063//  const int  VERBOSE = 1;
2064  if (VERBOSE>0) printf("%s begin\n",prefix);
2065 
2066  const double * result = NULL;
2067  result = model->model_->getRowUpper();
2068
2069  if (VERBOSE>0)
2070    printf("%s return %p\n",prefix, static_cast<const void*>(result));
2071  return result;
2072}
2073/* Objective Coefficients */
2074COINLIBAPI const double * COINLINKAGE
2075Cbc_getObjCoefficients(Cbc_Model * model)
2076{
2077  const char prefix[] = "Cbc_C_Interface::Cbc_getObjCoefficients(): ";
2078//  const int  VERBOSE = 1;
2079  if (VERBOSE>0) printf("%s begin\n",prefix);
2080 
2081  const double * result = NULL;
2082  result = model->model_->getObjCoefficients();
2083
2084  if (VERBOSE>0)
2085    printf("%s return %p\n",prefix, static_cast<const void*>(result));
2086  return result;
2087}
2088/* Column Lower */
2089COINLIBAPI const double * COINLINKAGE
2090Cbc_getColLower(Cbc_Model * model)
2091{
2092  const char prefix[] = "Cbc_C_Interface::Cbc_getColLower(): ";
2093//  const int  VERBOSE = 1;
2094  if (VERBOSE>0) printf("%s begin\n",prefix);
2095 
2096  const double * result = NULL;
2097  result = model->model_->getColLower();
2098
2099  if (VERBOSE>0)
2100    printf("%s return %p\n",prefix, static_cast<const void*>(result));
2101  return result;
2102}
2103/* Column Upper */
2104COINLIBAPI const double * COINLINKAGE
2105Cbc_getColUpper(Cbc_Model * model)
2106{
2107  const char prefix[] = "Cbc_C_Interface::Cbc_getColUpper(): ";
2108//  const int  VERBOSE = 1;
2109  if (VERBOSE>0) printf("%s begin\n",prefix);
2110 
2111  const double * result = NULL;
2112  result = model->model_->getColUpper();
2113
2114  if (VERBOSE>0)
2115    printf("%s return %p\n",prefix, static_cast<const void*>(result));
2116  return result;
2117}
2118/* Objective value */
2119COINLIBAPI double COINLINKAGE
2120Cbc_getObjValue(Cbc_Model * model)
2121{
2122  const char prefix[] = "Cbc_C_Interface::Cbc_getObjValue(): ";
2123//  const int  VERBOSE = 1;
2124  if (VERBOSE>0) printf("%s begin\n",prefix);
2125 
2126  double result = 0;
2127  result = model->model_->getObjValue();
2128
2129  if (VERBOSE>0)
2130    printf("%s return %g\n",prefix, result);
2131  return result;
2132}
2133/* Print model */
2134COINLIBAPI void COINLINKAGE
2135Cbc_printModel(Cbc_Model * model, const char * argPrefix)
2136{
2137  const char prefix[] = "Cbc_C_Interface::Cbc_printModel(): ";
2138  const int  VERBOSE = 4;
2139  if (VERBOSE>0) printf("%s begin\n",prefix);
2140 
2141  CbcModel *cbc_model = model->model_;
2142  int numrows    = cbc_model->getNumRows();
2143  int numcols    = cbc_model->getNumCols();
2144  int numelem    = cbc_model->getNumElements();
2145  const CoinPackedMatrix * matrix = cbc_model->solver()->getMatrixByCol();
2146  const CoinBigIndex     * start  = matrix->getVectorStarts();
2147  const int              * index  = matrix->getIndices();
2148  const double           * value  = matrix->getElements();
2149  const double           * collb  = cbc_model->getColLower();
2150  const double           * colub  = cbc_model->getColUpper();
2151  const double           * obj    = cbc_model->getObjCoefficients();
2152  const double           * rowlb  = cbc_model->getRowLower();
2153  const double           * rowub  = cbc_model->getRowUpper();
2154
2155  printf("%s numcols = %i, numrows = %i, numelem = %i\n", 
2156    argPrefix, numcols, numrows, numelem);
2157  printf("%s model = %p, start = %p, index = %p, value = %p\n",
2158    argPrefix, static_cast<void*>(model), static_cast<const void*>(start),
2159         static_cast<const void*>(index), static_cast<const void*>(value));
2160  matrix->dumpMatrix(NULL);
2161  {
2162    int i;
2163    for (i=0; i<=numcols; i++) 
2164      printf("%s start[%i] = %i\n", argPrefix, i, start[i]);
2165    for (i=0; i< numelem; i++)
2166      printf("%s index[%i] = %i, value[%i] = %g\n",
2167        argPrefix, i, index[i], i, value[i]);
2168  }
2169 
2170  printf("%s collb = %p, colub = %p, obj = %p, rowlb = %p, rowub = %p\n",
2171    argPrefix, static_cast<const void*>(collb),
2172         static_cast<const void*>(colub), static_cast<const void*>(obj),
2173         static_cast<const void*>(rowlb), static_cast<const void*>(rowub));
2174  printf("%s optimization direction = %g\n",argPrefix, Cbc_optimizationDirection(model));
2175  printf("  (1 - minimize, -1 - maximize, 0 - ignore)\n");
2176  {
2177    int i;
2178    for (i=0; i<numcols; i++) 
2179      printf("%s collb[%i] = %g, colub[%i] = %g, obj[%i] = %g\n",
2180        argPrefix, i, collb[i], i, colub[i], i, obj[i]);
2181    for (i=0; i< numrows; i++)
2182      printf("%s rowlb[%i] = %g, rowub[%i] = %g\n",
2183        argPrefix, i, rowlb[i], i, rowub[i]);
2184  }
2185
2186  if (VERBOSE>0) printf("%s return\n",prefix);
2187}  // Cbc_printModel()
2188
2189COINLIBAPI int COINLINKAGE
2190Cbc_isInteger(Cbc_Model * model, int i)
2191{
2192  const char prefix[] = "Cbc_C_Interface::Cbc_isInteger(): ";
2193//  const int  VERBOSE = 1;
2194  if (VERBOSE>0) printf("%s begin\n",prefix);
2195 
2196  bool result = false;
2197  result = model->model_->isInteger(i);
2198
2199  if (VERBOSE>0) printf("%s return %i\n",prefix, result);
2200  return (result) ? 1 : 0;
2201}
2202
2203COINLIBAPI double COINLINKAGE
2204Cbc_cpuTime(Cbc_Model * /*model*/)
2205{
2206  const char prefix[] = "Cbc_C_Interface::Cbc_cpuTime(): ";
2207//  const int  VERBOSE = 1;
2208  if (VERBOSE>0) printf("%s begin\n",prefix);
2209 
2210  double result = 0;
2211  result = CoinCpuTime() ;
2212
2213  if (VERBOSE>0) printf("%s return %g\n",prefix,result);
2214  return result;
2215}
2216/** Number of nodes explored in B&B tree */
2217COINLIBAPI int COINLINKAGE
2218Cbc_getNodeCount(Cbc_Model * model)
2219{
2220  const char prefix[] = "Cbc_C_Interface::Cbc_getNodeCount(): ";
2221//  const int  VERBOSE = 1;
2222  if (VERBOSE>0) printf("%s begin\n",prefix);
2223 
2224  int result = 0;
2225  result = model->model_->getNodeCount() ;
2226
2227  if (VERBOSE>0) printf("%s return %i\n",prefix,result);
2228  return result;
2229}
2230/** Return a copy of this model */
2231COINLIBAPI Cbc_Model * COINLINKAGE
2232Cbc_clone(Cbc_Model * model)
2233{
2234  const char prefix[] = "Cbc_C_Interface::Cbc_clone(): ";
2235//  const int  VERBOSE = 1;
2236  if (VERBOSE>0) printf("%s begin\n",prefix);
2237 
2238  Cbc_Model * result = new Cbc_Model;
2239  result->model_     = new CbcModel(*(model->model_));
2240  result->solver_    = dynamic_cast< OsiClpSolverInterface*> (result->model_->solver());
2241  result->handler_   = NULL;
2242
2243  if (VERBOSE>0) printf("%s return\n",prefix);
2244  return model;
2245}
2246/** Set this the variable to be continuous */
2247COINLIBAPI Cbc_Model * COINLINKAGE
2248Cbc_setContinuous(Cbc_Model * model, int iColumn)
2249{
2250  const char prefix[] = "Cbc_C_Interface::Cbc_setContinuous(): ";
2251//  const int  VERBOSE = 1;
2252  if (VERBOSE>0) printf("%s begin\n",prefix);
2253 
2254  model->model_->solver()->setContinuous(iColumn);
2255
2256  if (VERBOSE>0) printf("%s return\n",prefix);
2257  return model;
2258}
2259/* Add an SOS constraint to the model */
2260COINLIBAPI void  COINLINKAGE
2261Cbc_addSOS_Dense(Cbc_Model * model, int numObjects, const int * len,
2262           const int ** which, const double * weights, const int type)
2263{
2264  const char prefix[] = "Cbc_C_Interface::Cbc_addSOS_Dense(): ";
2265//  const int  VERBOSE = 2;
2266  if (VERBOSE>0) printf("%sbegin\n",prefix);
2267 
2268  assert(1>0);// this is probably broken
2269  int i,j,l;
2270  const int *w;
2271  // I think this is a different model due to overriding = operator
2272  CbcModel m = *(model->model_); 
2273 
2274  CbcObject ** objects = new CbcObject * [numObjects];
2275
2276  if (VERBOSE>1) printf("%s numObjects = %i\n",prefix,numObjects);
2277  for (i=0;i<numObjects;i++) {
2278    if (VERBOSE>1) {
2279      printf("%s len[%i] = %i, identifier = %i, type = %i\n",
2280        prefix,i,len[i], i, type); 
2281      fflush(stdout);
2282      for (j=0;j<len[i];j++) {
2283        if (VERBOSE>2 || j==0 || j==(len[i]-1)) {
2284          printf("%s which[%i][%i] = %d, weights[%i] = %g\n",
2285            prefix, i,j, which[i][j], j, weights[j]); 
2286          fflush(stdout);
2287        }
2288      }
2289    }
2290   
2291    // Make a CbcSOS and assign it to objects
2292    if (VERBOSE>1) printf("%s len[%i] = %i\n",prefix, i, len[i]);
2293    l = len[i];
2294    w = which[i];
2295    if (VERBOSE>1) printf("%s new CbcSOS()\n",prefix);
2296    // ***
2297    objects[i] = new CbcSOS(model->model_, (int)(len[i]), 
2298      (const int*)which[i], (const double*)weights, (int)i, (int)type);
2299    // ***
2300    if (objects[i] == NULL) {
2301      printf("%s ERROR: objects[%i] == NULL\n",prefix,i); fflush(stdout);
2302      assert(objects[i] != NULL);
2303    }
2304  }
2305  if (VERBOSE>1) printf("%s calling addObjects()\n",prefix);
2306  fflush(stdout);
2307  model->model_->addObjects(numObjects, objects);
2308  if (VERBOSE>1) printf("%s finished addObjects()\n",prefix);
2309 
2310  for (i=0;i<numObjects;i++) delete objects[i]; 
2311  delete [] objects;
2312
2313  if (VERBOSE>0) printf("%sreturn\n",prefix);
2314  return;
2315}
2316/** Add SOS constraints to the model using row-order matrix */
2317COINLIBAPI void  COINLINKAGE
2318Cbc_addSOS_Sparse(Cbc_Model * model, const int * rowStarts,
2319           const int * rowIndices, const double * weights, const int type)
2320{
2321  const char prefix[] = "Cbc_C_Interface::Cbc_addSOS_Sparse(): ";
2322//  const int  VERBOSE = 1;
2323  if (VERBOSE>0) printf("%sbegin\n",prefix);
2324 
2325  int numRows = Cbc_numberRows(model);
2326  if (VERBOSE>0) printf("%s numRows = %i\n",prefix,numRows);
2327 
2328  // The passed sparse matrix must have the same number of rows as the model
2329  assert(numRows==Cbc_numberRows(model)); 
2330 
2331  int row, i;
2332  const int *colIndex;
2333  const double *colWeight;
2334 
2335  // loop on rows and count number of objects according to numWeights>0
2336  int numObjects = 0;
2337  for (row=0; row<numRows; row++) {
2338    if (VERBOSE>2) {
2339      printf("%s row = %i\n",prefix,row);
2340      printf("%s rowStarts[%i] = %i\n",prefix,row,rowStarts[row]);
2341      printf("%s rowStarts[%i+1] = %i\n",prefix,row,rowStarts[row+1]);
2342      fflush(stdout);
2343    }
2344    const int numWeights = rowStarts[row+1]-rowStarts[row];
2345    if (VERBOSE>2) printf("%s  numWeights = %i\n",prefix,numWeights);
2346    if (numWeights>0) numObjects++;   
2347  }
2348 
2349  // make objects
2350  CbcObject ** objects = new CbcObject * [numObjects];
2351//  if (VERBOSE>1) printf("%s numObjects = %i, objects = %X\n",prefix,numObjects,objects);
2352
2353  // loop on rows and make an object when numWeights>0
2354  int objNum = 0;
2355  for (row=0; row<numRows; row++) {
2356    if (VERBOSE>2) {
2357      printf("%s row = %i\n",prefix,row);
2358      printf("%s rowStarts[%i] = %i\n",prefix,row,rowStarts[row]);
2359      printf("%s rowStarts[%i+1] = %i\n",prefix,row,rowStarts[row+1]);
2360    }
2361    const int numWeights = rowStarts[row+1]-rowStarts[row];
2362    if (VERBOSE>2) printf("%s  numWeights = %i\n",prefix,numWeights);
2363    colIndex    = rowIndices+rowStarts[row];
2364    colWeight   = weights+rowStarts[row];
2365    if (numWeights>0) {
2366      // Make a CbcSOS and assign it to objects
2367      if (VERBOSE>3) {
2368        for (i=0;i<numWeights;i++) {
2369          printf("%s  colIndex [%i] = %i\n",prefix,i,colIndex[i]);
2370          printf("%s  colWeight[%i] = %f\n",prefix,i,colWeight[i]);
2371        }
2372        fflush(stdout);
2373      }
2374      objects[objNum] = new CbcSOS(model->model_, (int)(numWeights), 
2375        (const int*)colIndex, (const double*)colWeight, (int)objNum, (int)type);
2376//      if (VERBOSE>2) printf("%s objects[%i] = %X\n",prefix,objNum,objects[objNum]);
2377      if (objects[objNum] == NULL) {
2378        printf("%s ERROR: objects[%i] == NULL\n",prefix,objNum); fflush(stdout);
2379        assert(objects[objNum] != NULL);
2380      }
2381      objNum++;
2382    } 
2383  }
2384  if (VERBOSE>2) {
2385    printf("%s calling addObjects()\n",prefix);
2386/*
2387    printf("%s numObjects = %i, objects = %X\n",prefix,numObjects,objects);
2388    for (row=0; row<numObjects; row++)
2389      printf("%s  objects[%i] = %X\n",prefix,row,objects[row]);   
2390*/   
2391  }
2392  fflush(stdout);
2393  model->model_->addObjects(numObjects, objects);
2394  if (VERBOSE>1) printf("%s finished addObjects()\n",prefix);
2395 
2396  for (objNum=0;objNum<numObjects;objNum++) delete objects[objNum]; 
2397  delete [] objects;
2398
2399  if (VERBOSE>0) printf("%sreturn\n",prefix);
2400  return;
2401}
2402
2403/** Delete all object information */
2404COINLIBAPI void  COINLINKAGE
2405Cbc_deleteObjects(Cbc_Model * model)
2406{
2407  const char prefix[] = "Cbc_C_Interface::Cbc_deleteObjects(): ";
2408//  const int  VERBOSE = 2;
2409  if (VERBOSE>0) printf("%s begin\n",prefix);
2410
2411  model->model_->deleteObjects();
2412
2413  if (VERBOSE>0) printf("%s return\n",prefix);
2414  return;
2415}
2416
2417/** Print the solution */
2418COINLIBAPI void  COINLINKAGE
2419Cbc_printSolution(Cbc_Model * model)
2420{
2421  {
2422    //
2423    //  Now to print out row solution.  The methods used return const
2424    //  pointers - which is of course much more virtuous.
2425    // 
2426    //  This version just does non-zero columns
2427    //
2428   
2429    // * Rows
2430   
2431    int numberRows = Cbc_getNumRows(model);
2432    int iRow;
2433   
2434   
2435    const double * rowPrimal = Cbc_getRowActivity(model);
2436    // * Alternatively getReducedCost(model)
2437    const double * rowDual = Cbc_getRowPrice(model);
2438    // * Alternatively getColLower(model)
2439    const double * rowLower = Cbc_getRowLower(model);
2440    // * Alternatively getColUpper(model)
2441    const double * rowUpper = Cbc_getRowUpper(model);
2442    printf("--------------------------------------\n");
2443
2444    // * If we have not kept names (parameter to readMps) this will be 0
2445  //    assert(Cbc_lengthNames(model));
2446   
2447    printf("                       Primal          Dual         Lower         Upper\n");
2448    for (iRow=0;iRow<numberRows;iRow++) {
2449      double value;
2450      value = rowPrimal[iRow];
2451      if (value>1.0e-8||value<-1.0e-8) {
2452        char name[20];
2453  //            Cbc_columnName(model,iColumn,name);
2454        sprintf(name,"ROW%5i",iRow);
2455        printf("%6d %8s",iRow,name);
2456        printf(" %13g",rowPrimal[iRow]);
2457        printf(" %13g",rowDual[iRow]);
2458        printf(" %13g",rowLower[iRow]);
2459        printf(" %13g",rowUpper[iRow]);
2460        printf("\n");
2461      }
2462    }
2463    printf("--------------------------------------\n");
2464  }
2465  {
2466    //
2467    //  Now to print out column solution.  The methods used return const
2468    //  pointers - which is of course much more virtuous.
2469    // 
2470    //  This version just does non-zero columns
2471    //
2472    //
2473   
2474    // * Columns
2475   
2476    int numberColumns = Cbc_numberColumns(model);
2477    int iColumn;
2478   
2479   
2480    // * Alternatively getColSolution(model)
2481    const double * columnPrimal = Cbc_getColSolution(model);
2482    // * Alternatively getReducedCost(model)
2483    const double * columnDual = Cbc_getReducedCost(model);
2484    // * Alternatively getColLower(model)
2485    const double * columnLower = Cbc_getColLower(model);
2486    // * Alternatively getColUpper(model)
2487    const double * columnUpper = Cbc_getColUpper(model);
2488    // * Alternatively getObjCoefficients(model)
2489    const double * columnObjective = Cbc_getObjCoefficients(model);
2490
2491    const char * isInteger = Cbc_integerInformation(model);
2492
2493    printf("--------------------------------------\n");
2494
2495    // * If we have not kept names (parameter to readMps) this will be 0
2496//    assert(Cbc_lengthNames(model));
2497   
2498    printf("                       Primal          Dual         Lower         Upper          Cost     isInteger\n");
2499    for (iColumn=0;iColumn<numberColumns;iColumn++) {
2500      double value;
2501      value = columnPrimal[iColumn];
2502      if (value>1.0e-8||value<-1.0e-8) {
2503        char name[20];
2504//              Cbc_columnName(model,iColumn,name);
2505        sprintf(name,"COL%5i",iColumn);
2506        printf("%6d %8s",iColumn,name);
2507        printf(" %13g",columnPrimal[iColumn]);
2508        printf(" %13g",columnDual[iColumn]);
2509        printf(" %13g",columnLower[iColumn]);
2510        printf(" %13g",columnUpper[iColumn]);
2511        printf(" %13g",columnObjective[iColumn]);
2512        printf(" %13i",isInteger[iColumn]);
2513        printf("\n");
2514      }
2515    }
2516    printf("--------------------------------------\n");
2517  }
2518  if (0) Cbc_printModel(model, "cbc::main(): ");
2519  return;
2520}
2521  /** Dual initial solve */
2522  COINLIBAPI int COINLINKAGE
2523  Cbc_initialDualSolve(Cbc_Model * /*model*/)
2524  {
2525    return 0;
2526  }
2527  /** Primal initial solve */
2528  COINLIBAPI int COINLINKAGE
2529  Cbc_initialPrimalSolve(Cbc_Model * /*model*/)
2530  {
2531    return 0;
2532  }
2533  /** Dual algorithm - see ClpSimplexDual.hpp for method */
2534  COINLIBAPI int COINLINKAGE
2535  Cbc_dual(Cbc_Model * /*model*/, int /*ifValuesPass*/)
2536  {
2537    return 0;
2538  }
2539  /** Primal algorithm - see ClpSimplexPrimal.hpp for method */
2540  COINLIBAPI int COINLINKAGE
2541  Cbc_primal(Cbc_Model * /*model*/, int /*ifValuesPass*/)
2542  {
2543    return 0;
2544  }
2545#if defined(__MWERKS__)
2546#pragma export off
2547#endif
Note: See TracBrowser for help on using the repository browser.