source: trunk/Clp_C_Interface.cpp @ 284

Last change on this file since 284 was 277, checked in by forrest, 16 years ago

Allowing CoinBigIndex? as long

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 25.4 KB
Line 
1// Copyright (C) 2003, International Business Machines
2// Corporation and others.  All Rights Reserved.
3
4
5
6
7#include "CoinPragma.hpp"
8
9#include <math.h>
10
11#include "CoinHelperFunctions.hpp"
12#include "ClpSimplex.hpp"
13#include <cfloat>
14// This sections needs to match Clp_C_defines.h but with extern C
15#define ClpSimplexCDefine_H
16
17/** This has #defines etc for the "C" interface to Clp.
18
19*/
20
21/* Plus infinity */
22#ifndef COIN_DBL_MAX
23#define COIN_DBL_MAX DBL_MAX
24#endif
25
26/* We need to allow for Microsoft */
27#ifndef CLPLIBAPI
28
29#if defined (CLPMSDLL)
30#   define CLPLIBAPI __declspec(dllexport) extern "C"
31#   define CLPLINKAGE  __stdcall
32#   define CLPLINKAGE_CB  __cdecl
33#else
34#   define CLPLIBAPI extern "C"
35#   define CLPLINKAGE
36#   define CLPLINKAGE_CB
37#endif
38
39#endif
40class CMessageHandler;
41// Real typedef for structure
42typedef struct {
43  ClpSimplex * model_;
44  CMessageHandler * handler_;
45} Clp_Simplex;
46/** typedef for user call back */
47typedef  void (CLPLINKAGE_CB *clp_callback) (Clp_Simplex * model,int  msgno, int ndouble,
48                            const double * dvec, int nint, const int * ivec,
49                            int nchar,  char ** cvec);
50
51// To allow call backs
52class CMessageHandler : public CoinMessageHandler {
53 
54public:
55  /**@name Overrides */
56  //@{
57  virtual int print();
58  //@}
59  /**@name set and get */
60  //@{
61  /// Model
62  const Clp_Simplex * model() const;
63  void setModel(Clp_Simplex * model);
64  /// Call back
65  void setCallBack(clp_callback callback);
66  //@}
67
68  /**@name Constructors, destructor */
69  //@{
70  /** Default constructor. */
71  CMessageHandler();
72  /// Constructor with pointer to model
73  CMessageHandler(Clp_Simplex * model,
74                           FILE * userPointer=NULL);
75  /** Destructor */
76  virtual ~CMessageHandler();
77  //@}
78
79  /**@name Copy method */
80  //@{
81  /** The copy constructor. */
82  CMessageHandler(const CMessageHandler&);
83  /** The copy constructor from an CoinSimplexMessageHandler. */
84  CMessageHandler(const CoinMessageHandler&);
85 
86  CMessageHandler& operator=(const CMessageHandler&);
87  /// Clone
88  virtual CoinMessageHandler * clone() const ;
89  //@}
90   
91   
92protected:
93  /**@name Data members
94     The data members are protected to allow access for derived classes. */
95  //@{
96  /// Pointer back to model
97  Clp_Simplex * model_;
98  /// call back
99  clp_callback callback_;
100  //@}
101};
102
103
104//-------------------------------------------------------------------
105// Default Constructor
106//-------------------------------------------------------------------
107CMessageHandler::CMessageHandler () 
108  : CoinMessageHandler(),
109    model_(NULL),
110    callback_(NULL)
111{
112}
113
114//-------------------------------------------------------------------
115// Copy constructor
116//-------------------------------------------------------------------
117CMessageHandler::CMessageHandler (const CMessageHandler & rhs) 
118: CoinMessageHandler(rhs),
119    model_(rhs.model_),
120    callback_(rhs.callback_)
121{ 
122}
123
124CMessageHandler::CMessageHandler (const CoinMessageHandler & rhs) 
125  : CoinMessageHandler(),
126    model_(NULL),
127    callback_(NULL)
128{ 
129}
130
131// Constructor with pointer to model
132CMessageHandler::CMessageHandler(Clp_Simplex * model,
133               FILE * userPointer)
134  : CoinMessageHandler(),
135    model_(model),
136    callback_(NULL)
137{
138}
139
140//-------------------------------------------------------------------
141// Destructor
142//-------------------------------------------------------------------
143CMessageHandler::~CMessageHandler ()
144{
145}
146
147//----------------------------------------------------------------
148// Assignment operator
149//-------------------------------------------------------------------
150CMessageHandler &
151CMessageHandler::operator=(const CMessageHandler& rhs)
152{
153  if (this != &rhs) {
154    CoinMessageHandler::operator=(rhs);
155    model_ = rhs.model_;
156    callback_ = rhs.callback_;
157  }
158  return *this;
159}
160//-------------------------------------------------------------------
161// Clone
162//-------------------------------------------------------------------
163CoinMessageHandler * CMessageHandler::clone() const
164{
165  return new CMessageHandler(*this);
166}
167
168int 
169CMessageHandler::print()
170{
171  if (callback_) {
172    int messageNumber = currentMessage().externalNumber();
173    if (currentSource()!="Clp")
174      messageNumber += 1000000;
175    int i;
176    int nDouble=numberDoubleFields();
177    assert (nDouble<=10);
178    double vDouble[10];
179    for (i=0;i<nDouble;i++)
180      vDouble[i]=doubleValue(i);
181    int nInt=numberIntFields();
182    assert (nInt<=10);
183    int vInt[10];
184    for (i=0;i<nInt;i++)
185      vInt[i]=intValue(i);
186    int nString=numberStringFields();
187    assert (nString<=10);
188    char * vString[10];
189    for (i=0;i<nString;i++) {
190      std::string value = stringValue(i);
191      vString[i]=strdup(value.c_str());
192    }
193    callback_(model_,messageNumber,
194              nDouble,vDouble,
195              nInt,vInt,
196              nString,vString);
197    for (i=0;i<nString;i++) 
198      free(vString[i]);
199   
200  }
201  return CoinMessageHandler::print();
202}
203const Clp_Simplex *
204CMessageHandler::model() const
205{
206  return model_;
207}
208void 
209CMessageHandler::setModel(Clp_Simplex * model)
210{
211  model_ = model;
212}
213// Call back
214void 
215CMessageHandler::setCallBack(clp_callback callback)
216{
217  callback_ = callback;
218}
219
220#include "Clp_C_Interface.h"
221#include <string>
222#include <stdio.h>
223#include <iostream>
224
225/* Default constructor */
226CLPLIBAPI Clp_Simplex *  CLPLINKAGE
227Clp_newModel()
228{
229  Clp_Simplex * model = new Clp_Simplex;
230  model->model_ = new ClpSimplex();
231  model->handler_=NULL;
232  return model;
233}
234/* Destructor */
235CLPLIBAPI void CLPLINKAGE
236Clp_deleteModel(Clp_Simplex * model)
237{
238  delete model->model_;
239  delete model->handler_;
240  delete model;
241}
242
243/* Loads a problem (the constraints on the
244    rows are given by lower and upper bounds). If a pointer is NULL then the
245    following values are the default:
246    <ul>
247    <li> <code>colub</code>: all columns have upper bound infinity
248    <li> <code>collb</code>: all columns have lower bound 0
249    <li> <code>rowub</code>: all rows have upper bound infinity
250    <li> <code>rowlb</code>: all rows have lower bound -infinity
251    <li> <code>obj</code>: all variables have 0 objective coefficient
252    </ul>
253*/
254/* Just like the other loadProblem() method except that the matrix is
255   given in a standard column major ordered format (without gaps). */
256CLPLIBAPI void CLPLINKAGE
257Clp_loadProblem (Clp_Simplex * model,  const int numcols, const int numrows,
258                 const CoinBigIndex * start, const int* index,
259                 const double* value,
260                 const double* collb, const double* colub,   
261                 const double* obj,
262                 const double* rowlb, const double* rowub)
263{
264  model->model_->loadProblem(numcols,numrows,start,index,value,
265                             collb,colub,obj,rowlb,rowub);
266}
267/* Read an mps file from the given filename */
268CLPLIBAPI int CLPLINKAGE
269Clp_readMps(Clp_Simplex * model,const char *filename,
270            int keepNames,
271            int ignoreErrors)
272{
273  return model->model_->readMps(filename,keepNames!=0,ignoreErrors!=0);
274}
275/* Copy in integer informations */
276CLPLIBAPI void CLPLINKAGE
277Clp_copyInIntegerInformation(Clp_Simplex * model,const char * information)
278{
279  model->model_->copyInIntegerInformation(information);
280}
281/* Drop integer informations */
282CLPLIBAPI void CLPLINKAGE
283Clp_deleteIntegerInformation(Clp_Simplex * model)
284{
285  model->model_->deleteIntegerInformation();
286}
287/* Resizes rim part of model  */
288CLPLIBAPI void CLPLINKAGE
289Clp_resize (Clp_Simplex * model, int newNumberRows, int newNumberColumns)
290{
291  model->model_->resize(newNumberRows,newNumberColumns);
292}
293/* Deletes rows */
294CLPLIBAPI void CLPLINKAGE
295Clp_deleteRows(Clp_Simplex * model, int number, const int * which)
296{
297  model->model_->deleteRows(number,which);
298}
299/* Add rows */
300CLPLIBAPI void CLPLINKAGE
301Clp_addRows(Clp_Simplex * model, int number, const double * rowLower, 
302               const double * rowUpper,
303               const int * rowStarts, const int * columns,
304               const double * elements)
305{
306  model->model_->addRows(number,rowLower,rowUpper,rowStarts,columns,elements);
307}
308
309/* Deletes columns */
310CLPLIBAPI void CLPLINKAGE
311Clp_deleteColumns(Clp_Simplex * model, int number, const int * which)
312{
313  model->model_->deleteColumns(number,which);
314}
315/* Add columns */
316CLPLIBAPI void CLPLINKAGE
317Clp_addColumns(Clp_Simplex * model, int number, const double * columnLower, 
318                  const double * columnUpper,
319                  const double * objective,
320                  const int * columnStarts, const int * rows,
321                  const double * elements)
322{
323  model->model_->addColumns(number,columnLower,columnUpper,objective,
324                            columnStarts,rows,elements);
325}
326/* Drops names - makes lengthnames 0 and names empty */
327CLPLIBAPI void CLPLINKAGE
328Clp_dropNames(Clp_Simplex * model)
329{
330  model->model_->dropNames();
331}
332/* Copies in names */
333CLPLIBAPI void CLPLINKAGE
334Clp_copyNames(Clp_Simplex * model, const char * const * rowNamesIn,
335              const char * const * columnNamesIn)
336{
337  int iRow;
338  std::vector<std::string> rowNames;
339  int numberRows = model->model_->numberRows();
340  rowNames.reserve(numberRows);
341  for (iRow=0;iRow<numberRows;iRow++) {
342    rowNames.push_back(rowNamesIn[iRow]);
343  }
344 
345  int iColumn;
346  std::vector<std::string> columnNames;
347  int numberColumns = model->model_->numberColumns();
348  columnNames.reserve(numberColumns);
349  for (iColumn=0;iColumn<numberColumns;iColumn++) {
350    columnNames.push_back(columnNamesIn[iColumn]);
351  }
352  model->model_->copyNames(rowNames,columnNames);
353}
354
355/* Number of rows */
356CLPLIBAPI int CLPLINKAGE
357Clp_numberRows(Clp_Simplex * model)
358{
359  return model->model_->numberRows();
360}
361/* Number of columns */
362CLPLIBAPI int CLPLINKAGE
363Clp_numberColumns(Clp_Simplex * model)
364{
365  return model->model_->numberColumns();
366}
367/* Primal tolerance to use */
368CLPLIBAPI double CLPLINKAGE
369Clp_primalTolerance(Clp_Simplex * model)
370{
371  return model->model_->primalTolerance();
372}
373CLPLIBAPI void CLPLINKAGE
374Clp_setPrimalTolerance(Clp_Simplex * model,  double value) 
375{
376  model->model_->setPrimalTolerance(value);
377}
378/* Dual tolerance to use */
379CLPLIBAPI double CLPLINKAGE
380Clp_dualTolerance(Clp_Simplex * model)
381{
382  return model->model_->dualTolerance();
383}
384CLPLIBAPI void CLPLINKAGE
385Clp_setDualTolerance(Clp_Simplex * model,  double value) 
386{
387  model->model_->setDualTolerance(value);
388}
389/* Dual objective limit */
390CLPLIBAPI double CLPLINKAGE
391Clp_dualObjectiveLimit(Clp_Simplex * model)
392{
393  return model->model_->dualObjectiveLimit();
394}
395CLPLIBAPI void CLPLINKAGE
396Clp_setDualObjectiveLimit(Clp_Simplex * model, double value)
397{
398  model->model_->setDualObjectiveLimit(value);
399}
400/* Objective offset */
401CLPLIBAPI double CLPLINKAGE
402Clp_objectiveOffset(Clp_Simplex * model)
403{
404  return model->model_->objectiveOffset();
405}
406CLPLIBAPI void CLPLINKAGE
407Clp_setObjectiveOffset(Clp_Simplex * model, double value)
408{
409  model->model_->setObjectiveOffset(value);
410}
411/* Fills in array with problem name  */
412CLPLIBAPI void CLPLINKAGE
413Clp_problemName(Clp_Simplex * model, int maxNumberCharacters, char * array)
414{
415  std::string name = model->model_->problemName();
416  maxNumberCharacters = min(maxNumberCharacters,(int)strlen(name.c_str()));
417  strncpy(array,name.c_str(),maxNumberCharacters-1);
418  array[maxNumberCharacters-1]='\0';
419}
420/* Number of iterations */
421CLPLIBAPI int CLPLINKAGE
422Clp_numberIterations(Clp_Simplex * model)
423{
424  return model->model_->numberIterations();
425}
426CLPLIBAPI void CLPLINKAGE
427Clp_setNumberIterations(Clp_Simplex * model, int numberIterations)
428{
429  model->model_->setNumberIterations(numberIterations);
430}
431/* Maximum number of iterations */
432CLPLIBAPI int maximumIterations(Clp_Simplex * model)
433{
434  return model->model_->maximumIterations();
435}
436CLPLIBAPI void CLPLINKAGE
437Clp_setMaximumIterations(Clp_Simplex * model, int value)
438{
439  model->model_->setMaximumIterations(value);
440}
441/* Maximum time in seconds (from when set called) */
442CLPLIBAPI double CLPLINKAGE
443Clp_maximumSeconds(Clp_Simplex * model)
444{
445  return model->model_->maximumSeconds();
446}
447CLPLIBAPI void CLPLINKAGE
448Clp_setMaximumSeconds(Clp_Simplex * model, double value)
449{
450  model->model_->setMaximumSeconds(value);
451}
452/* Returns true if hit maximum iteratio`ns (or time) */
453CLPLIBAPI int CLPLINKAGE
454Clp_hitMaximumIterations(Clp_Simplex * model)
455{
456  return model->model_->hitMaximumIterations() ? 1 : 0;
457}
458/* Status of problem:
459   0 - optimal
460   1 - primal infeasible
461   2 - dual infeasible
462   3 - stopped on iterations etc
463   4 - stopped due to errors
464*/
465CLPLIBAPI int CLPLINKAGE
466Clp_status(Clp_Simplex * model)
467{
468  return model->model_->status();
469}
470/* Set problem status */
471CLPLIBAPI void CLPLINKAGE
472Clp_setProblemStatus(Clp_Simplex * model, int problemStatus)
473{
474  model->model_->setProblemStatus(problemStatus);
475}
476/* Secondary status of problem - may get extended
477   0 - none
478   1 - primal infeasible because dual limit reached
479   2 - scaled problem optimal - unscaled has primal infeasibilities
480   3 - scaled problem optimal - unscaled has dual infeasibilities
481   4 - scaled problem optimal - unscaled has both dual and primal infeasibilities
482*/
483CLPLIBAPI int CLPLINKAGE
484Clp_secondaryStatus(Clp_Simplex * model)
485{
486  return model->model_->secondaryStatus();
487}
488CLPLIBAPI void CLPLINKAGE
489Clp_setSecondaryStatus(Clp_Simplex * model, int status)
490{
491  model->model_->setSecondaryStatus(status);
492}
493/* Direction of optimization (1 - minimize, -1 - maximize, 0 - ignore */
494CLPLIBAPI double CLPLINKAGE
495Clp_optimizationDirection(Clp_Simplex * model)
496{
497  return model->model_->optimizationDirection();
498}
499CLPLIBAPI void CLPLINKAGE
500Clp_setOptimizationDirection(Clp_Simplex * model, double value)
501{
502  model->model_->setOptimizationDirection(value);
503}
504/* Primal row solution */
505CLPLIBAPI double * CLPLINKAGE
506Clp_primalRowSolution(Clp_Simplex * model)
507{
508  return model->model_->primalRowSolution();
509}
510/* Primal column solution */
511CLPLIBAPI double * CLPLINKAGE
512Clp_primalColumnSolution(Clp_Simplex * model)
513{
514  return model->model_->primalColumnSolution();
515}
516/* Dual row solution */
517CLPLIBAPI double * CLPLINKAGE
518Clp_dualRowSolution(Clp_Simplex * model)
519{
520  return model->model_->dualRowSolution();
521}
522/* Reduced costs */
523CLPLIBAPI double * CLPLINKAGE
524Clp_dualColumnSolution(Clp_Simplex * model)
525{
526  return model->model_->dualColumnSolution();
527}
528/* Row lower */
529CLPLIBAPI double* CLPLINKAGE
530Clp_rowLower(Clp_Simplex * model)
531{
532  return model->model_->rowLower();
533}
534/* Row upper  */
535CLPLIBAPI double* CLPLINKAGE
536Clp_rowUpper(Clp_Simplex * model)
537{
538  return model->model_->rowUpper();
539}
540/* Objective */
541CLPLIBAPI double * CLPLINKAGE
542Clp_objective(Clp_Simplex * model)
543{
544  return model->model_->objective();
545}
546/* Column Lower */
547CLPLIBAPI double * CLPLINKAGE
548Clp_columnLower(Clp_Simplex * model)
549{
550  return model->model_->columnLower();
551}
552/* Column Upper */
553CLPLIBAPI double * CLPLINKAGE
554Clp_columnUpper(Clp_Simplex * model)
555{
556  return model->model_->columnUpper();
557}
558/* Number of elements in matrix */
559CLPLIBAPI int CLPLINKAGE
560Clp_getNumElements(Clp_Simplex * model)
561{
562  return model->model_->getNumElements();
563}
564/* Objective value */
565CLPLIBAPI double CLPLINKAGE
566Clp_objectiveValue(Clp_Simplex * model)
567{
568  return model->model_->objectiveValue();
569}
570/* Integer information */
571CLPLIBAPI char * CLPLINKAGE
572Clp_integerInformation(Clp_Simplex * model)
573{
574  return model->model_->integerInformation();
575}
576/* Infeasibility/unbounded ray (NULL returned if none/wrong)
577   Up to user to use delete [] on these arrays.  */
578CLPLIBAPI double * CLPLINKAGE
579Clp_infeasibilityRay(Clp_Simplex * model)
580{
581  return model->model_->infeasibilityRay();
582}
583CLPLIBAPI double * CLPLINKAGE
584Clp_unboundedRay(Clp_Simplex * model)
585{
586  return model->model_->unboundedRay();
587}
588/* See if status array exists (partly for OsiClp) */
589CLPLIBAPI int CLPLINKAGE
590Clp_statusExists(Clp_Simplex * model)
591{
592  return model->model_->statusExists() ? 1 : 0;
593}
594/* Return address of status array (char[numberRows+numberColumns]) */
595CLPLIBAPI unsigned char *  CLPLINKAGE
596Clp_statusArray(Clp_Simplex * model)
597{
598  return model->model_->statusArray();
599}
600/* Copy in status vector */
601CLPLIBAPI void CLPLINKAGE
602Clp_copyinStatus(Clp_Simplex * model, const unsigned char * statusArray)
603{
604  model->model_->copyinStatus(statusArray);
605}
606
607/* User pointer for whatever reason */
608CLPLIBAPI void CLPLINKAGE
609Clp_setUserPointer (Clp_Simplex * model, void * pointer)
610{
611  model->model_->setUserPointer(pointer);
612}
613CLPLIBAPI void * CLPLINKAGE
614Clp_getUserPointer (Clp_Simplex * model)
615{
616  return model->model_->getUserPointer();
617}
618/* Pass in Callback function */
619CLPLIBAPI void CLPLINKAGE
620Clp_registerCallBack(Clp_Simplex * model, 
621                     clp_callback userCallBack)
622{
623  // Will be copy of users one
624  delete model->handler_;
625  model->handler_ = new CMessageHandler(*(model->model_->messageHandler()));
626  model->handler_->setCallBack(userCallBack);
627  model->handler_->setModel(model);
628  model->model_->passInMessageHandler(model->handler_);
629}
630/* Unset Callback function */
631CLPLIBAPI void CLPLINKAGE
632Clp_clearCallBack(Clp_Simplex * model)
633{
634  delete model->handler_;
635  model->handler_=NULL;
636}
637/* Amount of print out:
638   0 - none
639   1 - just final
640   2 - just factorizations
641   3 - as 2 plus a bit more
642   4 - verbose
643   above that 8,16,32 etc just for selective debug
644*/
645CLPLIBAPI void CLPLINKAGE
646Clp_setLogLevel(Clp_Simplex * model, int value)
647{
648  model->model_->setLogLevel(value);
649}
650CLPLIBAPI int CLPLINKAGE
651Clp_logLevel(Clp_Simplex * model)
652{
653  return model->model_->logLevel();
654}
655/* length of names (0 means no names0 */
656CLPLIBAPI int CLPLINKAGE
657Clp_lengthNames(Clp_Simplex * model)
658{
659  return model->model_->lengthNames();
660}
661/* Fill in array (at least lengthNames+1 long) with a row name */
662CLPLIBAPI void CLPLINKAGE
663Clp_rowName(Clp_Simplex * model, int iRow, char * name)
664{
665  std::string rowName=model->model_->rowName(iRow);
666  strcpy(name,rowName.c_str());
667}
668/* Fill in array (at least lengthNames+1 long) with a column name */
669CLPLIBAPI void CLPLINKAGE
670Clp_columnName(Clp_Simplex * model, int iColumn, char * name)
671{
672  std::string columnName= model->model_->columnName(iColumn);
673  strcpy(name,columnName.c_str());
674}
675
676/* General solve algorithm which can do presolve.
677   See  ClpSolve.hpp for options
678*/
679CLPLIBAPI int CLPLINKAGE
680Clp_initialSolve(Clp_Simplex * model)
681{
682  return model->model_->initialSolve();
683}
684/* Dual initial solve */
685CLPLIBAPI int CLPLINKAGE
686Clp_initialDualSolve(Clp_Simplex * model)
687{
688  return model->model_->initialDualSolve();
689}
690/* Primal initial solve */
691CLPLIBAPI int CLPLINKAGE
692Clp_initialPrimalSolve(Clp_Simplex * model)
693{
694  return model->model_->initialPrimalSolve();
695}
696/* Dual algorithm - see ClpSimplexDual.hpp for method */
697CLPLIBAPI int CLPLINKAGE
698Clp_dual(Clp_Simplex * model, int ifValuesPass)
699{
700  return model->model_->dual(ifValuesPass);
701}
702/* Primal algorithm - see ClpSimplexPrimal.hpp for method */
703CLPLIBAPI int CLPLINKAGE
704Clp_primal(Clp_Simplex * model, int ifValuesPass)
705{
706  return model->model_->primal(ifValuesPass);
707}
708/* Sets or unsets scaling, 0 -off, 1 equilibrium, 2 geometric, 3, auto, 4 dynamic(later) */
709CLPLIBAPI void CLPLINKAGE
710Clp_scaling(Clp_Simplex * model, int mode)
711{
712  model->model_->scaling(mode);
713}
714/* Gets scalingFlag */
715CLPLIBAPI int CLPLINKAGE
716Clp_scalingFlag(Clp_Simplex * model)
717{
718  return model->model_->scalingFlag();
719}
720/* Crash - at present just aimed at dual, returns
721   -2 if dual preferred and crash basis created
722   -1 if dual preferred and all slack basis preferred
723   0 if basis going in was not all slack
724   1 if primal preferred and all slack basis preferred
725   2 if primal preferred and crash basis created.
726   
727   if gap between bounds <="gap" variables can be flipped
728   
729   If "pivot" is
730   0 No pivoting (so will just be choice of algorithm)
731   1 Simple pivoting e.g. gub
732   2 Mini iterations
733*/
734CLPLIBAPI int CLPLINKAGE
735Clp_crash(Clp_Simplex * model, double gap,int pivot)
736{
737  return model->model_->crash(gap,pivot);
738}
739/* If problem is primal feasible */
740CLPLIBAPI int CLPLINKAGE
741Clp_primalFeasible(Clp_Simplex * model)
742{
743  return model->model_->primalFeasible() ? 1 : 0;
744}
745/* If problem is dual feasible */
746CLPLIBAPI int CLPLINKAGE
747Clp_dualFeasible(Clp_Simplex * model)
748{
749  return model->model_->dualFeasible() ? 1 : 0;
750}
751/* Dual bound */
752CLPLIBAPI double CLPLINKAGE
753Clp_dualBound(Clp_Simplex * model)
754{
755  return model->model_->dualBound();
756}
757CLPLIBAPI void CLPLINKAGE
758Clp_setDualBound(Clp_Simplex * model, double value)
759{
760  model->model_->setDualBound(value);
761}
762/* Infeasibility cost */
763CLPLIBAPI double CLPLINKAGE
764Clp_infeasibilityCost(Clp_Simplex * model)
765{
766  return model->model_->infeasibilityCost();
767}
768CLPLIBAPI void CLPLINKAGE
769Clp_setInfeasibilityCost(Clp_Simplex * model, double value)
770{
771  model->model_->setInfeasibilityCost(value);
772}
773/* Perturbation:
774   50  - switch on perturbation
775   100 - auto perturb if takes too long (1.0e-6 largest nonzero)
776   101 - we are perturbed
777   102 - don't try perturbing again
778   default is 100
779   others are for playing
780*/
781CLPLIBAPI int CLPLINKAGE
782Clp_perturbation(Clp_Simplex * model)
783{
784  return model->model_->perturbation();
785}
786CLPLIBAPI void CLPLINKAGE
787Clp_setPerturbation(Clp_Simplex * model, int value)
788{
789  model->model_->setPerturbation(value);
790}
791/* Current (or last) algorithm */
792CLPLIBAPI int CLPLINKAGE
793Clp_algorithm(Clp_Simplex * model)
794{
795  return model->model_->algorithm();
796}
797/* Set algorithm */
798CLPLIBAPI void CLPLINKAGE
799Clp_setAlgorithm(Clp_Simplex * model, int value)
800{
801  model->model_->setAlgorithm(value);
802}
803/* Sum of dual infeasibilities */
804CLPLIBAPI double CLPLINKAGE
805Clp_sumDualInfeasibilities(Clp_Simplex * model)
806{
807  return model->model_->sumDualInfeasibilities();
808}
809/* Number of dual infeasibilities */
810CLPLIBAPI int CLPLINKAGE
811Clp_numberDualInfeasibilities(Clp_Simplex * model)
812{
813  return model->model_->numberDualInfeasibilities();
814}
815/* Sum of primal infeasibilities */
816CLPLIBAPI double CLPLINKAGE
817Clp_sumPrimalInfeasibilities(Clp_Simplex * model)
818{
819  return model->model_->sumPrimalInfeasibilities();
820}
821/* Number of primal infeasibilities */
822CLPLIBAPI int CLPLINKAGE
823Clp_numberPrimalInfeasibilities(Clp_Simplex * model)
824{
825  return model->model_->numberPrimalInfeasibilities();
826}
827/* Save model to file, returns 0 if success.  This is designed for
828   use outside algorithms so does not save iterating arrays etc.
829   It does not save any messaging information.
830   Does not save scaling values.
831   It does not know about all types of virtual functions.
832*/
833CLPLIBAPI int CLPLINKAGE
834Clp_saveModel(Clp_Simplex * model, const char * fileName)
835{
836  return model->model_->saveModel(fileName);
837}
838/* Restore model from file, returns 0 if success,
839   deletes current model */
840CLPLIBAPI int CLPLINKAGE
841Clp_restoreModel(Clp_Simplex * model, const char * fileName)
842{
843  return model->model_->restoreModel(fileName);
844}
845 
846/* Just check solution (for external use) - sets sum of
847   infeasibilities etc */
848CLPLIBAPI void CLPLINKAGE
849Clp_checkSolution(Clp_Simplex * model)
850{
851  model->model_->checkSolution();
852}
853/* Number of rows */
854CLPLIBAPI int CLPLINKAGE
855Clp_getNumRows(Clp_Simplex * model)
856{
857  return model->model_->getNumRows();
858}
859/* Number of columns */
860CLPLIBAPI int CLPLINKAGE
861Clp_getNumCols(Clp_Simplex * model)
862{
863  return model->model_->getNumCols();
864}
865/* Number of iterations */
866CLPLIBAPI int CLPLINKAGE
867Clp_getIterationCount(Clp_Simplex * model)
868{
869  return model->model_->getIterationCount();
870}
871/* Are there a numerical difficulties? */
872CLPLIBAPI int CLPLINKAGE
873Clp_isAbandoned(Clp_Simplex * model)
874{
875  return model->model_->isAbandoned() ? 1 : 0;
876}
877/* Is optimality proven? */
878CLPLIBAPI int CLPLINKAGE
879Clp_isProvenOptimal(Clp_Simplex * model)
880{
881  return model->model_->isProvenOptimal() ? 1 : 0;
882}
883/* Is primal infeasiblity proven? */
884CLPLIBAPI int CLPLINKAGE
885Clp_isProvenPrimalInfeasible(Clp_Simplex * model)
886{
887  return model->model_->isProvenPrimalInfeasible() ? 1 : 0;
888}
889/* Is dual infeasiblity proven? */
890CLPLIBAPI int CLPLINKAGE
891Clp_isProvenDualInfeasible(Clp_Simplex * model)
892{
893  return model->model_->isProvenDualInfeasible() ? 1 : 0;
894}
895/* Is the given primal objective limit reached? */
896CLPLIBAPI int CLPLINKAGE
897Clp_isPrimalObjectiveLimitReached(Clp_Simplex * model) 
898{
899  return model->model_->isPrimalObjectiveLimitReached() ? 1 : 0;
900}
901/* Is the given dual objective limit reached? */
902CLPLIBAPI int CLPLINKAGE
903Clp_isDualObjectiveLimitReached(Clp_Simplex * model) 
904{
905  return model->model_->isDualObjectiveLimitReached() ? 1 : 0;
906}
907/* Iteration limit reached? */
908CLPLIBAPI int CLPLINKAGE
909Clp_isIterationLimitReached(Clp_Simplex * model)
910{
911  return model->model_->isIterationLimitReached() ? 1 : 0;
912}
913/* Direction of optimization (1 - minimize, -1 - maximize, 0 - ignore */
914CLPLIBAPI double CLPLINKAGE
915Clp_getObjSense(Clp_Simplex * model)
916{
917  return model->model_->getObjSense();
918}
919/* Primal row solution */
920CLPLIBAPI const double * CLPLINKAGE
921Clp_getRowActivity(Clp_Simplex * model)
922{
923  return model->model_->getRowActivity();
924}
925/* Primal column solution */
926CLPLIBAPI const double * CLPLINKAGE
927Clp_getColSolution(Clp_Simplex * model)
928{
929  return model->model_->getColSolution();
930}
931CLPLIBAPI void CLPLINKAGE
932Clp_setColSolution(Clp_Simplex * model, const double * input)
933{
934  model->model_->setColSolution(input);
935}
936/* Dual row solution */
937CLPLIBAPI const double * CLPLINKAGE
938Clp_getRowPrice(Clp_Simplex * model)
939{
940  return model->model_->getRowPrice();
941}
942/* Reduced costs */
943CLPLIBAPI const double * CLPLINKAGE
944Clp_getReducedCost(Clp_Simplex * model)
945{
946  return model->model_->getReducedCost();
947}
948/* Row lower */
949CLPLIBAPI const double* CLPLINKAGE
950Clp_getRowLower(Clp_Simplex * model)
951{
952  return model->model_->getRowLower();
953}
954/* Row upper  */
955CLPLIBAPI const double* CLPLINKAGE
956Clp_getRowUpper(Clp_Simplex * model)
957{
958  return model->model_->getRowUpper();
959}
960/* Objective */
961CLPLIBAPI const double * CLPLINKAGE
962Clp_getObjCoefficients(Clp_Simplex * model)
963{
964  return model->model_->getObjCoefficients();
965}
966/* Column Lower */
967CLPLIBAPI const double * CLPLINKAGE
968Clp_getColLower(Clp_Simplex * model)
969{
970  return model->model_->getColLower();
971}
972/* Column Upper */
973CLPLIBAPI const double * CLPLINKAGE
974Clp_getColUpper(Clp_Simplex * model)
975{
976  return model->model_->getColUpper();
977}
978/* Objective value */
979CLPLIBAPI double CLPLINKAGE
980Clp_getObjValue(Clp_Simplex * model)
981{
982  return model->model_->getObjValue();
983}
984
Note: See TracBrowser for help on using the repository browser.