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

Last change on this file since 1461 was 1432, checked in by bjarni, 10 years ago

Added extra return at end of each source file where needed, to remove possible linefeed conflicts (NightlyBuild? errors)

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