source: stable/2.8/Cbc/src/Cbc_C_Interface.cpp @ 1888

Last change on this file since 1888 was 1888, checked in by stefan, 6 years ago

sync with trunk rev 1887

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