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

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

towards common use with other solvers

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