source: trunk/Clp/src/Clp_C_Interface.cpp @ 2019

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

add function Clp_freeRay to C interface to free a ray given by Clp_infeasibility/unboundedRay; add functions to get Clp version number from library

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 38.6 KB
RevLine 
[1665]1// $Id: Clp_C_Interface.cpp 2019 2014-01-31 05:18:01Z stefan $
[241]2// Copyright (C) 2003, International Business Machines
3// Corporation and others.  All Rights Reserved.
[1665]4// This code is licensed under the terms of the Eclipse Public License (EPL).
[241]5
6
7#include "CoinPragma.hpp"
8
[1231]9#include <cmath>
10#include <cstring>
[241]11
12#include "CoinHelperFunctions.hpp"
[2019]13#include "ClpConfig.h"
[241]14#include "ClpSimplex.hpp"
[891]15#include "ClpInterior.hpp"
[1480]16#ifndef SLIM_CLP
17#include "Idiot.hpp"
18#endif
[241]19#include <cfloat>
[429]20// Get C stuff but with extern C
21#define CLP_EXTERN_C
22#include "Coin_C_defines.h"
[241]23
[441]24/// To allow call backs
[242]25class CMessageHandler : public CoinMessageHandler {
[1525]26
[242]27public:
[1525]28     /**@name Overrides */
29     //@{
30     virtual int print();
31     //@}
32     /**@name set and get */
33     //@{
34     /// Model
35     const Clp_Simplex * model() const;
36     void setModel(Clp_Simplex * model);
37     /// Call back
38     void setCallBack(clp_callback callback);
39     //@}
[242]40
[1525]41     /**@name Constructors, destructor */
42     //@{
43     /** Default constructor. */
44     CMessageHandler();
45     /// Constructor with pointer to model
46     CMessageHandler(Clp_Simplex * model,
47                     FILE * userPointer = NULL);
48     /** Destructor */
49     virtual ~CMessageHandler();
50     //@}
[242]51
[1525]52     /**@name Copy method */
53     //@{
54     /** The copy constructor. */
55     CMessageHandler(const CMessageHandler&);
56     /** The copy constructor from an CoinSimplexMessageHandler. */
57     CMessageHandler(const CoinMessageHandler&);
58
59     CMessageHandler& operator=(const CMessageHandler&);
60     /// Clone
61     virtual CoinMessageHandler * clone() const ;
62     //@}
63
64
[242]65protected:
[1525]66     /**@name Data members
67        The data members are protected to allow access for derived classes. */
68     //@{
69     /// Pointer back to model
70     Clp_Simplex * model_;
71     /// call back
72     clp_callback callback_;
73     //@}
[242]74};
75
76
77//-------------------------------------------------------------------
[1525]78// Default Constructor
[242]79//-------------------------------------------------------------------
[1525]80CMessageHandler::CMessageHandler ()
81     : CoinMessageHandler(),
82       model_(NULL),
83       callback_(NULL)
[242]84{
85}
86
87//-------------------------------------------------------------------
[1525]88// Copy constructor
[242]89//-------------------------------------------------------------------
[1525]90CMessageHandler::CMessageHandler (const CMessageHandler & rhs)
91     : CoinMessageHandler(rhs),
92       model_(rhs.model_),
93       callback_(rhs.callback_)
94{
[242]95}
96
[1525]97CMessageHandler::CMessageHandler (const CoinMessageHandler & rhs)
98     : CoinMessageHandler(rhs),
99       model_(NULL),
100       callback_(NULL)
101{
[242]102}
103
104// Constructor with pointer to model
105CMessageHandler::CMessageHandler(Clp_Simplex * model,
[1525]106                                 FILE * )
107     : CoinMessageHandler(),
108       model_(model),
109       callback_(NULL)
[242]110{
111}
112
113//-------------------------------------------------------------------
[1525]114// Destructor
[242]115//-------------------------------------------------------------------
116CMessageHandler::~CMessageHandler ()
117{
118}
119
120//----------------------------------------------------------------
[1525]121// Assignment operator
[242]122//-------------------------------------------------------------------
123CMessageHandler &
124CMessageHandler::operator=(const CMessageHandler& rhs)
125{
[1525]126     if (this != &rhs) {
127          CoinMessageHandler::operator=(rhs);
128          model_ = rhs.model_;
129          callback_ = rhs.callback_;
130     }
131     return *this;
[242]132}
133//-------------------------------------------------------------------
134// Clone
135//-------------------------------------------------------------------
136CoinMessageHandler * CMessageHandler::clone() const
137{
[1525]138     return new CMessageHandler(*this);
[242]139}
140
[1525]141int
[242]142CMessageHandler::print()
143{
[1525]144     if (callback_) {
145          int messageNumber = currentMessage().externalNumber();
146          if (currentSource() != "Clp")
147               messageNumber += 1000000;
148          int i;
149          int nDouble = numberDoubleFields();
150          assert (nDouble <= 10);
151          double vDouble[10];
152          for (i = 0; i < nDouble; i++)
153               vDouble[i] = doubleValue(i);
154          int nInt = numberIntFields();
155          assert (nInt <= 10);
156          int vInt[10];
157          for (i = 0; i < nInt; i++)
158               vInt[i] = intValue(i);
159          int nString = numberStringFields();
160          assert (nString <= 10);
161          char * vString[10];
162          for (i = 0; i < nString; i++) {
163               std::string value = stringValue(i);
164               vString[i] = CoinStrdup(value.c_str());
165          }
166          callback_(model_, messageNumber,
167                    nDouble, vDouble,
168                    nInt, vInt,
169                    nString, vString);
170          for (i = 0; i < nString; i++)
171               free(vString[i]);
172
173     }
174     return CoinMessageHandler::print();
[242]175}
176const Clp_Simplex *
177CMessageHandler::model() const
178{
[1525]179     return model_;
[242]180}
[1525]181void
[242]182CMessageHandler::setModel(Clp_Simplex * model)
183{
[1525]184     model_ = model;
[242]185}
186// Call back
[1525]187void
[242]188CMessageHandler::setCallBack(clp_callback callback)
189{
[1525]190     callback_ = callback;
[242]191}
192
[241]193#include "Clp_C_Interface.h"
194#include <string>
195#include <stdio.h>
196#include <iostream>
197
[1525]198#if defined(__MWERKS__)
[431]199#pragma export on
200#endif
[2019]201
202
203COINLIBAPI const char* COINLINKAGE
204Clp_Version(void)
205{
206   return CLP_VERSION;
207}
208COINLIBAPI int COINLINKAGE
209Clp_VersionMajor(void)
210{
211   return CLP_VERSION_MAJOR;
212}
213COINLIBAPI int COINLINKAGE Clp_VersionMinor(void)
214{
215   return CLP_VERSION_MINOR;
216}
217COINLIBAPI int COINLINKAGE Clp_VersionRelease(void)
218{
219   return CLP_VERSION_RELEASE;
220}
221
[241]222/* Default constructor */
[1525]223COINLIBAPI Clp_Simplex *  COINLINKAGE
[241]224Clp_newModel()
225{
[1525]226     Clp_Simplex * model = new Clp_Simplex;
227     model->model_ = new ClpSimplex();
228     model->handler_ = NULL;
229     return model;
[241]230}
231/* Destructor */
[1525]232COINLIBAPI void COINLINKAGE
[241]233Clp_deleteModel(Clp_Simplex * model)
234{
[1525]235     delete model->model_;
236     delete model->handler_;
237     delete model;
[241]238}
239
240/* Loads a problem (the constraints on the
241    rows are given by lower and upper bounds). If a pointer is NULL then the
242    following values are the default:
243    <ul>
244    <li> <code>colub</code>: all columns have upper bound infinity
[1525]245    <li> <code>collb</code>: all columns have lower bound 0
[241]246    <li> <code>rowub</code>: all rows have upper bound infinity
247    <li> <code>rowlb</code>: all rows have lower bound -infinity
248    <li> <code>obj</code>: all variables have 0 objective coefficient
249    </ul>
250*/
251/* Just like the other loadProblem() method except that the matrix is
252   given in a standard column major ordered format (without gaps). */
[1525]253COINLIBAPI void COINLINKAGE
[241]254Clp_loadProblem (Clp_Simplex * model,  const int numcols, const int numrows,
[1525]255                 const CoinBigIndex * start, const int* index,
256                 const double* value,
257                 const double* collb, const double* colub,
258                 const double* obj,
259                 const double* rowlb, const double* rowub)
[241]260{
[1525]261     const char prefix[] = "Clp_c_Interface::Clp_loadProblem(): ";
262     const int  verbose = 0;
263     if (verbose > 1) {
264          printf("%s numcols = %i, numrows = %i\n",
265                 prefix, numcols, numrows);
266          printf("%s model = %p, start = %p, index = %p, value = %p\n",
267                 prefix, reinterpret_cast<const void *>(model), reinterpret_cast<const void *>(start), reinterpret_cast<const void *>(index), reinterpret_cast<const void *>(value));
268          printf("%s collb = %p, colub = %p, obj = %p, rowlb = %p, rowub = %p\n",
269                 prefix, reinterpret_cast<const void *>(collb), reinterpret_cast<const void *>(colub), reinterpret_cast<const void *>(obj), reinterpret_cast<const void *>(rowlb), reinterpret_cast<const void *>(rowub));
270     }
271     model->model_->loadProblem(numcols, numrows, start, index, value,
272                                collb, colub, obj, rowlb, rowub);
[241]273}
[891]274/* read quadratic part of the objective (the matrix part) */
[1525]275COINLIBAPI void COINLINKAGE
276Clp_loadQuadraticObjective(Clp_Simplex * model,
277                           const int numberColumns,
[891]278                           const CoinBigIndex * start,
[1525]279                           const int * column,
[891]280                           const double * element)
281{
282
[1525]283     model->model_->loadQuadraticObjective(numberColumns,
284                                           start, column, element);
[891]285
286}
[241]287/* Read an mps file from the given filename */
[1525]288COINLIBAPI int COINLINKAGE
289Clp_readMps(Clp_Simplex * model, const char *filename,
290            int keepNames,
291            int ignoreErrors)
[241]292{
[1525]293     return model->model_->readMps(filename, keepNames != 0, ignoreErrors != 0);
[241]294}
295/* Copy in integer informations */
[1525]296COINLIBAPI void COINLINKAGE
297Clp_copyInIntegerInformation(Clp_Simplex * model, const char * information)
[241]298{
[1525]299     model->model_->copyInIntegerInformation(information);
[241]300}
301/* Drop integer informations */
[1525]302COINLIBAPI void COINLINKAGE
[241]303Clp_deleteIntegerInformation(Clp_Simplex * model)
304{
[1525]305     model->model_->deleteIntegerInformation();
[241]306}
307/* Resizes rim part of model  */
[1525]308COINLIBAPI void COINLINKAGE
[241]309Clp_resize (Clp_Simplex * model, int newNumberRows, int newNumberColumns)
310{
[1525]311     model->model_->resize(newNumberRows, newNumberColumns);
[241]312}
313/* Deletes rows */
[1525]314COINLIBAPI void COINLINKAGE
[241]315Clp_deleteRows(Clp_Simplex * model, int number, const int * which)
316{
[1525]317     model->model_->deleteRows(number, which);
[241]318}
319/* Add rows */
[1525]320COINLIBAPI void COINLINKAGE
321Clp_addRows(Clp_Simplex * model, int number, const double * rowLower,
322            const double * rowUpper,
323            const int * rowStarts, const int * columns,
324            const double * elements)
[241]325{
[1525]326     model->model_->addRows(number, rowLower, rowUpper, rowStarts, columns, elements);
[241]327}
328
329/* Deletes columns */
[1525]330COINLIBAPI void COINLINKAGE
[241]331Clp_deleteColumns(Clp_Simplex * model, int number, const int * which)
332{
[1525]333     model->model_->deleteColumns(number, which);
[241]334}
335/* Add columns */
[1525]336COINLIBAPI void COINLINKAGE
337Clp_addColumns(Clp_Simplex * model, int number, const double * columnLower,
338               const double * columnUpper,
339               const double * objective,
340               const int * columnStarts, const int * rows,
341               const double * elements)
[241]342{
[1525]343     model->model_->addColumns(number, columnLower, columnUpper, objective,
344                               columnStarts, rows, elements);
[241]345}
[409]346/* Change row lower bounds */
[1525]347COINLIBAPI void COINLINKAGE
348Clp_chgRowLower(Clp_Simplex * model, const double * rowLower)
[409]349{
[1525]350     model->model_->chgRowLower(rowLower);
[409]351}
352/* Change row upper bounds */
[1525]353COINLIBAPI void COINLINKAGE
354Clp_chgRowUpper(Clp_Simplex * model, const double * rowUpper)
[409]355{
[1525]356     model->model_->chgRowUpper(rowUpper);
[409]357}
358/* Change column lower bounds */
[1525]359COINLIBAPI void COINLINKAGE
360Clp_chgColumnLower(Clp_Simplex * model, const double * columnLower)
[409]361{
[1525]362     model->model_->chgColumnLower(columnLower);
[409]363}
364/* Change column upper bounds */
[1525]365COINLIBAPI void COINLINKAGE
366Clp_chgColumnUpper(Clp_Simplex * model, const double * columnUpper)
[409]367{
[1525]368     model->model_->chgColumnUpper(columnUpper);
[409]369}
370/* Change objective coefficients */
[1525]371COINLIBAPI void COINLINKAGE
372Clp_chgObjCoefficients(Clp_Simplex * model, const double * objIn)
[409]373{
[1525]374     model->model_->chgObjCoefficients(objIn);
[409]375}
[241]376/* Drops names - makes lengthnames 0 and names empty */
[1525]377COINLIBAPI void COINLINKAGE
[241]378Clp_dropNames(Clp_Simplex * model)
379{
[1525]380     model->model_->dropNames();
[241]381}
382/* Copies in names */
[1525]383COINLIBAPI void COINLINKAGE
[241]384Clp_copyNames(Clp_Simplex * model, const char * const * rowNamesIn,
[1525]385              const char * const * columnNamesIn)
[241]386{
[1525]387     int iRow;
388     std::vector<std::string> rowNames;
389     int numberRows = model->model_->numberRows();
390     rowNames.reserve(numberRows);
391     for (iRow = 0; iRow < numberRows; iRow++) {
392          rowNames.push_back(rowNamesIn[iRow]);
393     }
394
395     int iColumn;
396     std::vector<std::string> columnNames;
397     int numberColumns = model->model_->numberColumns();
398     columnNames.reserve(numberColumns);
399     for (iColumn = 0; iColumn < numberColumns; iColumn++) {
400          columnNames.push_back(columnNamesIn[iColumn]);
401     }
402     model->model_->copyNames(rowNames, columnNames);
[241]403}
404
405/* Number of rows */
[1525]406COINLIBAPI int COINLINKAGE
[241]407Clp_numberRows(Clp_Simplex * model)
408{
[1525]409     return model->model_->numberRows();
[241]410}
411/* Number of columns */
[1525]412COINLIBAPI int COINLINKAGE
[241]413Clp_numberColumns(Clp_Simplex * model)
414{
[1525]415     return model->model_->numberColumns();
[241]416}
417/* Primal tolerance to use */
[1525]418COINLIBAPI double COINLINKAGE
[241]419Clp_primalTolerance(Clp_Simplex * model)
420{
[1525]421     return model->model_->primalTolerance();
[241]422}
[1525]423COINLIBAPI void COINLINKAGE
424Clp_setPrimalTolerance(Clp_Simplex * model,  double value)
[241]425{
[1525]426     model->model_->setPrimalTolerance(value);
[241]427}
428/* Dual tolerance to use */
[1525]429COINLIBAPI double COINLINKAGE
[241]430Clp_dualTolerance(Clp_Simplex * model)
431{
[1525]432     return model->model_->dualTolerance();
[241]433}
[1525]434COINLIBAPI void COINLINKAGE
435Clp_setDualTolerance(Clp_Simplex * model,  double value)
[241]436{
[1525]437     model->model_->setDualTolerance(value);
[241]438}
439/* Dual objective limit */
[1525]440COINLIBAPI double COINLINKAGE
[241]441Clp_dualObjectiveLimit(Clp_Simplex * model)
442{
[1525]443     return model->model_->dualObjectiveLimit();
[241]444}
[1525]445COINLIBAPI void COINLINKAGE
[241]446Clp_setDualObjectiveLimit(Clp_Simplex * model, double value)
447{
[1525]448     model->model_->setDualObjectiveLimit(value);
[241]449}
450/* Objective offset */
[1525]451COINLIBAPI double COINLINKAGE
[241]452Clp_objectiveOffset(Clp_Simplex * model)
453{
[1525]454     return model->model_->objectiveOffset();
[241]455}
[1525]456COINLIBAPI void COINLINKAGE
[241]457Clp_setObjectiveOffset(Clp_Simplex * model, double value)
458{
[1525]459     model->model_->setObjectiveOffset(value);
[241]460}
461/* Fills in array with problem name  */
[1525]462COINLIBAPI void COINLINKAGE
[241]463Clp_problemName(Clp_Simplex * model, int maxNumberCharacters, char * array)
464{
[1525]465     std::string name = model->model_->problemName();
[1689]466     maxNumberCharacters = CoinMin(maxNumberCharacters,
467                                   ((int) strlen(name.c_str()))+1) ;
[1525]468     strncpy(array, name.c_str(), maxNumberCharacters - 1);
469     array[maxNumberCharacters-1] = '\0';
[241]470}
[429]471/* Sets problem name.  Must have \0 at end.  */
[1525]472COINLIBAPI int COINLINKAGE
[1402]473Clp_setProblemName(Clp_Simplex * model, int /*maxNumberCharacters*/, char * array)
[429]474{
[1525]475     return model->model_->setStrParam(ClpProbName, array);
[429]476}
[241]477/* Number of iterations */
[1525]478COINLIBAPI int COINLINKAGE
[241]479Clp_numberIterations(Clp_Simplex * model)
480{
[1525]481     return model->model_->numberIterations();
[241]482}
[1525]483COINLIBAPI void COINLINKAGE
[241]484Clp_setNumberIterations(Clp_Simplex * model, int numberIterations)
485{
[1525]486     model->model_->setNumberIterations(numberIterations);
[241]487}
488/* Maximum number of iterations */
[429]489COINLIBAPI int maximumIterations(Clp_Simplex * model)
[241]490{
[1525]491     return model->model_->maximumIterations();
[241]492}
[1525]493COINLIBAPI void COINLINKAGE
[241]494Clp_setMaximumIterations(Clp_Simplex * model, int value)
495{
[1525]496     model->model_->setMaximumIterations(value);
[241]497}
498/* Maximum time in seconds (from when set called) */
[1525]499COINLIBAPI double COINLINKAGE
[241]500Clp_maximumSeconds(Clp_Simplex * model)
501{
[1525]502     return model->model_->maximumSeconds();
[241]503}
[1525]504COINLIBAPI void COINLINKAGE
[241]505Clp_setMaximumSeconds(Clp_Simplex * model, double value)
506{
[1525]507     model->model_->setMaximumSeconds(value);
[241]508}
509/* Returns true if hit maximum iteratio`ns (or time) */
[1525]510COINLIBAPI int COINLINKAGE
[241]511Clp_hitMaximumIterations(Clp_Simplex * model)
512{
[1525]513     return model->model_->hitMaximumIterations() ? 1 : 0;
[241]514}
515/* Status of problem:
516   0 - optimal
517   1 - primal infeasible
518   2 - dual infeasible
519   3 - stopped on iterations etc
520   4 - stopped due to errors
521*/
[1525]522COINLIBAPI int COINLINKAGE
[241]523Clp_status(Clp_Simplex * model)
524{
[1525]525     return model->model_->status();
[241]526}
527/* Set problem status */
[1525]528COINLIBAPI void COINLINKAGE
[241]529Clp_setProblemStatus(Clp_Simplex * model, int problemStatus)
530{
[1525]531     model->model_->setProblemStatus(problemStatus);
[241]532}
533/* Secondary status of problem - may get extended
534   0 - none
535   1 - primal infeasible because dual limit reached
536   2 - scaled problem optimal - unscaled has primal infeasibilities
537   3 - scaled problem optimal - unscaled has dual infeasibilities
538   4 - scaled problem optimal - unscaled has both dual and primal infeasibilities
539*/
[1525]540COINLIBAPI int COINLINKAGE
[241]541Clp_secondaryStatus(Clp_Simplex * model)
542{
[1525]543     return model->model_->secondaryStatus();
[241]544}
[1525]545COINLIBAPI void COINLINKAGE
[241]546Clp_setSecondaryStatus(Clp_Simplex * model, int status)
547{
[1525]548     model->model_->setSecondaryStatus(status);
[241]549}
550/* Direction of optimization (1 - minimize, -1 - maximize, 0 - ignore */
[1525]551COINLIBAPI double COINLINKAGE
[241]552Clp_optimizationDirection(Clp_Simplex * model)
553{
[1525]554     return model->model_->optimizationDirection();
[241]555}
[1525]556COINLIBAPI void COINLINKAGE
[241]557Clp_setOptimizationDirection(Clp_Simplex * model, double value)
558{
[1525]559     model->model_->setOptimizationDirection(value);
[241]560}
561/* Primal row solution */
[1525]562COINLIBAPI double * COINLINKAGE
[241]563Clp_primalRowSolution(Clp_Simplex * model)
564{
[1525]565     return model->model_->primalRowSolution();
[241]566}
567/* Primal column solution */
[1525]568COINLIBAPI double * COINLINKAGE
[241]569Clp_primalColumnSolution(Clp_Simplex * model)
570{
[1525]571     return model->model_->primalColumnSolution();
[241]572}
573/* Dual row solution */
[1525]574COINLIBAPI double * COINLINKAGE
[241]575Clp_dualRowSolution(Clp_Simplex * model)
576{
[1525]577     return model->model_->dualRowSolution();
[241]578}
579/* Reduced costs */
[1525]580COINLIBAPI double * COINLINKAGE
[241]581Clp_dualColumnSolution(Clp_Simplex * model)
582{
[1525]583     return model->model_->dualColumnSolution();
[241]584}
585/* Row lower */
[1525]586COINLIBAPI double* COINLINKAGE
[241]587Clp_rowLower(Clp_Simplex * model)
588{
[1525]589     return model->model_->rowLower();
[241]590}
591/* Row upper  */
[1525]592COINLIBAPI double* COINLINKAGE
[241]593Clp_rowUpper(Clp_Simplex * model)
594{
[1525]595     return model->model_->rowUpper();
[241]596}
597/* Objective */
[1525]598COINLIBAPI double * COINLINKAGE
[241]599Clp_objective(Clp_Simplex * model)
600{
[1525]601     return model->model_->objective();
[241]602}
603/* Column Lower */
[1525]604COINLIBAPI double * COINLINKAGE
[241]605Clp_columnLower(Clp_Simplex * model)
606{
[1525]607     return model->model_->columnLower();
[241]608}
609/* Column Upper */
[1525]610COINLIBAPI double * COINLINKAGE
[241]611Clp_columnUpper(Clp_Simplex * model)
612{
[1525]613     return model->model_->columnUpper();
[241]614}
615/* Number of elements in matrix */
[1525]616COINLIBAPI int COINLINKAGE
[241]617Clp_getNumElements(Clp_Simplex * model)
618{
[1525]619     return model->model_->getNumElements();
[241]620}
[1525]621// Column starts in matrix
[429]622COINLIBAPI const CoinBigIndex * COINLINKAGE Clp_getVectorStarts(Clp_Simplex * model)
623{
[1525]624     CoinPackedMatrix * matrix;
625     matrix = model->model_->matrix();
626     return (matrix == NULL) ? NULL : matrix->getVectorStarts();
[429]627}
628
[1525]629// Row indices in matrix
[429]630COINLIBAPI const int * COINLINKAGE Clp_getIndices(Clp_Simplex * model)
631{
[1525]632     CoinPackedMatrix * matrix = model->model_->matrix();
633     return (matrix == NULL) ? NULL : matrix->getIndices();
634}
[429]635
[1525]636// Column vector lengths in matrix
[429]637COINLIBAPI const int * COINLINKAGE Clp_getVectorLengths(Clp_Simplex * model)
638{
[1525]639     CoinPackedMatrix * matrix = model->model_->matrix();
640     return (matrix == NULL) ? NULL : matrix->getVectorLengths();
641}
642
643// Element values in matrix
[429]644COINLIBAPI const double * COINLINKAGE Clp_getElements(Clp_Simplex * model)
645{
[1525]646     CoinPackedMatrix * matrix = model->model_->matrix();
647     return (matrix == NULL) ? NULL : matrix->getElements();
[429]648}
[241]649/* Objective value */
[1525]650COINLIBAPI double COINLINKAGE
[241]651Clp_objectiveValue(Clp_Simplex * model)
652{
[1525]653     return model->model_->objectiveValue();
[241]654}
655/* Integer information */
[1525]656COINLIBAPI char * COINLINKAGE
[241]657Clp_integerInformation(Clp_Simplex * model)
658{
[1525]659     return model->model_->integerInformation();
[241]660}
661/* Infeasibility/unbounded ray (NULL returned if none/wrong)
[1901]662   Up to user to use free() on these arrays.  */
[1525]663COINLIBAPI double * COINLINKAGE
[241]664Clp_infeasibilityRay(Clp_Simplex * model)
665{
[1901]666     const double * ray = model->model_->internalRay();
667     double * array = NULL;
668     int numberRows = model->model_->numberRows(); 
669     int status = model->model_->status();
670     if (status == 1 && ray) {
671          array = static_cast<double*>(malloc(numberRows*sizeof(double)));
672          memcpy(array,ray,numberRows*sizeof(double));
[1926]673#ifdef PRINT_RAY_METHOD
674          printf("Infeasibility ray obtained by algorithm %s\n",model->model_->algorithm()>0 ?
675              "primal" : "dual");
[1901]676#endif
677     }
678     return array;
[241]679}
[1525]680COINLIBAPI double * COINLINKAGE
[241]681Clp_unboundedRay(Clp_Simplex * model)
682{
[1901]683     const double * ray = model->model_->internalRay();
684     double * array = NULL;
685     int numberColumns = model->model_->numberColumns(); 
686     int status = model->model_->status();
687     if (status == 2 && ray) {
688          array = static_cast<double*>(malloc(numberColumns*sizeof(double)));
689          memcpy(array,ray,numberColumns*sizeof(double));
690     }
691     return array;
[241]692}
[2019]693COINLIBAPI void COINLINKAGE
694Clp_freeRay(Clp_Simplex * model, double * ray)
695{
696     free(ray);
697}
[241]698/* See if status array exists (partly for OsiClp) */
[1525]699COINLIBAPI int COINLINKAGE
[241]700Clp_statusExists(Clp_Simplex * model)
701{
[1525]702     return model->model_->statusExists() ? 1 : 0;
[241]703}
704/* Return address of status array (char[numberRows+numberColumns]) */
[1525]705COINLIBAPI unsigned char *  COINLINKAGE
[241]706Clp_statusArray(Clp_Simplex * model)
707{
[1525]708     return model->model_->statusArray();
[241]709}
710/* Copy in status vector */
[1525]711COINLIBAPI void COINLINKAGE
[241]712Clp_copyinStatus(Clp_Simplex * model, const unsigned char * statusArray)
713{
[1525]714     model->model_->copyinStatus(statusArray);
[241]715}
716
717/* User pointer for whatever reason */
[1525]718COINLIBAPI void COINLINKAGE
[241]719Clp_setUserPointer (Clp_Simplex * model, void * pointer)
720{
[1525]721     model->model_->setUserPointer(pointer);
[241]722}
[1525]723COINLIBAPI void * COINLINKAGE
[241]724Clp_getUserPointer (Clp_Simplex * model)
725{
[1525]726     return model->model_->getUserPointer();
[241]727}
728/* Pass in Callback function */
[1525]729COINLIBAPI void COINLINKAGE
730Clp_registerCallBack(Clp_Simplex * model,
731                     clp_callback userCallBack)
[241]732{
[1525]733     // Will be copy of users one
734     delete model->handler_;
735     model->handler_ = new CMessageHandler(*(model->model_->messageHandler()));
736     model->handler_->setCallBack(userCallBack);
737     model->handler_->setModel(model);
738     model->model_->passInMessageHandler(model->handler_);
[241]739}
740/* Unset Callback function */
[1525]741COINLIBAPI void COINLINKAGE
[241]742Clp_clearCallBack(Clp_Simplex * model)
743{
[1525]744     delete model->handler_;
745     model->handler_ = NULL;
[241]746}
747/* Amount of print out:
748   0 - none
749   1 - just final
750   2 - just factorizations
751   3 - as 2 plus a bit more
752   4 - verbose
753   above that 8,16,32 etc just for selective debug
754*/
[1525]755COINLIBAPI void COINLINKAGE
[241]756Clp_setLogLevel(Clp_Simplex * model, int value)
757{
[1525]758     model->model_->setLogLevel(value);
[241]759}
[1525]760COINLIBAPI int COINLINKAGE
[241]761Clp_logLevel(Clp_Simplex * model)
762{
[1525]763     return model->model_->logLevel();
[241]764}
765/* length of names (0 means no names0 */
[1525]766COINLIBAPI int COINLINKAGE
[241]767Clp_lengthNames(Clp_Simplex * model)
768{
[1525]769     return model->model_->lengthNames();
[241]770}
771/* Fill in array (at least lengthNames+1 long) with a row name */
[1525]772COINLIBAPI void COINLINKAGE
[241]773Clp_rowName(Clp_Simplex * model, int iRow, char * name)
774{
[1525]775     std::string rowName = model->model_->rowName(iRow);
776     strcpy(name, rowName.c_str());
[241]777}
778/* Fill in array (at least lengthNames+1 long) with a column name */
[1525]779COINLIBAPI void COINLINKAGE
[241]780Clp_columnName(Clp_Simplex * model, int iColumn, char * name)
781{
[1525]782     std::string columnName = model->model_->columnName(iColumn);
783     strcpy(name, columnName.c_str());
[241]784}
785
786/* General solve algorithm which can do presolve.
787   See  ClpSolve.hpp for options
788*/
[1525]789COINLIBAPI int COINLINKAGE
[241]790Clp_initialSolve(Clp_Simplex * model)
791{
[1525]792     return model->model_->initialSolve();
[241]793}
[1902]794/* Pass solve options. (Exception to direct analogue rule) */
795COINLIBAPI int COINLINKAGE
796Clp_initialSolveWithOptions(Clp_Simplex * model, Clp_Solve * s)
797{
798     return model->model_->initialSolve(s->options);
799}
[891]800/* Barrier initial solve */
[1525]801COINLIBAPI int COINLINKAGE
[891]802Clp_initialBarrierSolve(Clp_Simplex * model0)
803{
[1525]804     ClpSimplex *model = model0->model_;
[891]805
[1525]806     return model->initialBarrierSolve();
807
[891]808}
809/* Barrier initial solve */
[1525]810COINLIBAPI int COINLINKAGE
[891]811Clp_initialBarrierNoCrossSolve(Clp_Simplex * model0)
812{
[1525]813     ClpSimplex *model = model0->model_;
[891]814
[1525]815     return model->initialBarrierNoCrossSolve();
816
[891]817}
[241]818/* Dual initial solve */
[1525]819COINLIBAPI int COINLINKAGE
[241]820Clp_initialDualSolve(Clp_Simplex * model)
821{
[1525]822     return model->model_->initialDualSolve();
[241]823}
824/* Primal initial solve */
[1525]825COINLIBAPI int COINLINKAGE
[241]826Clp_initialPrimalSolve(Clp_Simplex * model)
827{
[1525]828     return model->model_->initialPrimalSolve();
[241]829}
830/* Dual algorithm - see ClpSimplexDual.hpp for method */
[1525]831COINLIBAPI int COINLINKAGE
[241]832Clp_dual(Clp_Simplex * model, int ifValuesPass)
833{
[1525]834     return model->model_->dual(ifValuesPass);
[241]835}
836/* Primal algorithm - see ClpSimplexPrimal.hpp for method */
[1525]837COINLIBAPI int COINLINKAGE
[241]838Clp_primal(Clp_Simplex * model, int ifValuesPass)
839{
[1525]840     return model->model_->primal(ifValuesPass);
[241]841}
842/* Sets or unsets scaling, 0 -off, 1 equilibrium, 2 geometric, 3, auto, 4 dynamic(later) */
[1525]843COINLIBAPI void COINLINKAGE
[241]844Clp_scaling(Clp_Simplex * model, int mode)
845{
[1525]846     model->model_->scaling(mode);
[241]847}
848/* Gets scalingFlag */
[1525]849COINLIBAPI int COINLINKAGE
[241]850Clp_scalingFlag(Clp_Simplex * model)
851{
[1525]852     return model->model_->scalingFlag();
[241]853}
854/* Crash - at present just aimed at dual, returns
855   -2 if dual preferred and crash basis created
856   -1 if dual preferred and all slack basis preferred
857   0 if basis going in was not all slack
858   1 if primal preferred and all slack basis preferred
859   2 if primal preferred and crash basis created.
[1525]860
[241]861   if gap between bounds <="gap" variables can be flipped
[1525]862
[241]863   If "pivot" is
864   0 No pivoting (so will just be choice of algorithm)
865   1 Simple pivoting e.g. gub
866   2 Mini iterations
867*/
[1525]868COINLIBAPI int COINLINKAGE
869Clp_crash(Clp_Simplex * model, double gap, int pivot)
[241]870{
[1525]871     return model->model_->crash(gap, pivot);
[241]872}
873/* If problem is primal feasible */
[1525]874COINLIBAPI int COINLINKAGE
[241]875Clp_primalFeasible(Clp_Simplex * model)
876{
[1525]877     return model->model_->primalFeasible() ? 1 : 0;
[241]878}
879/* If problem is dual feasible */
[1525]880COINLIBAPI int COINLINKAGE
[241]881Clp_dualFeasible(Clp_Simplex * model)
882{
[1525]883     return model->model_->dualFeasible() ? 1 : 0;
[241]884}
885/* Dual bound */
[1525]886COINLIBAPI double COINLINKAGE
[241]887Clp_dualBound(Clp_Simplex * model)
888{
[1525]889     return model->model_->dualBound();
[241]890}
[1525]891COINLIBAPI void COINLINKAGE
[241]892Clp_setDualBound(Clp_Simplex * model, double value)
893{
[1525]894     model->model_->setDualBound(value);
[241]895}
896/* Infeasibility cost */
[1525]897COINLIBAPI double COINLINKAGE
[241]898Clp_infeasibilityCost(Clp_Simplex * model)
899{
[1525]900     return model->model_->infeasibilityCost();
[241]901}
[1525]902COINLIBAPI void COINLINKAGE
[241]903Clp_setInfeasibilityCost(Clp_Simplex * model, double value)
904{
[1525]905     model->model_->setInfeasibilityCost(value);
[241]906}
907/* Perturbation:
908   50  - switch on perturbation
909   100 - auto perturb if takes too long (1.0e-6 largest nonzero)
910   101 - we are perturbed
911   102 - don't try perturbing again
912   default is 100
913   others are for playing
914*/
[1525]915COINLIBAPI int COINLINKAGE
[241]916Clp_perturbation(Clp_Simplex * model)
917{
[1525]918     return model->model_->perturbation();
[241]919}
[1525]920COINLIBAPI void COINLINKAGE
[241]921Clp_setPerturbation(Clp_Simplex * model, int value)
922{
[1525]923     model->model_->setPerturbation(value);
[241]924}
925/* Current (or last) algorithm */
[1525]926COINLIBAPI int COINLINKAGE
[241]927Clp_algorithm(Clp_Simplex * model)
928{
[1525]929     return model->model_->algorithm();
[241]930}
931/* Set algorithm */
[1525]932COINLIBAPI void COINLINKAGE
[241]933Clp_setAlgorithm(Clp_Simplex * model, int value)
934{
[1525]935     model->model_->setAlgorithm(value);
[241]936}
937/* Sum of dual infeasibilities */
[1525]938COINLIBAPI double COINLINKAGE
[241]939Clp_sumDualInfeasibilities(Clp_Simplex * model)
940{
[1525]941     return model->model_->sumDualInfeasibilities();
[241]942}
943/* Number of dual infeasibilities */
[1525]944COINLIBAPI int COINLINKAGE
[241]945Clp_numberDualInfeasibilities(Clp_Simplex * model)
946{
[1525]947     return model->model_->numberDualInfeasibilities();
[241]948}
949/* Sum of primal infeasibilities */
[1525]950COINLIBAPI double COINLINKAGE
[241]951Clp_sumPrimalInfeasibilities(Clp_Simplex * model)
952{
[1525]953     return model->model_->sumPrimalInfeasibilities();
[241]954}
955/* Number of primal infeasibilities */
[1525]956COINLIBAPI int COINLINKAGE
[241]957Clp_numberPrimalInfeasibilities(Clp_Simplex * model)
958{
[1525]959     return model->model_->numberPrimalInfeasibilities();
[241]960}
961/* Save model to file, returns 0 if success.  This is designed for
962   use outside algorithms so does not save iterating arrays etc.
[1525]963   It does not save any messaging information.
[241]964   Does not save scaling values.
965   It does not know about all types of virtual functions.
966*/
[1525]967COINLIBAPI int COINLINKAGE
[241]968Clp_saveModel(Clp_Simplex * model, const char * fileName)
969{
[1525]970     return model->model_->saveModel(fileName);
[241]971}
972/* Restore model from file, returns 0 if success,
973   deletes current model */
[1525]974COINLIBAPI int COINLINKAGE
[241]975Clp_restoreModel(Clp_Simplex * model, const char * fileName)
976{
[1525]977     return model->model_->restoreModel(fileName);
[241]978}
[1525]979
[241]980/* Just check solution (for external use) - sets sum of
981   infeasibilities etc */
[1525]982COINLIBAPI void COINLINKAGE
[241]983Clp_checkSolution(Clp_Simplex * model)
984{
[1525]985     model->model_->checkSolution();
[241]986}
987/* Number of rows */
[1525]988COINLIBAPI int COINLINKAGE
[241]989Clp_getNumRows(Clp_Simplex * model)
990{
[1525]991     return model->model_->getNumRows();
[241]992}
993/* Number of columns */
[1525]994COINLIBAPI int COINLINKAGE
[241]995Clp_getNumCols(Clp_Simplex * model)
996{
[1525]997     return model->model_->getNumCols();
[241]998}
999/* Number of iterations */
[1525]1000COINLIBAPI int COINLINKAGE
[241]1001Clp_getIterationCount(Clp_Simplex * model)
1002{
[1525]1003     return model->model_->getIterationCount();
[241]1004}
1005/* Are there a numerical difficulties? */
[1525]1006COINLIBAPI int COINLINKAGE
[241]1007Clp_isAbandoned(Clp_Simplex * model)
1008{
[1525]1009     return model->model_->isAbandoned() ? 1 : 0;
[241]1010}
1011/* Is optimality proven? */
[1525]1012COINLIBAPI int COINLINKAGE
[241]1013Clp_isProvenOptimal(Clp_Simplex * model)
1014{
[1525]1015     return model->model_->isProvenOptimal() ? 1 : 0;
[241]1016}
1017/* Is primal infeasiblity proven? */
[1525]1018COINLIBAPI int COINLINKAGE
[241]1019Clp_isProvenPrimalInfeasible(Clp_Simplex * model)
1020{
[1525]1021     return model->model_->isProvenPrimalInfeasible() ? 1 : 0;
[241]1022}
1023/* Is dual infeasiblity proven? */
[1525]1024COINLIBAPI int COINLINKAGE
[241]1025Clp_isProvenDualInfeasible(Clp_Simplex * model)
1026{
[1525]1027     return model->model_->isProvenDualInfeasible() ? 1 : 0;
[241]1028}
1029/* Is the given primal objective limit reached? */
[1525]1030COINLIBAPI int COINLINKAGE
1031Clp_isPrimalObjectiveLimitReached(Clp_Simplex * model)
[241]1032{
[1525]1033     return model->model_->isPrimalObjectiveLimitReached() ? 1 : 0;
[241]1034}
1035/* Is the given dual objective limit reached? */
[1525]1036COINLIBAPI int COINLINKAGE
1037Clp_isDualObjectiveLimitReached(Clp_Simplex * model)
[241]1038{
[1525]1039     return model->model_->isDualObjectiveLimitReached() ? 1 : 0;
[241]1040}
1041/* Iteration limit reached? */
[1525]1042COINLIBAPI int COINLINKAGE
[241]1043Clp_isIterationLimitReached(Clp_Simplex * model)
1044{
[1525]1045     return model->model_->isIterationLimitReached() ? 1 : 0;
[241]1046}
1047/* Direction of optimization (1 - minimize, -1 - maximize, 0 - ignore */
[1525]1048COINLIBAPI double COINLINKAGE
[241]1049Clp_getObjSense(Clp_Simplex * model)
1050{
[1525]1051     return model->model_->getObjSense();
[241]1052}
[1480]1053/* Direction of optimization (1 - minimize, -1 - maximize, 0 - ignore */
[1525]1054COINLIBAPI void COINLINKAGE
[1480]1055Clp_setObjSense(Clp_Simplex * model, double objsen)
1056{
[1525]1057     model->model_->setOptimizationDirection(objsen);
[1480]1058}
[241]1059/* Primal row solution */
[1525]1060COINLIBAPI const double * COINLINKAGE
[241]1061Clp_getRowActivity(Clp_Simplex * model)
1062{
[1525]1063     return model->model_->getRowActivity();
[241]1064}
1065/* Primal column solution */
[1525]1066COINLIBAPI const double * COINLINKAGE
[241]1067Clp_getColSolution(Clp_Simplex * model)
1068{
[1525]1069     return model->model_->getColSolution();
[241]1070}
[1525]1071COINLIBAPI void COINLINKAGE
[241]1072Clp_setColSolution(Clp_Simplex * model, const double * input)
1073{
[1525]1074     model->model_->setColSolution(input);
[241]1075}
1076/* Dual row solution */
[1525]1077COINLIBAPI const double * COINLINKAGE
[241]1078Clp_getRowPrice(Clp_Simplex * model)
1079{
[1525]1080     return model->model_->getRowPrice();
[241]1081}
1082/* Reduced costs */
[1525]1083COINLIBAPI const double * COINLINKAGE
[241]1084Clp_getReducedCost(Clp_Simplex * model)
1085{
[1525]1086     return model->model_->getReducedCost();
[241]1087}
1088/* Row lower */
[1525]1089COINLIBAPI const double* COINLINKAGE
[241]1090Clp_getRowLower(Clp_Simplex * model)
1091{
[1525]1092     return model->model_->getRowLower();
[241]1093}
1094/* Row upper  */
[1525]1095COINLIBAPI const double* COINLINKAGE
[241]1096Clp_getRowUpper(Clp_Simplex * model)
1097{
[1525]1098     return model->model_->getRowUpper();
[241]1099}
1100/* Objective */
[1525]1101COINLIBAPI const double * COINLINKAGE
[241]1102Clp_getObjCoefficients(Clp_Simplex * model)
1103{
[1525]1104     return model->model_->getObjCoefficients();
[241]1105}
1106/* Column Lower */
[1525]1107COINLIBAPI const double * COINLINKAGE
[241]1108Clp_getColLower(Clp_Simplex * model)
1109{
[1525]1110     return model->model_->getColLower();
[241]1111}
1112/* Column Upper */
[1525]1113COINLIBAPI const double * COINLINKAGE
[241]1114Clp_getColUpper(Clp_Simplex * model)
1115{
[1525]1116     return model->model_->getColUpper();
[241]1117}
1118/* Objective value */
[1525]1119COINLIBAPI double COINLINKAGE
[241]1120Clp_getObjValue(Clp_Simplex * model)
1121{
[1525]1122     return model->model_->getObjValue();
[241]1123}
[406]1124/* Get variable basis info */
[1088]1125COINLIBAPI int COINLINKAGE
[1525]1126Clp_getColumnStatus(Clp_Simplex * model, int sequence)
[406]1127{
[1525]1128     return (int) model->model_->getColumnStatus(sequence);
[406]1129}
1130/* Get row basis info */
[1088]1131COINLIBAPI int COINLINKAGE
[1525]1132Clp_getRowStatus(Clp_Simplex * model, int sequence)
[406]1133{
[1525]1134     return (int) model->model_->getRowStatus(sequence);
[406]1135}
[633]1136/* Set variable basis info */
1137COINLIBAPI void COINLINKAGE
[1525]1138Clp_setColumnStatus(Clp_Simplex * model, int sequence, int value)
[633]1139{
[1525]1140     if (value >= 0 && value <= 5) {
1141          model->model_->setColumnStatus(sequence, (ClpSimplex::Status) value );
1142          if (value == 3 || value == 5)
1143               model->model_->primalColumnSolution()[sequence] =
1144                    model->model_->columnLower()[sequence];
1145          else if (value == 2)
1146               model->model_->primalColumnSolution()[sequence] =
1147                    model->model_->columnUpper()[sequence];
1148     }
[633]1149}
1150/* Set row basis info */
1151COINLIBAPI void COINLINKAGE
[1525]1152Clp_setRowStatus(Clp_Simplex * model, int sequence, int value)
[633]1153{
[1525]1154     if (value >= 0 && value <= 5) {
1155          model->model_->setRowStatus(sequence, (ClpSimplex::Status) value );
1156          if (value == 3 || value == 5)
1157               model->model_->primalRowSolution()[sequence] =
1158                    model->model_->rowLower()[sequence];
1159          else if (value == 2)
1160               model->model_->primalRowSolution()[sequence] =
1161                    model->model_->rowUpper()[sequence];
1162     }
[633]1163}
[406]1164/* Small element value - elements less than this set to zero,
1165   default is 1.0e-20 */
[1525]1166COINLIBAPI double COINLINKAGE
[406]1167Clp_getSmallElementValue(Clp_Simplex * model)
1168{
[1525]1169     return model->model_->getSmallElementValue();
[406]1170}
[1525]1171COINLIBAPI void COINLINKAGE
1172Clp_setSmallElementValue(Clp_Simplex * model, double value)
[406]1173{
[1525]1174     model->model_->setSmallElementValue(value);
[406]1175}
[429]1176/* Print model */
[1525]1177COINLIBAPI void COINLINKAGE
[429]1178Clp_printModel(Clp_Simplex * model, const char * prefix)
1179{
[1525]1180     ClpSimplex *clp_simplex = model->model_;
1181     int numrows    = clp_simplex->numberRows();
1182     int numcols    = clp_simplex->numberColumns();
1183     int numelem    = clp_simplex->getNumElements();
1184     const CoinBigIndex *start = clp_simplex->matrix()->getVectorStarts();
1185     const int *index     = clp_simplex->matrix()->getIndices();
1186     const double *value  = clp_simplex->matrix()->getElements();
1187     const double *collb  = model->model_->columnLower();
1188     const double *colub  = model->model_->columnUpper();
1189     const double *obj    = model->model_->objective();
1190     const double *rowlb  = model->model_->rowLower();
1191     const double *rowub  = model->model_->rowUpper();
1192     printf("%s numcols = %i, numrows = %i, numelem = %i\n",
1193            prefix, numcols, numrows, numelem);
1194     printf("%s model = %p, start = %p, index = %p, value = %p\n",
1195            prefix, reinterpret_cast<const void *>(model), reinterpret_cast<const void *>(start), reinterpret_cast<const void *>(index), reinterpret_cast<const void *>(value));
1196     clp_simplex->matrix()->dumpMatrix(NULL);
1197     {
1198          int i;
1199          for (i = 0; i <= numcols; i++)
1200               printf("%s start[%i] = %i\n", prefix, i, start[i]);
1201          for (i = 0; i < numelem; i++)
1202               printf("%s index[%i] = %i, value[%i] = %g\n",
1203                      prefix, i, index[i], i, value[i]);
1204     }
1205
1206     printf("%s collb = %p, colub = %p, obj = %p, rowlb = %p, rowub = %p\n",
1207            prefix, reinterpret_cast<const void *>(collb), reinterpret_cast<const void *>(colub), reinterpret_cast<const void *>(obj), reinterpret_cast<const void *>(rowlb), reinterpret_cast<const void *>(rowub));
1208     printf("%s optimization direction = %g\n", prefix, Clp_optimizationDirection(model));
1209     printf("  (1 - minimize, -1 - maximize, 0 - ignore)\n");
1210     {
1211          int i;
1212          for (i = 0; i < numcols; i++)
1213               printf("%s collb[%i] = %g, colub[%i] = %g, obj[%i] = %g\n",
1214                      prefix, i, collb[i], i, colub[i], i, obj[i]);
1215          for (i = 0; i < numrows; i++)
1216               printf("%s rowlb[%i] = %g, rowub[%i] = %g\n",
1217                      prefix, i, rowlb[i], i, rowub[i]);
1218     }
[429]1219}
[1480]1220
1221#ifndef SLIM_CLP
1222/** Solve the problem with the idiot code */
1223/* tryhard values:
1224   tryhard & 7:
1225      0: NOT lightweight, 105 iterations within a pass (when mu stays fixed)
1226      1: lightweight, but focus more on optimality (mu is high)
1227         (23 iters in a pass)
1228      2: lightweight, but focus more on feasibility (11 iters in a pass)
1229      3: lightweight, but focus more on feasibility (23 iters in a pass, so it
1230         goes closer to opt than option 2)
1231   tryhard >> 3:
1232      number of passes, the larger the number the closer it gets to optimality
1233*/
1234COINLIBAPI void COINLINKAGE
1235Clp_idiot(Clp_Simplex * model, int tryhard)
1236{
[1525]1237     ClpSimplex *clp = model->model_;
1238     Idiot info(*clp);
1239     int numberpass = tryhard >> 3;
1240     int lightweight = tryhard & 7;
1241     info.setLightweight(lightweight);
1242     info.crash(numberpass, clp->messageHandler(), clp->messagesPointer(), false);
[1480]1243}
1244#endif
1245
[1902]1246COINLIBAPI Clp_Solve * COINLINKAGE
1247ClpSolve_new() 
1248{ 
1249    return new Clp_Solve(); 
1250}
1251
1252COINLIBAPI void COINLINKAGE
1253ClpSolve_delete(Clp_Solve * solve) 
1254{ 
1255    delete solve; 
1256}
1257
1258// space- and error-saving macros
1259#define ClpSolveGetIntProperty(prop) \
1260COINLIBAPI int COINLINKAGE \
1261ClpSolve_ ## prop (Clp_Solve *s) \
1262{ \
1263    return s->options.prop(); \
1264}
1265
1266#define ClpSolveSetIntProperty(prop) \
1267COINLIBAPI void COINLINKAGE \
1268ClpSolve_ ## prop (Clp_Solve *s, int val) \
1269{ \
1270    s->options.prop(val); \
1271}
1272
1273COINLIBAPI void COINLINKAGE
1274ClpSolve_setSpecialOption(Clp_Solve * s, int which, int value, int extraInfo) 
1275{
1276    s->options.setSpecialOption(which,value,extraInfo);
1277}
1278
1279COINLIBAPI int COINLINKAGE
1280ClpSolve_getSpecialOption(Clp_Solve * s, int which)
1281{
1282    return s->options.getSpecialOption(which);
1283}
1284
1285COINLIBAPI void COINLINKAGE
1286ClpSolve_setSolveType(Clp_Solve * s, int method, int extraInfo)
1287{
1288    s->options.setSolveType(static_cast<ClpSolve::SolveType>(method), extraInfo);
1289}
1290
1291ClpSolveGetIntProperty(getSolveType)
1292
1293COINLIBAPI void COINLINKAGE ClpSolve_setPresolveType(Clp_Solve * s, int amount, int extraInfo)
1294{
1295    s->options.setPresolveType(static_cast<ClpSolve::PresolveType>(amount),extraInfo);
1296}
1297
1298ClpSolveGetIntProperty(getPresolveType)
1299
1300ClpSolveGetIntProperty(getPresolvePasses)
1301
1302
1303COINLIBAPI int COINLINKAGE
1304ClpSolve_getExtraInfo(Clp_Solve * s, int which) {
1305     return s->options.getExtraInfo(which);
1306}
1307
1308ClpSolveSetIntProperty(setInfeasibleReturn)
1309ClpSolveGetIntProperty(infeasibleReturn)
1310
1311ClpSolveGetIntProperty(doDual)
1312ClpSolveSetIntProperty(setDoDual)
1313
1314ClpSolveGetIntProperty(doSingleton)
1315ClpSolveSetIntProperty(setDoSingleton)
1316
1317ClpSolveGetIntProperty(doDoubleton)
1318ClpSolveSetIntProperty(setDoDoubleton)
1319
1320ClpSolveGetIntProperty(doTripleton)
1321ClpSolveSetIntProperty(setDoTripleton)
1322
1323ClpSolveGetIntProperty(doTighten)
1324ClpSolveSetIntProperty(setDoTighten)
1325
1326ClpSolveGetIntProperty(doForcing)
1327ClpSolveSetIntProperty(setDoForcing)
1328
1329ClpSolveGetIntProperty(doImpliedFree)
1330ClpSolveSetIntProperty(setDoImpliedFree)
1331
1332ClpSolveGetIntProperty(doDupcol)
1333ClpSolveSetIntProperty(setDoDupcol)
1334
1335ClpSolveGetIntProperty(doDuprow)
1336ClpSolveSetIntProperty(setDoDuprow)
1337
1338ClpSolveGetIntProperty(doSingletonColumn)
1339ClpSolveSetIntProperty(setDoSingletonColumn)
1340
1341ClpSolveGetIntProperty(presolveActions)
1342ClpSolveSetIntProperty(setPresolveActions)
1343
1344ClpSolveGetIntProperty(substitution)
1345ClpSolveSetIntProperty(setSubstitution)
1346
[1525]1347#if defined(__MWERKS__)
[431]1348#pragma export off
1349#endif
[241]1350
Note: See TracBrowser for help on using the repository browser.