source: branches/devel/Cbc/src/Cbc_C_Interface.cpp @ 602

Last change on this file since 602 was 570, checked in by forrest, 13 years ago

for Bob

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