source: trunk/Cbc_C_Interface.cpp @ 156

Last change on this file since 156 was 156, checked in by forrest, 14 years ago

dynamic cast

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 70.2 KB
Line 
1// Copyright (C) 2004, International Business Machines
2// Corporation and others.  All Rights Reserved.
3
4
5#include <math.h>
6#include <cfloat>
7
8#include "CoinPragma.hpp"
9#include "CoinHelperFunctions.hpp"
10#include "CoinPackedMatrix.hpp"
11#include "CoinTime.hpp"
12
13#include "CbcModel.hpp"
14#include "CbcBranchActual.hpp"
15
16#include "CoinMessageHandler.hpp"
17#include "OsiClpSolverInterface.hpp"
18
19//  bobe including extras.h to get strdup()
20#if defined(__MWERKS__)
21#include <extras.h>
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_status(Cbc_Model * model)
866{
867  const char prefix[] = "Cbc_C_Interface::Cbc_status(): ";
868//  const int  VERBOSE = 1;
869  if (VERBOSE>0) printf("%s begin\n",prefix);
870
871  int result = 0;
872  result = model->model_->status();
873
874  if (VERBOSE>0) printf("%s return %i\n",prefix,result);
875  return result;
876}
877/* Set problem status */
878COINLIBAPI void COINLINKAGE
879Cbc_setProblemStatus(Cbc_Model * model, int problemStatus)
880{
881  const char prefix[] = "Cbc_C_Interface::Cbc_setProblemStatus(): ";
882//  const int  VERBOSE = 1;
883  if (VERBOSE>0) printf("%s begin\n",prefix);
884
885// cannot find this in Cbc, Osi, or OsiClp
886//tbd  model->model_->setProblemStatus(problemStatus);
887  printf("%s ERROR: NOT IMPLEMENTED\n",prefix);
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_secondaryStatus(Cbc_Model * model)
900{
901  const char prefix[] = "Cbc_C_Interface::Cbc_secondaryStatus(): ";
902//  const int  VERBOSE = 1;
903  if (VERBOSE>0) printf("%s begin\n",prefix);
904
905  int result = 0;
906// cannot find this in Cbc, Osi, or OsiClp
907//tbd  result = model->model_->secondaryStatus();
908  printf("%s ERROR: NOT IMPLEMENTED\n",prefix);
909
910  if (VERBOSE>0) printf("%s return %i\n",prefix,result);
911  return result;
912}
913COINLIBAPI void COINLINKAGE
914Cbc_setSecondaryStatus(Cbc_Model * model, int status)
915{
916  const char prefix[] = "Cbc_C_Interface::Cbc_setSecondaryStatus(): ";
917//  const int  VERBOSE = 1;
918  if (VERBOSE>0) printf("%s begin\n",prefix);
919
920// cannot find this in Cbc, Osi, or OsiClp
921//tbd  model->model_->setSecondaryStatus(status);
922  printf("%s ERROR: NOT IMPLEMENTED\n",prefix);
923
924  if (VERBOSE>0) printf("%s return\n",prefix);
925}
926/* Direction of optimization (1 - minimize, -1 - maximize, 0 - ignore */
927COINLIBAPI double COINLINKAGE
928Cbc_optimizationDirection(Cbc_Model * model)
929{
930  const char prefix[] = "Cbc_C_Interface::Cbc_optimizationDirection(): ";
931//  const int  VERBOSE = 1;
932  if (VERBOSE>0) printf("%s begin\n",prefix);
933
934  double result = 0.0;
935  result = model->model_->getObjSense();
936
937  if (VERBOSE>0) printf("%s return %g\n",prefix, result);
938  return result;
939}
940COINLIBAPI void COINLINKAGE
941Cbc_setOptimizationDirection(Cbc_Model * model, double value)
942{
943  const char prefix[] = "Cbc_C_Interface::Cbc_setOptimizationDirection(): ";
944//  const int  VERBOSE = 1;
945  if (VERBOSE>0) printf("%s begin\n",prefix);
946
947  model->model_->setObjSense(value);
948//  model->model_->solver()->setObjSense(value);
949 
950  if (VERBOSE>0) printf("%s return\n",prefix);
951}
952/* Primal row solution */
953COINLIBAPI double * COINLINKAGE
954Cbc_primalRowSolution(Cbc_Model * model)
955{
956  const char prefix[] = "Cbc_C_Interface::Cbc_primalRowSolution(): ";
957//  const int  VERBOSE = 1;
958  if (VERBOSE>0) printf("%s begin\n",prefix);
959
960  double * result = NULL;
961 
962// cannot find this in Cbc, Osi, or OsiClp
963// may have to make it somehow
964//tbd  return model->model_->primalRowSolution();
965  printf("%s ERROR: NOT IMPLEMENTED\n",prefix);
966
967  if (VERBOSE>0) printf("%s return %p\n",prefix,result);
968  return result;
969}
970/* Primal column solution */
971COINLIBAPI double * COINLINKAGE
972Cbc_primalColumnSolution(Cbc_Model * model)
973{
974  const char prefix[] = "Cbc_C_Interface::Cbc_primalColumnSolution(): ";
975//  const int  VERBOSE = 1;
976  if (VERBOSE>0) printf("%s begin\n",prefix);
977
978  double * result = NULL;
979// cannot find this in Cbc, Osi, or OsiClp
980// may have to make it somehow
981//  result = model->model_->getColSolution();
982  printf("%s ERROR: NOT IMPLEMENTED\n",prefix);
983
984  if (VERBOSE>0) printf("%s return %p\n",prefix,result);
985  return result;
986}
987/* Dual row solution */
988COINLIBAPI double * COINLINKAGE
989Cbc_dualRowSolution(Cbc_Model * model)
990{
991  const char prefix[] = "Cbc_C_Interface::Cbc_dualRowSolution(): ";
992//  const int  VERBOSE = 1;
993  if (VERBOSE>0) printf("%s begin\n",prefix);
994
995  double * result = NULL;
996// cannot find this in Cbc, Osi, or OsiClp
997// may have to make it somehow
998//tbd  return model->model_->dualRowSolution();
999  printf("%s ERROR: NOT IMPLEMENTED\n",prefix);
1000
1001  if (VERBOSE>0) printf("%s return %p\n",prefix,result);
1002  return NULL;
1003}
1004/* Reduced costs */
1005COINLIBAPI double * COINLINKAGE
1006Cbc_dualColumnSolution(Cbc_Model * model)
1007{
1008  const char prefix[] = "Cbc_C_Interface::Cbc_dualColumnSolution(): ";
1009//  const int  VERBOSE = 1;
1010  if (VERBOSE>0) printf("%s begin\n",prefix);
1011
1012  double * result = NULL;
1013// cannot find this in Cbc, Osi, or OsiClp
1014// may have to make it somehow
1015//tbd  return model->model_->dualColumnSolution();
1016  printf("%s ERROR: NOT IMPLEMENTED\n",prefix);
1017
1018  if (VERBOSE>0) printf("%s return %p\n",prefix,result);
1019  return NULL;
1020}
1021/* Row lower */
1022COINLIBAPI double* COINLINKAGE
1023Cbc_rowLower(Cbc_Model * model)
1024{
1025  const char prefix[] = "Cbc_C_Interface::Cbc_rowLower(): ";
1026//  const int  VERBOSE = 1;
1027  if (VERBOSE>0) printf("%s begin\n",prefix);
1028
1029  double * result = NULL;
1030// cannot find this in Cbc, Osi, or OsiClp
1031// may have to make it somehow
1032//tbd  return model->model_->rowLower();
1033  printf("%s ERROR: NOT IMPLEMENTED\n",prefix);
1034
1035  if (VERBOSE>0) printf("%s return %p\n",prefix,result);
1036  return NULL;
1037}
1038/* Row upper  */
1039COINLIBAPI double* COINLINKAGE
1040Cbc_rowUpper(Cbc_Model * model)
1041{
1042  const char prefix[] = "Cbc_C_Interface::Cbc_rowUpper(): ";
1043//  const int  VERBOSE = 1;
1044  if (VERBOSE>0) printf("%s begin\n",prefix);
1045
1046  double * result = NULL;
1047// cannot find this in Cbc, Osi, or OsiClp
1048// may have to make it somehow
1049//tbd  return model->model_->rowUpper();
1050  printf("%s ERROR: NOT IMPLEMENTED\n",prefix);
1051
1052  if (VERBOSE>0) printf("%s return %p\n",prefix,result);
1053  return NULL;
1054}
1055/* Objective Coefficients */
1056COINLIBAPI double * COINLINKAGE
1057Cbc_objective(Cbc_Model * model)
1058{
1059  const char prefix[] = "Cbc_C_Interface::Cbc_objective(): ";
1060//  const int  VERBOSE = 1;
1061  if (VERBOSE>0) printf("%s begin\n",prefix);
1062
1063  double * result = NULL;
1064// cannot find this in Cbc, Osi, or OsiClp
1065// may have to make it somehow
1066//  result = model->model_->objective();
1067  printf("%s ERROR: NOT IMPLEMENTED\n",prefix);
1068
1069  if (VERBOSE>0) printf("%s return %p\n",prefix,result);
1070  return NULL;
1071}
1072/* Column Lower */
1073COINLIBAPI double * COINLINKAGE
1074Cbc_columnLower(Cbc_Model * model)
1075{
1076  const char prefix[] = "Cbc_C_Interface::Cbc_columnLower(): ";
1077//  const int  VERBOSE = 1;
1078  if (VERBOSE>0) printf("%s begin\n",prefix);
1079
1080  double * result = NULL;
1081// cannot find this in Cbc, Osi, or OsiClp
1082// may have to make it somehow
1083//tbd  return model->model_->columnLower();
1084  printf("%s ERROR: NOT IMPLEMENTED\n",prefix);
1085
1086  if (VERBOSE>0) printf("%s return %p\n",prefix,result);
1087  return NULL;
1088}
1089/* Column Upper */
1090COINLIBAPI double * COINLINKAGE
1091Cbc_columnUpper(Cbc_Model * model)
1092{
1093  const char prefix[] = "Cbc_C_Interface::Cbc_columnUpper(): ";
1094//  const int  VERBOSE = 1;
1095  if (VERBOSE>0) printf("%s begin\n",prefix);
1096
1097  double * result = NULL;
1098// cannot find this in Cbc, Osi, or OsiClp
1099// may have to make it somehow
1100//tbd  return model->model_->columnUpper();
1101  printf("%s ERROR: NOT IMPLEMENTED\n",prefix);
1102
1103  if (VERBOSE>0) printf("%s return %p\n",prefix,result);
1104  return NULL;
1105}
1106/* Number of elements in matrix */
1107COINLIBAPI int COINLINKAGE
1108Cbc_getNumElements(Cbc_Model * model)
1109{
1110  const char prefix[] = "Cbc_C_Interface::Cbc_getNumElements(): ";
1111//  const int  VERBOSE = 1;
1112  if (VERBOSE>0) printf("%s begin\n",prefix);
1113
1114  int result = 0;
1115  result = model->model_->getNumElements();
1116
1117  if (VERBOSE>0) printf("%s return %i\n",prefix,result);
1118  return result;
1119}
1120
1121// Column starts in matrix
1122COINLIBAPI const CoinBigIndex * COINLINKAGE Cbc_getVectorStarts(Cbc_Model * model)
1123{
1124  const CoinPackedMatrix * matrix = NULL;
1125  matrix = model->model_->solver()->getMatrixByCol();
1126  return (matrix == NULL) ? NULL : matrix->getVectorStarts();
1127}
1128// Row indices in matrix
1129COINLIBAPI const int * COINLINKAGE
1130Cbc_getIndices(Cbc_Model * model)
1131{
1132  const char prefix[] = "Cbc_C_Interface::Cbc_getIndices(): ";
1133//  const int  VERBOSE = 1;
1134  if (VERBOSE>0) printf("%s begin\n",prefix);
1135
1136  const int * result = NULL;
1137  const CoinPackedMatrix * matrix = NULL;
1138  matrix = model->model_->solver()->getMatrixByCol();
1139  result = (matrix == NULL) ? NULL : matrix->getIndices();
1140
1141  if (VERBOSE>0) printf("%s return %p\n",prefix,result);
1142  return result;
1143} 
1144
1145// Column vector lengths in matrix
1146COINLIBAPI const int * COINLINKAGE
1147Cbc_getVectorLengths(Cbc_Model * model)
1148{
1149  const char prefix[] = "Cbc_C_Interface::Cbc_getVectorLengths(): ";
1150//  const int  VERBOSE = 1;
1151  if (VERBOSE>0) printf("%s begin\n",prefix);
1152
1153  const int * result = NULL;
1154  const CoinPackedMatrix * matrix = NULL;
1155  matrix = model->model_->solver()->getMatrixByCol();
1156  result = (matrix == NULL) ? NULL : matrix->getVectorLengths();
1157
1158  if (VERBOSE>0) printf("%s return %p\n",prefix,result);
1159  return result;
1160} 
1161 
1162// Element values in matrix
1163COINLIBAPI const double * COINLINKAGE
1164Cbc_getElements(Cbc_Model * model)
1165{
1166  const char prefix[] = "Cbc_C_Interface::Cbc_getElements(): ";
1167//  const int  VERBOSE = 1;
1168  if (VERBOSE>0) printf("%s begin\n",prefix);
1169
1170  const double * result = NULL;
1171  const CoinPackedMatrix * matrix = NULL;
1172  matrix = model->model_->solver()->getMatrixByCol();
1173  result = (matrix == NULL) ? NULL : matrix->getElements();
1174
1175  if (VERBOSE>0) printf("%s return %p\n",prefix,result);
1176  return result;
1177}
1178// ======================================================================
1179
1180/* Objective value */
1181COINLIBAPI double COINLINKAGE
1182Cbc_objectiveValue(Cbc_Model * model)
1183{
1184  const char prefix[] = "Cbc_C_Interface::Cbc_objectiveValue(): ";
1185//  const int  VERBOSE = 1;
1186  if (VERBOSE>0) printf("%s begin\n",prefix);
1187
1188  double result = 0.0;
1189  result = model->model_->getObjValue();
1190
1191  if (VERBOSE>0) printf("%s return %g\n",prefix, result);
1192  return result;
1193}
1194/* Infeasibility/unbounded ray (NULL returned if none/wrong)
1195   Up to user to use delete [] on these arrays.  */
1196COINLIBAPI double * COINLINKAGE
1197Cbc_infeasibilityRay(Cbc_Model * model)
1198{
1199  const char prefix[] = "Cbc_C_Interface::Cbc_infeasibilityRay(): ";
1200//  const int  VERBOSE = 1;
1201  if (VERBOSE>0) printf("%s begin\n",prefix);
1202
1203  double * result = NULL;
1204  // lots of rays (probably too many) are available in
1205  // OsiClpSolverInterface::getDualRays()
1206  //
1207//tbd  result = model->model_->infeasibilityRay();
1208  printf("%s ERROR: NOT IMPLEMENTED\n",prefix);
1209
1210  if (VERBOSE>0) printf("%s return %p\n",prefix,result);
1211  return result;
1212}
1213COINLIBAPI double * COINLINKAGE
1214Cbc_unboundedRay(Cbc_Model * model)
1215{
1216  const char prefix[] = "Cbc_C_Interface::Cbc_unboundedRay(): ";
1217//  const int  VERBOSE = 1;
1218  if (VERBOSE>0) printf("%s begin\n",prefix);
1219
1220  double * result = NULL;
1221  // lots of rays (probably too many) are available in
1222  // OsiClpSolverInterface::getPrimalRays()
1223  //
1224//tbd  result = model->model_->unboundedRay();
1225  printf("%s ERROR: NOT IMPLEMENTED\n",prefix);
1226
1227  if (VERBOSE>0) printf("%s return %p\n",prefix,result);
1228  return result;
1229}
1230/* See if status array exists (partly for OsiClp) */
1231COINLIBAPI int COINLINKAGE
1232Cbc_statusExists(Cbc_Model * model)
1233{
1234  const char prefix[] = "Cbc_C_Interface::Cbc_statusExists(): ";
1235//  const int  VERBOSE = 1;
1236  if (VERBOSE>0) printf("%s begin\n",prefix);
1237
1238  int result = 0;
1239//tbd  result = model->model_->statusExists() ? 1 : 0;
1240  printf("%s ERROR: NOT IMPLEMENTED\n",prefix);
1241
1242  if (VERBOSE>0) printf("%s return %i\n",prefix,result);
1243  return result;
1244}
1245/* Return address of status array (char[numberRows+numberColumns]) */
1246COINLIBAPI void  COINLINKAGE
1247Cbc_getBasisStatus(Cbc_Model * model, int * cstat, int * rstat)
1248{
1249  const char prefix[] = "Cbc_C_Interface::Cbc_getBasisStatus(): ";
1250//  const int  VERBOSE = 1;
1251  if (VERBOSE>0) printf("%s begin\n",prefix);
1252
1253// have to figure this out
1254//tbd  model->model_->solver()->getBasisStatus(cstat, rstat);
1255  printf("%s ERROR: NOT IMPLEMENTED\n",prefix);
1256
1257  if (VERBOSE>0) printf("%s return\n",prefix);
1258  return;
1259}
1260/* Copy in status vector */
1261COINLIBAPI void COINLINKAGE
1262setBasisStatus(Cbc_Model * model,  int * cstat, int * rstat)
1263{
1264  const char prefix[] = "Cbc_C_Interface::setBasisStatus(): ";
1265//  const int  VERBOSE = 1;
1266  if (VERBOSE>0) printf("%s begin\n",prefix);
1267
1268//  model->model_->solver()->setBasisStatus(cstat, rstat);
1269  printf("%s ERROR: NOT IMPLEMENTED\n",prefix);
1270
1271  if (VERBOSE>0) printf("%s return\n",prefix);
1272}
1273
1274/* User pointer for whatever reason */
1275COINLIBAPI void COINLINKAGE
1276Cbc_setUserPointer (Cbc_Model * model, void * pointer)
1277{
1278  const char prefix[] = "Cbc_C_Interface::Cbc_setUserPointer(): ";
1279//  const int  VERBOSE = 1;
1280  if (VERBOSE>0) printf("%s begin\n",prefix);
1281
1282  // not sure what this is for
1283  //
1284//tbd  model->model_->setUserPointer(pointer);
1285  printf("%s ERROR: NOT IMPLEMENTED\n",prefix);
1286
1287  if (VERBOSE>0) printf("%s return\n",prefix);
1288}
1289COINLIBAPI void * COINLINKAGE
1290Cbc_getUserPointer (Cbc_Model * model)
1291{
1292  const char prefix[] = "Cbc_C_Interface::Cbc_getUserPointer(): ";
1293//  const int  VERBOSE = 1;
1294  if (VERBOSE>0) printf("%s begin\n",prefix);
1295
1296  void * result = NULL;
1297  // not sure what this is for
1298  //
1299//tbd result = model->model_->getUserPointer();
1300  printf("%s ERROR: NOT IMPLEMENTED\n",prefix);
1301
1302  if (VERBOSE>0) printf("%s return %p\n",prefix,result);
1303  return result;
1304}
1305/* Pass in Callback function */
1306COINLIBAPI void COINLINKAGE
1307Cbc_registerCallBack(Cbc_Model * model, 
1308         cbc_callback userCallBack)
1309{
1310  const char prefix[] = "Cbc_C_Interface::Cbc_registerCallBack(): ";
1311//  const int  VERBOSE = 1;
1312  if (VERBOSE>0) printf("%s begin\n",prefix);
1313
1314  // Will be copy of users one
1315  delete model->handler_;
1316  model->handler_ = new Cbc_MessageHandler(*(model->model_->messageHandler()));
1317  model->handler_->setCallBack(userCallBack);
1318  model->handler_->setModel(model);
1319  model->model_->passInMessageHandler(model->handler_);
1320
1321  if (VERBOSE>0) printf("%s return\n",prefix);
1322}
1323/* Unset Callback function */
1324COINLIBAPI void COINLINKAGE
1325Cbc_clearCallBack(Cbc_Model * model)
1326{
1327  const char prefix[] = "Cbc_C_Interface::Cbc_clearCallBack(): ";
1328//  const int  VERBOSE = 1;
1329  if (VERBOSE>0) printf("%s begin\n",prefix);
1330 
1331  delete model->handler_;
1332  model->handler_=NULL;
1333
1334  if (VERBOSE>0) printf("%s return\n",prefix);
1335}
1336/* Amount of print out:
1337   0 - none
1338   1 - just final
1339   2 - just factorizations
1340   3 - as 2 plus a bit more
1341   4 - verbose
1342   above that 8,16,32 etc just for selective debug
1343*/
1344COINLIBAPI void COINLINKAGE
1345Cbc_setLogLevel(Cbc_Model * model, int value)
1346{
1347  const char prefix[] = "Cbc_C_Interface::Cbc_setLogLevel(): ";
1348//  const int  VERBOSE = 2;
1349  if (VERBOSE>0) printf("%s begin\n",prefix);
1350  if (VERBOSE>1) printf("%s value = %i\n",prefix, value);
1351 
1352  model->model_->messageHandler()->setLogLevel(value);
1353
1354  if (VERBOSE>0) printf("%s return\n",prefix);
1355}
1356COINLIBAPI int COINLINKAGE
1357Cbc_logLevel(Cbc_Model * model)
1358{
1359  const char prefix[] = "Cbc_C_Interface::Cbc_logLevel(): ";
1360//  const int  VERBOSE = 1;
1361  if (VERBOSE>0) printf("%s begin\n",prefix);
1362 
1363  int result = 0;
1364  result = model->model_->messageHandler()->logLevel();
1365
1366  if (VERBOSE>0) printf("%s return %i\n",prefix,result);
1367  return result;
1368}
1369/* length of names (0 means no names0 */
1370COINLIBAPI int COINLINKAGE
1371Cbc_lengthNames(Cbc_Model * model)
1372{
1373  const char prefix[] = "Cbc_C_Interface::Cbc_lengthNames(): ";
1374//  const int  VERBOSE = 1;
1375  if (VERBOSE>0) printf("%s begin\n",prefix);
1376 
1377  int result = 0;
1378// cannot find names in Cbc, Osi, or OsiClp
1379//tbd  result = model->model_->lengthNames();
1380  printf("%s ERROR: NOT IMPLEMENTED\n",prefix);
1381
1382  if (VERBOSE>0) printf("%s return %i\n",prefix,result);
1383  return result;
1384}
1385/* Fill in array (at least lengthNames+1 long) with a row name */
1386COINLIBAPI void COINLINKAGE
1387Cbc_rowName(Cbc_Model * model, int iRow, char * name)
1388{
1389  const char prefix[] = "Cbc_C_Interface::Cbc_rowName(): ";
1390//  const int  VERBOSE = 1;
1391  if (VERBOSE>0) printf("%s begin\n",prefix);
1392 
1393  sprintf(name,"ROW%5i",iRow);
1394// cannot find names in Cbc, Osi, or OsiClp
1395//tbd  std::string rowName=model->model_->rowName(iRow);
1396//tbd  strcpy(name,rowName.c_str());
1397
1398  if (VERBOSE>0) printf("%s return\n",prefix);
1399}
1400/* Fill in array (at least lengthNames+1 long) with a column name */
1401// cannot find names in Cbc, Osi, or OsiClp
1402COINLIBAPI void COINLINKAGE
1403Cbc_columnName(Cbc_Model * model, int iColumn, char * name)
1404{
1405  const char prefix[] = "Cbc_C_Interface::Cbc_columnName(): ";
1406//  const int  VERBOSE = 1;
1407  if (VERBOSE>0) printf("%s begin\n",prefix);
1408 
1409  sprintf(name,"COL%5i",iColumn);
1410//tbd  std::string columnName= model->model_->columnName(iColumn);
1411//tbd  strcpy(name,columnName.c_str());
1412
1413  if (VERBOSE>0) printf("%s return\n",prefix);
1414}
1415
1416/* General branch and bound solve algorithm which can do presolve.
1417   See  CbcSolve.hpp for options
1418*/
1419COINLIBAPI int COINLINKAGE
1420Cbc_initialSolve(Cbc_Model * model)
1421{
1422  const char prefix[] = "Cbc_C_Interface::Cbc_initialSolve(): ";
1423//  const int  VERBOSE = 1;
1424  if (VERBOSE>0) printf("%s begin\n",prefix);
1425 
1426  int result = 0;
1427  model->model_->initialSolve();
1428  result = model->model_->status();
1429
1430  if (VERBOSE>0) printf("%s return %i\n",prefix,result);
1431  return result;
1432}
1433/* General solve algorithm which can do presolve.
1434   See  CbcModel.hpp for options
1435*/
1436COINLIBAPI int COINLINKAGE
1437Cbc_branchAndBound(Cbc_Model * model)
1438{
1439  const char prefix[] = "Cbc_C_Interface::Cbc_branchAndBound(): ";
1440//  const int  VERBOSE = 3;
1441  if (VERBOSE>0) printf("%s begin\n",prefix);
1442 
1443  int result = 0;
1444  if (VERBOSE>2) Cbc_printModel(model,prefix);
1445  try {
1446    model->model_->branchAndBound();
1447  } catch (CoinError e) {
1448    printf("%s ERROR: %s::%s, %s\n", prefix,
1449      e.className().c_str(), e.methodName().c_str(), e.message().c_str());
1450  }
1451  result = model->model_->status();
1452
1453  if (VERBOSE>0) printf("%s return %i\n",prefix,result);
1454  return result;
1455}
1456/* Sets or unsets scaling, 0 -off, 1 equilibrium, 2 geometric, 3, auto, 4 dynamic(later) */
1457COINLIBAPI void COINLINKAGE
1458Cbc_scaling(Cbc_Model * model, int mode)
1459{
1460  const char prefix[] = "Cbc_C_Interface::Cbc_scaling(): ";
1461//  const int  VERBOSE = 1;
1462  if (VERBOSE>0) printf("%s begin\n",prefix);
1463 
1464  OsiSolverInterface * solver = model->model_->solver();
1465  solver->setHintParam(OsiDoScale,mode);
1466
1467  if (VERBOSE>0) printf("%s return\n",prefix);
1468}
1469/* Gets scalingFlag */
1470COINLIBAPI int COINLINKAGE
1471Cbc_scalingFlag(Cbc_Model * model)
1472{
1473  const char prefix[] = "Cbc_C_Interface::Cbc_scalingFlag(): ";
1474//  const int  VERBOSE = 1;
1475  if (VERBOSE>0) printf("%s begin\n",prefix);
1476 
1477  int result = 0;
1478// try to use OsiSolverInterface::getHintParam(OsiDoScale, ???)
1479//tbd  result = model->model_->scalingFlag();
1480  printf("%s ERROR: NOT IMPLEMENTED\n",prefix);
1481
1482  if (VERBOSE>0) printf("%s return %i\n",prefix,result);
1483  return result;
1484}
1485/* Crash - at present just aimed at dual, returns
1486   -2 if dual preferred and crash basis created
1487   -1 if dual preferred and all slack basis preferred
1488   0 if basis going in was not all slack
1489   1 if primal preferred and all slack basis preferred
1490   2 if primal preferred and crash basis created.
1491   
1492   if gap between bounds <="gap" variables can be flipped
1493   
1494   If "pivot" is
1495   0 No pivoting (so will just be choice of algorithm)
1496   1 Simple pivoting e.g. gub
1497   2 Mini iterations
1498*/
1499COINLIBAPI int COINLINKAGE
1500Cbc_crash(Cbc_Model * model, double gap,int pivot)
1501{
1502  const char prefix[] = "Cbc_C_Interface::Cbc_crash(): ";
1503//  const int  VERBOSE = 1;
1504  if (VERBOSE>0) printf("%s begin\n",prefix);
1505 
1506  int result = 0;
1507// cannot find names in Cbc, Osi, or OsiClp
1508//tbd  result = model->model_->crash(gap,pivot);
1509  printf("%s ERROR: NOT IMPLEMENTED\n",prefix);
1510
1511  if (VERBOSE>0) printf("%s return %i\n",prefix,result);
1512  return result;
1513}
1514/* If problem is primal feasible */
1515COINLIBAPI int COINLINKAGE
1516Cbc_primalFeasible(Cbc_Model * model)
1517{
1518  const char prefix[] = "Cbc_C_Interface::Cbc_primalFeasible(): ";
1519//  const int  VERBOSE = 1;
1520  if (VERBOSE>0) printf("%s begin\n",prefix);
1521 
1522  int result = 0;
1523  OsiSolverInterface * solver = model->model_->solver();
1524  result = solver->isProvenPrimalInfeasible() ? 0 : 1;
1525
1526  if (VERBOSE>0) printf("%s return %i\n",prefix,result);
1527  return result;
1528}
1529/* If problem is dual feasible */
1530COINLIBAPI int COINLINKAGE
1531Cbc_dualFeasible(Cbc_Model * model)
1532{
1533  const char prefix[] = "Cbc_C_Interface::Cbc_dualFeasible(): ";
1534//  const int  VERBOSE = 1;
1535  if (VERBOSE>0) printf("%s begin\n",prefix);
1536 
1537  int result = 0;
1538  OsiSolverInterface * solver = model->model_->solver();
1539  result = solver->isProvenDualInfeasible() ? 0 : 1;
1540
1541  if (VERBOSE>0) printf("%s return %i\n",prefix,result);
1542  return result;
1543}
1544/* Dual bound */
1545COINLIBAPI double COINLINKAGE
1546Cbc_dualBound(Cbc_Model * model)
1547{
1548  const char prefix[] = "Cbc_C_Interface::Cbc_dualBound(): ";
1549//  const int  VERBOSE = 1;
1550  if (VERBOSE>0) printf("%s begin\n",prefix);
1551 
1552  double result = 0;
1553// cannot find in Cbc, Osi, or OsiClp
1554//tbd  result = model->model_->dualBound();
1555  printf("%s ERROR: NOT IMPLEMENTED\n",prefix);
1556
1557  if (VERBOSE>0) printf("%s return %g\n",prefix,result);
1558  return result;
1559}
1560COINLIBAPI void COINLINKAGE
1561Cbc_setDualBound(Cbc_Model * model, double value)
1562{
1563  const char prefix[] = "Cbc_C_Interface::Cbc_setDualBound(): ";
1564//  const int  VERBOSE = 1;
1565  if (VERBOSE>0) printf("%s begin\n",prefix);
1566 
1567// cannot find names in Cbc, Osi, or OsiClp
1568//tbd  model->model_->setDualBound(value);
1569  printf("%s ERROR: NOT IMPLEMENTED\n",prefix);
1570
1571  if (VERBOSE>0) printf("%s return\n",prefix);
1572}
1573/* Infeasibility cost */
1574COINLIBAPI double COINLINKAGE
1575Cbc_infeasibilityCost(Cbc_Model * model)
1576{
1577  const char prefix[] = "Cbc_C_Interface::Cbc_infeasibilityCost(): ";
1578//  const int  VERBOSE = 1;
1579  if (VERBOSE>0) printf("%s begin\n",prefix);
1580 
1581  double result = 0;
1582// cannot find names in Cbc, Osi, or OsiClp
1583//tbd  result = model->model_->solver()->infeasibilityCost();
1584  printf("%s ERROR: NOT IMPLEMENTED\n",prefix);
1585
1586  if (VERBOSE>0) printf("%s return %g\n",prefix,result);
1587  return result;
1588}
1589COINLIBAPI void COINLINKAGE
1590Cbc_setInfeasibilityCost(Cbc_Model * model, double value)
1591{
1592  const char prefix[] = "Cbc_C_Interface::Cbc_setInfeasibilityCost(): ";
1593//  const int  VERBOSE = 1;
1594  if (VERBOSE>0) printf("%s begin\n",prefix);
1595 
1596// cannot find names in Cbc, Osi, or OsiClp
1597//tbd  model->model_->setInfeasibilityCost(value);
1598  printf("%s ERROR: NOT IMPLEMENTED\n",prefix);
1599
1600  if (VERBOSE>0) printf("%s return\n",prefix);
1601}
1602/* Perturbation:
1603   50  - switch on perturbation
1604   100 - auto perturb if takes too long (1.0e-6 largest nonzero)
1605   101 - we are perturbed
1606   102 - don't try perturbing again
1607   default is 100
1608   others are for playing
1609*/
1610COINLIBAPI int COINLINKAGE
1611Cbc_perturbation(Cbc_Model * model)
1612{
1613  const char prefix[] = "Cbc_C_Interface::Cbc_perturbation(): ";
1614//  const int  VERBOSE = 1;
1615  if (VERBOSE>0) printf("%s begin\n",prefix);
1616 
1617  int result = 0;
1618// cannot find names in Cbc, Osi, or OsiClp
1619//tbd  result = model->model_->perturbation();
1620  printf("%s ERROR: NOT IMPLEMENTED\n",prefix);
1621
1622  if (VERBOSE>0) printf("%s return %i\n",prefix,result);
1623  return result;
1624}
1625COINLIBAPI void COINLINKAGE
1626Cbc_setPerturbation(Cbc_Model * model, int value)
1627{
1628  const char prefix[] = "Cbc_C_Interface::Cbc_setPerturbation(): ";
1629//  const int  VERBOSE = 1;
1630  if (VERBOSE>0) printf("%s begin\n",prefix);
1631 
1632// cannot find names in Cbc, Osi, or OsiClp
1633//tbd  model->model_->setPerturbation(value);
1634  printf("%s ERROR: NOT IMPLEMENTED\n",prefix);
1635
1636  if (VERBOSE>0) printf("%s return\n",prefix);
1637}
1638/* Current (or last) algorithm */
1639COINLIBAPI int COINLINKAGE
1640Cbc_algorithm(Cbc_Model * model)
1641{
1642  const char prefix[] = "Cbc_C_Interface::Cbc_setPerturbation(): ";
1643//  const int  VERBOSE = 1;
1644  if (VERBOSE>0) printf("%s begin\n",prefix);
1645 
1646  int result = 0;
1647// cannot find names in Cbc, Osi, or OsiClp
1648//tbd  result = model->model_->algorithm();
1649  printf("%s ERROR: NOT IMPLEMENTED\n",prefix);
1650
1651  if (VERBOSE>0) printf("%s return %i\n",prefix,result);
1652  return result;
1653}
1654/* Set algorithm */
1655COINLIBAPI void COINLINKAGE
1656Cbc_setAlgorithm(Cbc_Model * model, int value)
1657{
1658  const char prefix[] = "Cbc_C_Interface::Cbc_setAlgorithm(): ";
1659//  const int  VERBOSE = 1;
1660  if (VERBOSE>0) printf("%s begin\n",prefix);
1661 
1662// cannot find names in Cbc, Osi, or OsiClp
1663//tbd  model->model_->setAlgorithm(value);
1664  printf("%s ERROR: NOT IMPLEMENTED\n",prefix);
1665
1666  if (VERBOSE>0) printf("%s return\n",prefix);
1667}
1668/* Sum of dual infeasibilities */
1669COINLIBAPI double COINLINKAGE
1670Cbc_sumDualInfeasibilities(Cbc_Model * model)
1671{
1672  const char prefix[] = "Cbc_C_Interface::Cbc_sumDualInfeasibilities(): ";
1673//  const int  VERBOSE = 1;
1674  if (VERBOSE>0) printf("%s begin\n",prefix);
1675 
1676  double result = 0;
1677// cannot find names in Cbc, Osi, or OsiClp
1678//tbd  result = model->model_->sumDualInfeasibilities();
1679  printf("%s ERROR: NOT IMPLEMENTED\n",prefix);
1680
1681  if (VERBOSE>0) printf("%s return %g\n",prefix,result);
1682  return result;
1683}
1684/* Number of dual infeasibilities */
1685COINLIBAPI int COINLINKAGE
1686Cbc_numberDualInfeasibilities(Cbc_Model * model)
1687{
1688  const char prefix[] = "Cbc_C_Interface::Cbc_numberDualInfeasibilities(): ";
1689//  const int  VERBOSE = 1;
1690  if (VERBOSE>0) printf("%s begin\n",prefix);
1691 
1692  int result = 0;
1693// cannot find names in Cbc, Osi, or OsiClp
1694//tbd  result = model->model_->numberDualInfeasibilities();
1695  printf("%s ERROR: NOT IMPLEMENTED\n",prefix);
1696
1697  if (VERBOSE>0) printf("%s return %i\n",prefix,result);
1698  return result;
1699}
1700/* Sum of primal infeasibilities */
1701COINLIBAPI double COINLINKAGE
1702Cbc_sumPrimalInfeasibilities(Cbc_Model * model)
1703{
1704  const char prefix[] = "Cbc_C_Interface::Cbc_sumPrimalInfeasibilities(): ";
1705//  const int  VERBOSE = 1;
1706  if (VERBOSE>0) printf("%s begin\n",prefix);
1707 
1708  double result = 0;
1709// cannot find names in Cbc, Osi, or OsiClp
1710//tbd result = model->model_->sumPrimalInfeasibilities();
1711  printf("%s ERROR: NOT IMPLEMENTED\n",prefix);
1712
1713  if (VERBOSE>0) printf("%s return %g\n",prefix,result);
1714  return result;
1715}
1716/* Number of primal infeasibilities */
1717COINLIBAPI int COINLINKAGE
1718Cbc_numberPrimalInfeasibilities(Cbc_Model * model)
1719{
1720  const char prefix[] = "Cbc_C_Interface::Cbc_numberPrimalInfeasibilities(): ";
1721//  const int  VERBOSE = 1;
1722  if (VERBOSE>0) printf("%s begin\n",prefix);
1723 
1724  int result = 0;
1725//tbd  result = model->model_->getContinuousInfeasibilities();
1726  printf("%s ERROR: NOT IMPLEMENTED\n",prefix);
1727
1728  if (VERBOSE>0) printf("%s return %i\n",prefix,result);
1729  return result;
1730}
1731/* Save model to file, returns 0 if success.  This is designed for
1732   use outside algorithms so does not save iterating arrays etc.
1733   It does not save any messaging information.
1734   Does not save scaling values.
1735   It does not know about all types of virtual functions.
1736*/
1737COINLIBAPI int COINLINKAGE
1738Cbc_saveModel(Cbc_Model * model, const char * fileName)
1739{
1740  const char prefix[] = "Cbc_C_Interface::Cbc_saveModel(): ";
1741//  const int  VERBOSE = 1;
1742  if (VERBOSE>0) printf("%s begin\n",prefix);
1743 
1744  int result = 0;
1745// there is a writeMPS method in Osi
1746//tbd  result = model->model_->saveModel(fileName);
1747  printf("%s ERROR: NOT IMPLEMENTED\n",prefix);
1748
1749  if (VERBOSE>0) printf("%s return %i\n",prefix,result);
1750  return result;
1751}
1752/* Restore model from file, returns 0 if success,
1753   deletes current model */
1754COINLIBAPI int COINLINKAGE
1755Cbc_restoreModel(Cbc_Model * model, const char * fileName)
1756{
1757  const char prefix[] = "Cbc_C_Interface::Cbc_restoreModel(): ";
1758//  const int  VERBOSE = 1;
1759  if (VERBOSE>0) printf("%s begin\n",prefix);
1760 
1761  int result = 0;
1762// there is a readMPS method in Osi
1763//tbd  result = model->model_->restoreModel(fileName);
1764  printf("%s ERROR: NOT IMPLEMENTED\n",prefix);
1765
1766  if (VERBOSE>0) printf("%s return %i\n",prefix,result);
1767  return result;
1768}
1769 
1770/** Call this to really test if a valid solution can be feasible
1771    Solution is number columns in size.
1772    If fixVariables true then bounds of continuous solver updated.
1773    Returns objective value (worse than cutoff if not feasible)
1774*/
1775COINLIBAPI void COINLINKAGE
1776Cbc_checkSolution(Cbc_Model * model)
1777{
1778  const char prefix[] = "Cbc_C_Interface::Cbc_checkSolution(): ";
1779//  const int  VERBOSE = 1;
1780  if (VERBOSE>0) printf("%s begin\n",prefix);
1781 
1782  // see CbcModel::checkSolution(double cutoff, const double * solution,
1783  //           bool fixVariables);
1784//  model->model_->checkSolution();
1785
1786  if (VERBOSE>0) printf("%s return\n",prefix);
1787  return;
1788}
1789/* Number of rows */
1790COINLIBAPI int COINLINKAGE
1791Cbc_getNumRows(Cbc_Model * model)
1792{
1793  const char prefix[] = "Cbc_C_Interface::Cbc_getNumRows(): ";
1794//  const int  VERBOSE = 1;
1795  if (VERBOSE>0) printf("%s begin\n",prefix);
1796 
1797  int result = 0;
1798  result = model->model_->getNumRows();
1799
1800  if (VERBOSE>0) printf("%s return %d\n",prefix, result);
1801  return result;
1802}
1803/* Number of columns */
1804COINLIBAPI int COINLINKAGE
1805Cbc_getNumCols(Cbc_Model * model)
1806{
1807  const char prefix[] = "Cbc_C_Interface::Cbc_getNumCols(): ";
1808//  const int  VERBOSE = 1;
1809  if (VERBOSE>0) printf("%s begin\n",prefix);
1810 
1811  int result = 0;
1812  result = model->model_->getNumCols();
1813
1814  if (VERBOSE>0) printf("%s return %d\n",prefix, result);
1815  return result;
1816}
1817/* Number of iterations */
1818COINLIBAPI int COINLINKAGE
1819Cbc_getIterationCount(Cbc_Model * model)
1820{
1821  const char prefix[] = "Cbc_C_Interface::Cbc_getIterationCount(): ";
1822//  const int  VERBOSE = 1;
1823  if (VERBOSE>0) printf("%s begin\n",prefix);
1824 
1825  int result = 0;
1826  result = model->model_->getIterationCount();
1827
1828  if (VERBOSE>0) printf("%s return %d\n",prefix, result);
1829  return result;
1830}
1831/* Are there a numerical difficulties? */
1832COINLIBAPI int COINLINKAGE
1833Cbc_isAbandoned(Cbc_Model * model)
1834{
1835  const char prefix[] = "Cbc_C_Interface::Cbc_isAbandoned(): ";
1836//  const int  VERBOSE = 1;
1837  if (VERBOSE>0) printf("%s begin\n",prefix);
1838 
1839  int result = 0;
1840  result = model->model_->isAbandoned() ? 1 : 0;
1841
1842  if (VERBOSE>0) printf("%s return %i\n",prefix,result);
1843  return result;
1844}
1845/* Is optimality proven? */
1846COINLIBAPI int COINLINKAGE
1847Cbc_isProvenOptimal(Cbc_Model * model)
1848{
1849  const char prefix[] = "Cbc_C_Interface::Cbc_isProvenOptimal(): ";
1850//  const int  VERBOSE = 1;
1851  if (VERBOSE>0) printf("%s begin\n",prefix);
1852 
1853  int result = 0;
1854  result = model->model_->isProvenOptimal() ? 1 : 0;
1855
1856  if (VERBOSE>0) printf("%s return %i\n",prefix,result);
1857  return result;
1858}
1859/* Is primal infeasiblity proven? */
1860COINLIBAPI int COINLINKAGE
1861Cbc_isProvenPrimalInfeasible(Cbc_Model * model)
1862{
1863  const char prefix[] = "Cbc_C_Interface::Cbc_isProvenPrimalInfeasible(): ";
1864//  const int  VERBOSE = 1;
1865  if (VERBOSE>0) printf("%s begin\n",prefix);
1866 
1867  int result = 0;
1868  OsiSolverInterface * solver = model->model_->solver();
1869  result = solver->isProvenPrimalInfeasible() ? 1 : 0;
1870
1871  if (VERBOSE>0) printf("%s return %i\n",prefix,result);
1872  return result;
1873}
1874/* Is dual infeasiblity proven? */
1875COINLIBAPI int COINLINKAGE
1876Cbc_isProvenDualInfeasible(Cbc_Model * model)
1877{
1878  const char prefix[] = "Cbc_C_Interface::Cbc_isProvenDualInfeasible(): ";
1879//  const int  VERBOSE = 1;
1880  if (VERBOSE>0) printf("%s begin\n",prefix);
1881 
1882  int result = 0;
1883  OsiSolverInterface * solver = model->model_->solver();
1884  result = solver->isProvenDualInfeasible() ? 1 : 0;
1885
1886  if (VERBOSE>0) printf("%s return %i\n",prefix,result);
1887  return result;
1888}
1889/* Is the given primal objective limit reached? */
1890COINLIBAPI int COINLINKAGE
1891Cbc_isPrimalObjectiveLimitReached(Cbc_Model * model) 
1892{
1893  const char prefix[] = "Cbc_C_Interface::Cbc_isPrimalObjectiveLimitReached(): ";
1894//  const int  VERBOSE = 1;
1895  if (VERBOSE>0) printf("%s begin\n",prefix);
1896 
1897  int result = 0;
1898  OsiSolverInterface * solver = model->model_->solver();
1899  result = solver->isPrimalObjectiveLimitReached() ? 1 : 0;
1900
1901  if (VERBOSE>0) printf("%s return %i\n",prefix,result);
1902  return result;
1903}
1904/* Is the given dual objective limit reached? */
1905COINLIBAPI int COINLINKAGE
1906Cbc_isDualObjectiveLimitReached(Cbc_Model * model) 
1907{
1908  const char prefix[] = "Cbc_C_Interface::Cbc_isDualObjectiveLimitReached(): ";
1909//  const int  VERBOSE = 1;
1910  if (VERBOSE>0) printf("%s begin\n",prefix);
1911 
1912  int result = 0;
1913  OsiSolverInterface * solver = model->model_->solver();
1914  result = solver->isDualObjectiveLimitReached() ? 1 : 0;
1915
1916  if (VERBOSE>0) printf("%s return %i\n",prefix,result);
1917  return result;
1918}
1919/* Iteration limit reached? */
1920COINLIBAPI int COINLINKAGE
1921Cbc_isIterationLimitReached(Cbc_Model * model)
1922{
1923  const char prefix[] = "Cbc_C_Interface::Cbc_isIterationLimitReached(): ";
1924//  const int  VERBOSE = 1;
1925  if (VERBOSE>0) printf("%s begin\n",prefix);
1926 
1927  int result = 0;
1928  OsiSolverInterface * solver = model->model_->solver();
1929  result = solver->isIterationLimitReached() ? 1 : 0;
1930
1931  if (VERBOSE>0) printf("%s return %i\n",prefix,result);
1932  return result;
1933}
1934/* Direction of optimization (1 - minimize, -1 - maximize, 0 - ignore */
1935COINLIBAPI double COINLINKAGE
1936Cbc_getObjSense(Cbc_Model * model)
1937{
1938  const char prefix[] = "Cbc_C_Interface::Cbc_getObjSense(): ";
1939//  const int  VERBOSE = 1;
1940  if (VERBOSE>0) printf("%s begin\n",prefix);
1941 
1942  double result = 0;
1943  result = model->model_->getObjSense();
1944
1945  if (VERBOSE>0) printf("%s return %g\n",prefix,result);
1946  return result;
1947}
1948/* Primal row solution */
1949COINLIBAPI const double * COINLINKAGE
1950Cbc_getRowActivity(Cbc_Model * model)
1951{
1952  const char prefix[] = "Cbc_C_Interface::Cbc_getRowActivity(): ";
1953//  const int  VERBOSE = 1;
1954  if (VERBOSE>0) printf("%s begin\n",prefix);
1955 
1956  const double * result = NULL;
1957  result = model->model_->getRowActivity();
1958
1959  if (VERBOSE>0) printf("%s return %p\n",prefix,result);
1960  return result;
1961}
1962/* Primal column solution */
1963COINLIBAPI const double * COINLINKAGE
1964Cbc_getColSolution(Cbc_Model * model)
1965{
1966  const char prefix[] = "Cbc_C_Interface::Cbc_getColSolution(): ";
1967//  const int  VERBOSE = 1;
1968  if (VERBOSE>0) printf("%s begin\n",prefix);
1969 
1970  const double * result = NULL;
1971  result = model->model_->getColSolution();
1972
1973  if (VERBOSE>0) printf("%s return %p\n",prefix,result);
1974  return result;
1975}
1976COINLIBAPI void COINLINKAGE
1977Cbc_setColSolution(Cbc_Model * model, const double * input)
1978{
1979  const char prefix[] = "Cbc_C_Interface::Cbc_setColSolution(): ";
1980//  const int  VERBOSE = 1;
1981  if (VERBOSE>0) printf("%s begin\n",prefix);
1982 
1983  OsiSolverInterface * solver = model->model_->solver();
1984  solver->setColSolution(input);
1985
1986  if (VERBOSE>0) printf("%s return\n",prefix);
1987  return;
1988}
1989/* Dual row solution */
1990COINLIBAPI const double * COINLINKAGE
1991Cbc_getRowPrice(Cbc_Model * model)
1992{
1993  const char prefix[] = "Cbc_C_Interface::Cbc_getRowPrice(): ";
1994//  const int  VERBOSE = 1;
1995  if (VERBOSE>0) printf("%s begin\n",prefix);
1996 
1997  const double * result = NULL;
1998  result = model->model_->getRowPrice();
1999
2000  if (VERBOSE>0) printf("%s return %p\n",prefix,result);
2001  return result;
2002}
2003/* Reduced costs */
2004COINLIBAPI const double * COINLINKAGE
2005Cbc_getReducedCost(Cbc_Model * model)
2006{
2007  const char prefix[] = "Cbc_C_Interface::Cbc_getReducedCost(): ";
2008//  const int  VERBOSE = 1;
2009  if (VERBOSE>0) printf("%s begin\n",prefix);
2010 
2011  const double * result = NULL;
2012  result = model->model_->getReducedCost();
2013
2014  if (VERBOSE>0) printf("%s return %p\n",prefix,result);
2015  return result;
2016}
2017/* Row lower */
2018COINLIBAPI const double * COINLINKAGE
2019Cbc_getRowLower(Cbc_Model * model)
2020{
2021  const char prefix[] = "Cbc_C_Interface::Cbc_getRowLower(): ";
2022//  const int  VERBOSE = 1;
2023  if (VERBOSE>0) printf("%s begin\n",prefix);
2024 
2025  const double * result = NULL;
2026  result = model->model_->getRowLower();
2027
2028  if (VERBOSE>0) printf("%s return %p\n",prefix,result);
2029  return result;
2030}
2031/* Row upper  */
2032COINLIBAPI const double * COINLINKAGE
2033Cbc_getRowUpper(Cbc_Model * model)
2034{
2035  const char prefix[] = "Cbc_C_Interface::Cbc_getRowUpper(): ";
2036//  const int  VERBOSE = 1;
2037  if (VERBOSE>0) printf("%s begin\n",prefix);
2038 
2039  const double * result = NULL;
2040  result = model->model_->getRowUpper();
2041
2042  if (VERBOSE>0) printf("%s return %p\n",prefix,result);
2043  return result;
2044}
2045/* Objective Coefficients */
2046COINLIBAPI const double * COINLINKAGE
2047Cbc_getObjCoefficients(Cbc_Model * model)
2048{
2049  const char prefix[] = "Cbc_C_Interface::Cbc_getObjCoefficients(): ";
2050//  const int  VERBOSE = 1;
2051  if (VERBOSE>0) printf("%s begin\n",prefix);
2052 
2053  const double * result = NULL;
2054  result = model->model_->getObjCoefficients();
2055
2056  if (VERBOSE>0) printf("%s return %p\n",prefix,result);
2057  return result;
2058}
2059/* Column Lower */
2060COINLIBAPI const double * COINLINKAGE
2061Cbc_getColLower(Cbc_Model * model)
2062{
2063  const char prefix[] = "Cbc_C_Interface::Cbc_getColLower(): ";
2064//  const int  VERBOSE = 1;
2065  if (VERBOSE>0) printf("%s begin\n",prefix);
2066 
2067  const double * result = NULL;
2068  result = model->model_->getColLower();
2069
2070  if (VERBOSE>0) printf("%s return %p\n",prefix,result);
2071  return result;
2072}
2073/* Column Upper */
2074COINLIBAPI const double * COINLINKAGE
2075Cbc_getColUpper(Cbc_Model * model)
2076{
2077  const char prefix[] = "Cbc_C_Interface::Cbc_getColUpper(): ";
2078//  const int  VERBOSE = 1;
2079  if (VERBOSE>0) printf("%s begin\n",prefix);
2080 
2081  const double * result = NULL;
2082  result = model->model_->getColUpper();
2083
2084  if (VERBOSE>0) printf("%s return %p\n",prefix,result);
2085  return result;
2086}
2087/* Objective value */
2088COINLIBAPI double COINLINKAGE
2089Cbc_getObjValue(Cbc_Model * model)
2090{
2091  const char prefix[] = "Cbc_C_Interface::Cbc_getObjValue(): ";
2092//  const int  VERBOSE = 1;
2093  if (VERBOSE>0) printf("%s begin\n",prefix);
2094 
2095  double result = 0;
2096  result = model->model_->getObjValue();
2097
2098  if (VERBOSE>0) printf("%s return %g\n",prefix,result);
2099  return result;
2100}
2101/* Print model */
2102COINLIBAPI void COINLINKAGE
2103Cbc_printModel(Cbc_Model * model, const char * argPrefix)
2104{
2105  const char prefix[] = "Cbc_C_Interface::Cbc_printModel(): ";
2106  const int  VERBOSE = 4;
2107  if (VERBOSE>0) printf("%s begin\n",prefix);
2108 
2109  CbcModel *cbc_model = model->model_;
2110  int numrows    = cbc_model->getNumRows();
2111  int numcols    = cbc_model->getNumCols();
2112  int numelem    = cbc_model->getNumElements();
2113  const CoinPackedMatrix * matrix = cbc_model->solver()->getMatrixByCol();
2114  const CoinBigIndex     * start  = matrix->getVectorStarts();
2115  const int              * index  = matrix->getIndices();
2116  const double           * value  = matrix->getElements();
2117  const double           * collb  = cbc_model->getColLower();
2118  const double           * colub  = cbc_model->getColUpper();
2119  const double           * obj    = cbc_model->getObjCoefficients();
2120  const double           * rowlb  = cbc_model->getRowLower();
2121  const double           * rowub  = cbc_model->getRowUpper();
2122
2123  printf("%s numcols = %i, numrows = %i, numelem = %i\n", 
2124    argPrefix, numcols, numrows, numelem);
2125  printf("%s model = %p, start = %p, index = %p, value = %p\n",
2126    argPrefix, model, start, index, value);
2127  matrix->dumpMatrix(NULL);
2128  {
2129    int i;
2130    for (i=0; i<=numcols; i++) 
2131      printf("%s start[%i] = %i\n", argPrefix, i, start[i]);
2132    for (i=0; i< numelem; i++)
2133      printf("%s index[%i] = %i, value[%i] = %g\n",
2134        argPrefix, i, index[i], i, value[i]);
2135  }
2136 
2137  printf("%s collb = %p, colub = %p, obj = %p, rowlb = %p, rowub = %p\n",
2138    argPrefix, collb, colub, obj, rowlb, rowub);
2139  printf("%s optimization direction = %g\n",argPrefix, Cbc_optimizationDirection(model));
2140  printf("  (1 - minimize, -1 - maximize, 0 - ignore)\n");
2141  {
2142    int i;
2143    for (i=0; i<numcols; i++) 
2144      printf("%s collb[%i] = %g, colub[%i] = %g, obj[%i] = %g\n",
2145        argPrefix, i, collb[i], i, colub[i], i, obj[i]);
2146    for (i=0; i< numrows; i++)
2147      printf("%s rowlb[%i] = %g, rowub[%i] = %g\n",
2148        argPrefix, i, rowlb[i], i, rowub[i]);
2149  }
2150
2151  if (VERBOSE>0) printf("%s return\n",prefix);
2152}  // Cbc_printModel()
2153
2154COINLIBAPI int COINLINKAGE
2155Cbc_isInteger(Cbc_Model * model, int i)
2156{
2157  const char prefix[] = "Cbc_C_Interface::Cbc_isInteger(): ";
2158//  const int  VERBOSE = 1;
2159  if (VERBOSE>0) printf("%s begin\n",prefix);
2160 
2161  bool result = false;
2162  result = model->model_->isInteger(i);
2163
2164  if (VERBOSE>0) printf("%s return %i\n",prefix, result);
2165  return (result) ? 1 : 0;
2166}
2167
2168COINLIBAPI double COINLINKAGE
2169Cbc_cpuTime(Cbc_Model * model)
2170{
2171  const char prefix[] = "Cbc_C_Interface::Cbc_cpuTime(): ";
2172//  const int  VERBOSE = 1;
2173  if (VERBOSE>0) printf("%s begin\n",prefix);
2174 
2175  double result = 0;
2176  result = CoinCpuTime() ;
2177
2178  if (VERBOSE>0) printf("%s return %g\n",prefix,result);
2179  return result;
2180}
2181/** Number of nodes explored in B&B tree */
2182COINLIBAPI int COINLINKAGE Cbc_getNodeCount(Cbc_Model * model)
2183{
2184  const char prefix[] = "Cbc_C_Interface::Cbc_getNodeCount(): ";
2185//  const int  VERBOSE = 1;
2186  if (VERBOSE>0) printf("%s begin\n",prefix);
2187 
2188  int result = 0;
2189  result = model->model_->getNodeCount() ;
2190
2191  if (VERBOSE>0) printf("%s return %i\n",prefix,result);
2192  return result;
2193}
2194/** Return a copy of this model */
2195COINLIBAPI Cbc_Model * COINLINKAGE Cbc_clone(Cbc_Model * model)
2196{
2197  const char prefix[] = "Cbc_C_Interface::Cbc_clone(): ";
2198  const int  VERBOSE = 1;
2199  if (VERBOSE>0) printf("%s begin\n",prefix);
2200 
2201  Cbc_Model * result = new Cbc_Model;
2202  result->model_     = new CbcModel(*(model->model_));
2203  result->solver_    =  dynamic_cast< OsiClpSolverInterface*> (result->model_->solver());
2204  result->handler_   = NULL;
2205
2206  if (VERBOSE>0) printf("%s return\n",prefix);
2207  return model;
2208}
2209/** Set this the variable to be continuous */
2210COINLIBAPI Cbc_Model * COINLINKAGE Cbc_setContinuous(Cbc_Model * model, int iColumn)
2211{
2212  const char prefix[] = "Cbc_C_Interface::Cbc_setContinuous(): ";
2213//  const int  VERBOSE = 1;
2214  if (VERBOSE>0) printf("%s begin\n",prefix);
2215 
2216  model->model_->solver()->setContinuous(iColumn);
2217
2218  if (VERBOSE>0) printf("%s return\n",prefix);
2219  return model;
2220}
2221/* Delete all object information */
2222COINLIBAPI void  COINLINKAGE
2223Cbc_deleteObjects(Cbc_Model * model)
2224{
2225  const char prefix[] = "Cbc_C_Interface::Cbc_deleteObjects(): ";
2226//  const int  VERBOSE = 2;
2227  if (VERBOSE>0) printf("%s begin\n",prefix);
2228
2229  model->model_->deleteObjects();
2230
2231  if (VERBOSE>0) printf("%s return\n",prefix);
2232  return;
2233}
2234/* Add an SOS constraint to the model */
2235COINLIBAPI void  COINLINKAGE
2236Cbc_addSOS(Cbc_Model * model, int numberMembers,
2237           const int * which, const double * weights, int identifier, int type)
2238{
2239  const char prefix[] = "Cbc_C_Interface::Cbc_addSOS(): ";
2240//  const int  VERBOSE = 2;
2241  if (VERBOSE>0) printf("%s begin\n",prefix);
2242  if (VERBOSE>1) {
2243    int i;
2244    printf("%s numberMembers = %i, identifier = %i, type = %i\n",
2245      prefix,numberMembers, identifier, type); fflush(stdout);
2246    for (i=0;i<numberMembers;i++) 
2247      printf("%s which[%i] = %d, weights[%i] = %g\n",
2248        prefix, i, which[i], i, weights[i]); fflush(stdout);
2249  }
2250 
2251  CbcObject ** objects = new CbcObject * [1];
2252  if (VERBOSE>1) printf("%s new CbcSOS()\n",prefix);
2253  objects[0] = new CbcSOS(model->model_,numberMembers,which,weights,identifier,type);
2254  if (objects[0] == NULL) {
2255    printf("%s ERROR: objects[0] == NULL\n",prefix); fflush(stdout);
2256    assert(objects[0] != NULL);
2257  }
2258  if (VERBOSE>1) printf("%s calling addObjects()\n",prefix);
2259  fflush(stdout);
2260  model->model_->addObjects(1, objects);
2261  if (VERBOSE>1) printf("%s finished addObjects()\n",prefix);
2262  delete objects[0]; 
2263  delete [] objects;
2264
2265  if (VERBOSE>0) printf("%s return\n",prefix);
2266  return;
2267}
2268/* Print the solution */
2269COINLIBAPI void  COINLINKAGE
2270Cbc_printSolution(Cbc_Model * model)
2271{
2272  {
2273    //
2274    //  Now to print out row solution.  The methods used return const
2275    //  pointers - which is of course much more virtuous.
2276    // 
2277    //  This version just does non-zero columns
2278    //
2279   
2280    // * Rows
2281   
2282    int numberRows = Cbc_getNumRows(model);
2283    int iRow;
2284   
2285   
2286    const double * rowPrimal = Cbc_getRowActivity(model);
2287    // * Alternatively getReducedCost(model)
2288    const double * rowDual = Cbc_getRowPrice(model);
2289    // * Alternatively getColLower(model)
2290    const double * rowLower = Cbc_getRowLower(model);
2291    // * Alternatively getColUpper(model)
2292    const double * rowUpper = Cbc_getRowUpper(model);
2293    printf("--------------------------------------\n");
2294
2295    // * If we have not kept names (parameter to readMps) this will be 0
2296  //    assert(Cbc_lengthNames(model));
2297   
2298    printf("                       Primal          Dual         Lower         Upper\n");
2299    for (iRow=0;iRow<numberRows;iRow++) {
2300      double value;
2301      value = rowPrimal[iRow];
2302      if (value>1.0e-8||value<-1.0e-8) {
2303        char name[20];
2304  //            Cbc_columnName(model,iColumn,name);
2305        sprintf(name,"ROW%5i",iRow);
2306        printf("%6d %8s",iRow,name);
2307        printf(" %13g",rowPrimal[iRow]);
2308        printf(" %13g",rowDual[iRow]);
2309        printf(" %13g",rowLower[iRow]);
2310        printf(" %13g",rowUpper[iRow]);
2311        printf("\n");
2312      }
2313    }
2314    printf("--------------------------------------\n");
2315  }
2316  {
2317    //
2318    //  Now to print out column solution.  The methods used return const
2319    //  pointers - which is of course much more virtuous.
2320    // 
2321    //  This version just does non-zero columns
2322    //
2323    //
2324   
2325    // * Columns
2326   
2327    int numberColumns = Cbc_numberColumns(model);
2328    int iColumn;
2329   
2330   
2331    // * Alternatively getColSolution(model)
2332    const double * columnPrimal = Cbc_getColSolution(model);
2333    // * Alternatively getReducedCost(model)
2334    const double * columnDual = Cbc_getReducedCost(model);
2335    // * Alternatively getColLower(model)
2336    const double * columnLower = Cbc_getColLower(model);
2337    // * Alternatively getColUpper(model)
2338    const double * columnUpper = Cbc_getColUpper(model);
2339    // * Alternatively getObjCoefficients(model)
2340    const double * columnObjective = Cbc_getObjCoefficients(model);
2341
2342    const char * isInteger = Cbc_integerInformation(model);
2343
2344    printf("--------------------------------------\n");
2345
2346    // * If we have not kept names (parameter to readMps) this will be 0
2347//    assert(Cbc_lengthNames(model));
2348   
2349    printf("                       Primal          Dual         Lower         Upper          Cost     isInteger\n");
2350    for (iColumn=0;iColumn<numberColumns;iColumn++) {
2351      double value;
2352      value = columnPrimal[iColumn];
2353      if (value>1.0e-8||value<-1.0e-8) {
2354        char name[20];
2355//              Cbc_columnName(model,iColumn,name);
2356        sprintf(name,"COL%5i",iColumn);
2357        printf("%6d %8s",iColumn,name);
2358        printf(" %13g",columnPrimal[iColumn]);
2359        printf(" %13g",columnDual[iColumn]);
2360        printf(" %13g",columnLower[iColumn]);
2361        printf(" %13g",columnUpper[iColumn]);
2362        printf(" %13g",columnObjective[iColumn]);
2363        printf(" %13i",isInteger[iColumn]);
2364        printf("\n");
2365      }
2366    }
2367    printf("--------------------------------------\n");
2368  }
2369  if (0) Cbc_printModel(model, "cbc::main(): ");
2370  return;
2371}
2372#if defined(__MWERKS__)
2373#pragma export off
2374#endif
Note: See TracBrowser for help on using the repository browser.