source: trunk/Cbc/src/Cbc_C_Interface.cpp @ 487

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

verbosity

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