source: stable/1.2/Cbc/src/Cbc_C_Interface.cpp @ 644

Last change on this file since 644 was 644, checked in by coin, 12 years ago

got rid of lots of compiler warnings by static casting to void* (same as changeset #639 in branches/devel)

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