source: trunk/include/Cbc_C_Interface.h @ 2

Last change on this file since 2 was 2, checked in by ladanyi, 15 years ago

Import of Coin Branch-and-Cut (formerly known as Sbb)

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 18.1 KB
Line 
1/* Copyright (C) 2004 International Business Machines
2   Corporation and others.  All Rights Reserved.*/
3#ifndef CbcModelC_H
4#define CbcModelC_H
5
6/* include all defines and ugly stuff */
7#include "Coin_C_defines.h"
8
9/** This is a first "C" interface to Cbc.
10    It is mostly similar to the "C" interface to Clp and
11    was contributed by Bob Entriken.
12*/
13
14#ifdef __cplusplus
15extern "C"{
16#endif
17 
18  /**@name Constructors and destructor
19     These do not have an exact analogue in C++.
20     The user does not need to know structure of Cbc_Model.
21     
22     For all functions outside this group there is an exact C++
23     analogue created by taking the first parameter out, removing the Cbc_
24     from name and applying the method to an object of type ClpSimplex.
25  */
26  /*@{*/
27
28  /** Default constructor */
29  COINLIBAPI Cbc_Model * COINLINKAGE Cbc_newModel(void);
30  /** Destructor */
31  COINLIBAPI void COINLINKAGE Cbc_deleteModel(Cbc_Model * model);
32  /*@}*/
33
34  /**@name Load model - loads some stuff and initializes others */
35  /*@{*/
36  /** Loads a problem (the constraints on the
37      rows are given by lower and upper bounds). If a pointer is NULL then the
38      following values are the default:
39      <ul>
40      <li> <code>colub</code>: all columns have upper bound infinity
41      <li> <code>collb</code>: all columns have lower bound 0
42      <li> <code>rowub</code>: all rows have upper bound infinity
43      <li> <code>rowlb</code>: all rows have lower bound -infinity
44      <li> <code>obj</code>: all variables have 0 objective coefficient
45      </ul>
46  */
47  /** Just like the other loadProblem() method except that the matrix is
48        given in a standard column major ordered format (without gaps). */
49  COINLIBAPI void COINLINKAGE Cbc_loadProblem (Cbc_Model * model,  const int numcols, const int numrows,
50                      const CoinBigIndex * start, const int* index,
51                      const double* value,
52                      const double* collb, const double* colub,   
53                      const double* obj,
54                      const double* rowlb, const double* rowub);
55  /** Read an mps file from the given filename */
56  COINLIBAPI int COINLINKAGE Cbc_readMps(Cbc_Model * model,const char *filename);
57  /** Write an mps file from the given filename */
58  COINLIBAPI void COINLINKAGE Cbc_writeMps(Cbc_Model * model,const char *filename);  /** Copy in integer informations */
59  /** Copy in integer informations */
60  COINLIBAPI void COINLINKAGE Cbc_copyInIntegerInformation(Cbc_Model * model,const char * information);
61  /** Drop integer informations */
62  COINLIBAPI void COINLINKAGE Cbc_deleteIntegerInformation(Cbc_Model * model);
63  /** Resizes rim part of model  */
64  COINLIBAPI void COINLINKAGE Cbc_resize (Cbc_Model * model, int newNumberRows, int newNumberColumns);
65  /** Deletes rows */
66  COINLIBAPI void COINLINKAGE Cbc_deleteRows(Cbc_Model * model, int number, const int * which);
67  /** Add rows */
68  COINLIBAPI void COINLINKAGE Cbc_addRows(Cbc_Model * model, int number, const double * rowLower, 
69               const double * rowUpper,
70               const int * rowStarts, const int * columns,
71               const double * elements);
72
73  /** Deletes columns */
74  COINLIBAPI void COINLINKAGE Cbc_deleteColumns(Cbc_Model * model, int number, const int * which);
75  /** Add columns */
76  COINLIBAPI void COINLINKAGE Cbc_addColumns(Cbc_Model * model, int number, const double * columnLower, 
77                  const double * columnUpper,
78                  const double * objective,
79                  const int * columnStarts, const int * rows,
80                  const double * elements);
81  /** Drops names - makes lengthnames 0 and names empty */
82  COINLIBAPI void COINLINKAGE Cbc_dropNames(Cbc_Model * model);
83  /** Copies in names */
84  COINLIBAPI void COINLINKAGE Cbc_copyNames(Cbc_Model * model, const char * const * rowNames,
85                 const char * const * columnNames);
86 
87  /*@}*/
88  /**@name gets and sets - you will find some synonyms at the end of this file */
89  /*@{*/ 
90  /** Number of rows */
91  COINLIBAPI int COINLINKAGE Cbc_numberRows(Cbc_Model * model);
92  /** Number of columns */
93  COINLIBAPI int COINLINKAGE Cbc_numberColumns(Cbc_Model * model);
94  /** Primal tolerance to use */
95  COINLIBAPI double COINLINKAGE Cbc_primalTolerance(Cbc_Model * model);
96  COINLIBAPI void COINLINKAGE Cbc_setPrimalTolerance(Cbc_Model * model,  double value) ;
97  /** Dual tolerance to use */
98  COINLIBAPI double COINLINKAGE Cbc_dualTolerance(Cbc_Model * model);
99  COINLIBAPI void COINLINKAGE Cbc_setDualTolerance(Cbc_Model * model,  double value) ;
100  /* Integer tolerance to use */
101  COINLIBAPI double COINLINKAGE Cbc_integerTolerance(Cbc_Model * model);
102  COINLIBAPI void COINLINKAGE Cbc_setIntegerTolerance(Cbc_Model * model,  double value);
103  /** Dual objective limit */
104  COINLIBAPI double COINLINKAGE Cbc_dualObjectiveLimit(Cbc_Model * model);
105  COINLIBAPI void COINLINKAGE Cbc_setDualObjectiveLimit(Cbc_Model * model, double value);
106  /** Objective offset */
107  COINLIBAPI double COINLINKAGE Cbc_objectiveOffset(Cbc_Model * model);
108  COINLIBAPI void COINLINKAGE Cbc_setObjectiveOffset(Cbc_Model * model, double value);
109  /** Fills in array with problem name  */
110  COINLIBAPI void COINLINKAGE Cbc_problemName(Cbc_Model * model, int maxNumberCharacters, char * array);
111  /** Sets problem name.  Must have \0 at end.  */
112  COINLIBAPI int COINLINKAGE
113  Cbc_setProblemName(Cbc_Model * model, int maxNumberCharacters, char * array);
114  /** Number of iterations */
115  COINLIBAPI int COINLINKAGE Cbc_numberIterations(Cbc_Model * model);
116  COINLIBAPI void COINLINKAGE Cbc_setNumberIterations(Cbc_Model * model, int numberIterations);
117  /** Maximum number of iterations */
118  COINLIBAPI int Cbc_maximumIterations(Cbc_Model * model);
119  COINLIBAPI void COINLINKAGE Cbc_setMaximumIterations(Cbc_Model * model, int value);
120  /** Maximum time in seconds (from when set called) */
121  COINLIBAPI double COINLINKAGE Cbc_maximumSeconds(Cbc_Model * model);
122  COINLIBAPI void COINLINKAGE Cbc_setMaximumSeconds(Cbc_Model * model, double value);
123  /** Returns true if hit maximum iterations (or time) */
124  COINLIBAPI int COINLINKAGE Cbc_hitMaximumIterations(Cbc_Model * model);
125  /** Status of problem:
126      0 - optimal
127      1 - primal infeasible
128      2 - dual infeasible
129      3 - stopped on iterations etc
130      4 - stopped due to errors
131  */
132  COINLIBAPI int COINLINKAGE Cbc_status(Cbc_Model * model);
133  /** Set problem status */
134  COINLIBAPI void COINLINKAGE Cbc_setProblemStatus(Cbc_Model * model, int problemStatus);
135  /** Secondary status of problem - may get extended
136      0 - none
137      1 - primal infeasible because dual limit reached
138      2 - scaled problem optimal - unscaled has primal infeasibilities
139      3 - scaled problem optimal - unscaled has dual infeasibilities
140      4 - scaled problem optimal - unscaled has both dual and primal infeasibilities
141  */
142  COINLIBAPI int COINLINKAGE Cbc_secondaryStatus(Cbc_Model * model);
143  COINLIBAPI void COINLINKAGE Cbc_setSecondaryStatus(Cbc_Model * model, int status);
144  /** Direction of optimization (1 - minimize, -1 - maximize, 0 - ignore */
145  COINLIBAPI double COINLINKAGE Cbc_optimizationDirection(Cbc_Model * model);
146  COINLIBAPI void COINLINKAGE Cbc_setOptimizationDirection(Cbc_Model * model, double value);
147  /** Primal row solution */
148  COINLIBAPI double * COINLINKAGE Cbc_primalRowSolution(Cbc_Model * model);
149  /** Primal column solution */
150  COINLIBAPI double * COINLINKAGE Cbc_primalColumnSolution(Cbc_Model * model);
151  /** Dual row solution */
152  COINLIBAPI double * COINLINKAGE Cbc_dualRowSolution(Cbc_Model * model);
153  /** Reduced costs */
154  COINLIBAPI double * COINLINKAGE Cbc_dualColumnSolution(Cbc_Model * model);
155  /** Row lower */
156  COINLIBAPI double* COINLINKAGE Cbc_rowLower(Cbc_Model * model);
157  /** Row upper  */
158  COINLIBAPI double* COINLINKAGE Cbc_rowUpper(Cbc_Model * model);
159  /** Objective */
160  COINLIBAPI double * COINLINKAGE Cbc_objective(Cbc_Model * model);           
161  /** Column Lower */
162  COINLIBAPI double * COINLINKAGE Cbc_columnLower(Cbc_Model * model);
163  /** Column Upper */
164  COINLIBAPI double * COINLINKAGE Cbc_columnUpper(Cbc_Model * model);
165  /** Number of elements in matrix */
166  COINLIBAPI int COINLINKAGE Cbc_getNumElements(Cbc_Model * model);
167  /** Column starts in matrix */
168  COINLIBAPI const CoinBigIndex * COINLINKAGE Cbc_getVectorStarts(Cbc_Model * model); 
169  /** Row indices in matrix */
170  COINLIBAPI const int * COINLINKAGE Cbc_getIndices(Cbc_Model * model); 
171  /** Column vector lengths in matrix */
172  COINLIBAPI const int * COINLINKAGE Cbc_getVectorLengths(Cbc_Model * model); 
173  /** Element values in matrix */
174  COINLIBAPI const double * COINLINKAGE Cbc_getElements(Cbc_Model * model); 
175  /** Objective value */
176  COINLIBAPI double COINLINKAGE Cbc_objectiveValue(Cbc_Model * model);
177  /** Integer information */
178  COINLIBAPI char * COINLINKAGE Cbc_integerInformation(Cbc_Model * model);
179  /** Infeasibility/unbounded ray (NULL returned if none/wrong)
180      Up to user to use delete [] on these arrays.  */
181  COINLIBAPI double * COINLINKAGE Cbc_infeasibilityRay(Cbc_Model * model);
182  COINLIBAPI double * COINLINKAGE Cbc_unboundedRay(Cbc_Model * model);
183  /** See if status array exists (partly for OsiClp) */
184  COINLIBAPI int COINLINKAGE Cbc_statusExists(Cbc_Model * model);
185  /** Return address of status array (char[numberRows+numberColumns]) */
186  COINLIBAPI void  COINLINKAGE Cbc_getBasisStatus(Cbc_Model * model, int * cstat, int * rstat);
187  /** Copy in status vector */
188  COINLIBAPI void COINLINKAGE setBasisStatus(Cbc_Model * model, int * cstat, int * rstat);
189 
190  /** User pointer for whatever reason */
191  COINLIBAPI void COINLINKAGE Cbc_setUserPointer (Cbc_Model * model, void * pointer);
192  COINLIBAPI void * COINLINKAGE Cbc_getUserPointer (Cbc_Model * model);
193  /*@}*/
194  /**@name Message handling.  Call backs are handled by ONE function */
195  /*@{*/
196  /** Pass in Callback function.
197   Message numbers up to 1000000 are Clp, Coin ones have 1000000 added */
198  COINLIBAPI void COINLINKAGE Cbc_registerCallBack(Cbc_Model * model, 
199                                                   cbc_callback userCallBack);
200  /** Unset Callback function */
201  COINLIBAPI void COINLINKAGE Cbc_clearCallBack(Cbc_Model * model);
202  /** Amount of print out:
203      0 - none
204      1 - just final
205      2 - just factorizations
206      3 - as 2 plus a bit more
207      4 - verbose
208      above that 8,16,32 etc just for selective debug
209  */
210  COINLIBAPI void COINLINKAGE Cbc_setLogLevel(Cbc_Model * model, int value);
211  COINLIBAPI int COINLINKAGE Cbc_logLevel(Cbc_Model * model);
212  /** length of names (0 means no names0 */
213  COINLIBAPI int COINLINKAGE Cbc_lengthNames(Cbc_Model * model);
214  /** Fill in array (at least lengthNames+1 long) with a row name */
215  COINLIBAPI void COINLINKAGE Cbc_rowName(Cbc_Model * model, int iRow, char * name);
216  /** Fill in array (at least lengthNames+1 long) with a column name */
217  COINLIBAPI void COINLINKAGE Cbc_columnName(Cbc_Model * model, int iColumn, char * name);
218
219  /*@}*/
220
221
222  /**@name Functions most useful to user */
223  /*@{*/
224  /** General solve algorithm which can do presolve.
225      See  ClpSolve.hpp for options
226   */
227  COINLIBAPI int COINLINKAGE Cbc_initialSolve(Cbc_Model * model);
228  /* General solve algorithm which can do presolve.
229     See  CbcModel.hpp for options
230  */
231  COINLIBAPI int COINLINKAGE Cbc_branchAndBound(Cbc_Model * model);
232  /** Dual initial solve */
233  COINLIBAPI int COINLINKAGE Cbc_initialDualSolve(Cbc_Model * model);
234  /** Primal initial solve */
235  COINLIBAPI int COINLINKAGE Cbc_initialPrimalSolve(Cbc_Model * model);
236  /** Dual algorithm - see ClpSimplexDual.hpp for method */
237  COINLIBAPI int COINLINKAGE Cbc_dual(Cbc_Model * model, int ifValuesPass);
238  /** Primal algorithm - see ClpSimplexPrimal.hpp for method */
239  COINLIBAPI int COINLINKAGE Cbc_primal(Cbc_Model * model, int ifValuesPass);
240  /** Sets or unsets scaling, 0 -off, 1 equilibrium, 2 geometric, 3, auto, 4 dynamic(later) */
241  COINLIBAPI void COINLINKAGE Cbc_scaling(Cbc_Model * model, int mode);
242  /** Gets scalingFlag */
243  COINLIBAPI int COINLINKAGE Cbc_scalingFlag(Cbc_Model * model);
244  /** Crash - at present just aimed at dual, returns
245      -2 if dual preferred and crash basis created
246      -1 if dual preferred and all slack basis preferred
247       0 if basis going in was not all slack
248       1 if primal preferred and all slack basis preferred
249       2 if primal preferred and crash basis created.
250       
251       if gap between bounds <="gap" variables can be flipped
252
253       If "pivot" is
254       0 No pivoting (so will just be choice of algorithm)
255       1 Simple pivoting e.g. gub
256       2 Mini iterations
257  */
258  COINLIBAPI int COINLINKAGE Cbc_crash(Cbc_Model * model, double gap,int pivot);
259  /*@}*/
260
261
262  /**@name most useful gets and sets */
263  /*@{*/ 
264  /** If problem is primal feasible */
265  COINLIBAPI int COINLINKAGE Cbc_primalFeasible(Cbc_Model * model);
266  /** If problem is dual feasible */
267  COINLIBAPI int COINLINKAGE Cbc_dualFeasible(Cbc_Model * model);
268  /** Dual bound */
269  COINLIBAPI double COINLINKAGE Cbc_dualBound(Cbc_Model * model);
270  COINLIBAPI void COINLINKAGE Cbc_setDualBound(Cbc_Model * model, double value);
271  /** Infeasibility cost */
272  COINLIBAPI double COINLINKAGE Cbc_infeasibilityCost(Cbc_Model * model);
273  COINLIBAPI void COINLINKAGE Cbc_setInfeasibilityCost(Cbc_Model * model, double value);
274  /** Perturbation:
275      50  - switch on perturbation
276      100 - auto perturb if takes too long (1.0e-6 largest nonzero)
277      101 - we are perturbed
278      102 - don't try perturbing again
279      default is 100
280      others are for playing
281  */
282  COINLIBAPI int COINLINKAGE Cbc_perturbation(Cbc_Model * model);
283  COINLIBAPI void COINLINKAGE Cbc_setPerturbation(Cbc_Model * model, int value);
284  /** Current (or last) algorithm */
285  COINLIBAPI int COINLINKAGE Cbc_algorithm(Cbc_Model * model); 
286  /** Set algorithm */
287  COINLIBAPI void COINLINKAGE Cbc_setAlgorithm(Cbc_Model * model, int value);
288  /** Sum of dual infeasibilities */
289  COINLIBAPI double COINLINKAGE Cbc_sumDualInfeasibilities(Cbc_Model * model); 
290  /** Number of dual infeasibilities */
291  COINLIBAPI int COINLINKAGE Cbc_numberDualInfeasibilities(Cbc_Model * model); 
292  /** Sum of primal infeasibilities */
293  COINLIBAPI double COINLINKAGE Cbc_sumPrimalInfeasibilities(Cbc_Model * model); 
294  /** Number of primal infeasibilities */
295  COINLIBAPI int COINLINKAGE Cbc_numberPrimalInfeasibilities(Cbc_Model * model); 
296  /** Save model to file, returns 0 if success.  This is designed for
297      use outside algorithms so does not save iterating arrays etc.
298  It does not save any messaging information.
299  Does not save scaling values.
300  It does not know about all types of virtual functions.
301  */
302  COINLIBAPI int COINLINKAGE Cbc_saveModel(Cbc_Model * model, const char * fileName);
303  /** Restore model from file, returns 0 if success,
304      deletes current model */
305  COINLIBAPI int COINLINKAGE Cbc_restoreModel(Cbc_Model * model, const char * fileName);
306 
307  /** Just check solution (for external use) - sets sum of
308      infeasibilities etc */
309  COINLIBAPI void COINLINKAGE Cbc_checkSolution(Cbc_Model * model);
310  /*@}*/
311
312  /******************** End of most useful part **************/
313  /**@name gets and sets - some synonyms */
314  /*@{*/ 
315  /** Number of rows */
316  COINLIBAPI int COINLINKAGE Cbc_getNumRows(Cbc_Model * model);
317  /** Number of columns */
318  COINLIBAPI int COINLINKAGE Cbc_getNumCols(Cbc_Model * model);
319  /** Number of iterations */
320  COINLIBAPI int COINLINKAGE Cbc_getIterationCount(Cbc_Model * model);
321  /** Are there a numerical difficulties? */
322  COINLIBAPI int COINLINKAGE Cbc_isAbandoned(Cbc_Model * model);
323  /** Is optimality proven? */
324  COINLIBAPI int COINLINKAGE Cbc_isProvenOptimal(Cbc_Model * model);
325  /** Is primal infeasiblity proven? */
326  COINLIBAPI int COINLINKAGE Cbc_isProvenPrimalInfeasible(Cbc_Model * model);
327  /** Is dual infeasiblity proven? */
328  COINLIBAPI int COINLINKAGE Cbc_isProvenDualInfeasible(Cbc_Model * model);
329  /** Is the given primal objective limit reached? */
330  COINLIBAPI int COINLINKAGE Cbc_isPrimalObjectiveLimitReached(Cbc_Model * model) ;
331  /** Is the given dual objective limit reached? */
332  COINLIBAPI int COINLINKAGE Cbc_isDualObjectiveLimitReached(Cbc_Model * model) ;
333  /** Iteration limit reached? */
334  COINLIBAPI int COINLINKAGE Cbc_isIterationLimitReached(Cbc_Model * model);
335  /** Direction of optimization (1 - minimize, -1 - maximize, 0 - ignore */
336  COINLIBAPI double COINLINKAGE Cbc_getObjSense(Cbc_Model * model);
337  /** Primal row solution */
338  COINLIBAPI const double * COINLINKAGE Cbc_getRowActivity(Cbc_Model * model);
339  /** Primal column solution */
340  COINLIBAPI const double * COINLINKAGE Cbc_getColSolution(Cbc_Model * model);
341  COINLIBAPI void COINLINKAGE Cbc_setColSolution(Cbc_Model * model, const double * input);
342  /** Dual row solution */
343  COINLIBAPI const double * COINLINKAGE Cbc_getRowPrice(Cbc_Model * model);
344  /** Reduced costs */
345  COINLIBAPI const double * COINLINKAGE Cbc_getReducedCost(Cbc_Model * model);
346  /** Row lower */
347  COINLIBAPI const double* COINLINKAGE Cbc_getRowLower(Cbc_Model * model);
348  /** Row upper  */
349  COINLIBAPI const double* COINLINKAGE Cbc_getRowUpper(Cbc_Model * model);
350  /** Objective */
351  COINLIBAPI const double * COINLINKAGE Cbc_getObjCoefficients(Cbc_Model * model); 
352  /** Column Lower */
353  COINLIBAPI const double * COINLINKAGE Cbc_getColLower(Cbc_Model * model);
354  /** Column Upper */
355  COINLIBAPI const double * COINLINKAGE Cbc_getColUpper(Cbc_Model * model);
356  /** Objective value */
357  COINLIBAPI double COINLINKAGE Cbc_getObjValue(Cbc_Model * model);
358  /** Print the model */
359  COINLIBAPI void COINLINKAGE Cbc_printModel(Cbc_Model * model, const char * prefix);
360  /** Determine whether the variable at location i is integer restricted */
361  COINLIBAPI int COINLINKAGE Cbc_isInteger(Cbc_Model * model, int i);
362  /** Return CPU time */
363  COINLIBAPI double COINLINKAGE Cbc_cpuTime(Cbc_Model * model);
364  /** Number of nodes explored in B&B tree */
365  COINLIBAPI int COINLINKAGE Cbc_getNodeCount(Cbc_Model * model);
366  /** Return a copy of this model */
367  COINLIBAPI Cbc_Model * COINLINKAGE Cbc_clone(Cbc_Model * model);
368  /** Set this the variable to be continuous */
369  COINLIBAPI Cbc_Model * COINLINKAGE Cbc_setContinuous(Cbc_Model * model, int iColumn);
370  /* Add an SOS constraint to the model */
371  COINLIBAPI void  COINLINKAGE Cbc_addSOS(Cbc_Model * model, int numberMembers,
372             const int * which, const double * weights, int identifier, int type);
373  /* Delete all object information */
374  COINLIBAPI void  COINLINKAGE Cbc_deleteObjects(Cbc_Model * model);
375  /* Print the solution */
376  COINLIBAPI void  COINLINKAGE Cbc_printSolution(Cbc_Model * model);
377  /*@}*/
378#ifdef __cplusplus
379          }
380#endif
381#endif
Note: See TracBrowser for help on using the repository browser.