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

Last change on this file since 1573 was 1573, checked in by lou, 8 years ago

Change to EPL license notice.

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