source: trunk/Clp/src/Clp_C_Interface.h @ 754

Last change on this file since 754 was 754, checked in by andreasw, 14 years ago

first version

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 18.5 KB
Line 
1/* Copyright (C) 2002, 2003 International Business Machines
2   Corporation and others.  All Rights Reserved.*/
3#ifndef ClpSimplexC_H
4#define ClpSimplexC_H
5
6/* include all defines and ugly stuff */
7#include "Coin_C_defines.h"
8
9/** This is a first "C" interface to Clp.
10    It has similarities to the OSL V3 interface
11    and only has most common functions
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 Clp_Simplex.
21     
22     For all functions outside this group there is an exact C++
23     analogue created by taking the first parameter out, removing the Clp_
24     from name and applying the method to an object of type ClpSimplex.
25  */
26  /*@{*/
27
28  /** Default constructor */
29  COINLIBAPI Clp_Simplex * COINLINKAGE Clp_newModel(void);
30  /** Destructor */
31  COINLIBAPI void COINLINKAGE Clp_deleteModel(Clp_Simplex * 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 Clp_loadProblem (Clp_Simplex * 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 Clp_readMps(Clp_Simplex * model,const char *filename,
57              int keepNames,
58              int ignoreErrors);
59  /** Copy in integer informations */
60  COINLIBAPI void COINLINKAGE Clp_copyInIntegerInformation(Clp_Simplex * model,const char * information);
61  /** Drop integer informations */
62  COINLIBAPI void COINLINKAGE Clp_deleteIntegerInformation(Clp_Simplex * model);
63  /** Resizes rim part of model  */
64  COINLIBAPI void COINLINKAGE Clp_resize (Clp_Simplex * model, int newNumberRows, int newNumberColumns);
65  /** Deletes rows */
66  COINLIBAPI void COINLINKAGE Clp_deleteRows(Clp_Simplex * model, int number, const int * which);
67  /** Add rows */
68  COINLIBAPI void COINLINKAGE Clp_addRows(Clp_Simplex * 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 Clp_deleteColumns(Clp_Simplex * model, int number, const int * which);
75  /** Add columns */
76  COINLIBAPI void COINLINKAGE Clp_addColumns(Clp_Simplex * 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  /** Change row lower bounds */
82  COINLIBAPI void COINLINKAGE Clp_chgRowLower(Clp_Simplex * model, const double * rowLower);
83  /** Change row upper bounds */
84  COINLIBAPI void COINLINKAGE Clp_chgRowUpper(Clp_Simplex * model, const double * rowUpper); 
85  /** Change column lower bounds */
86  COINLIBAPI void COINLINKAGE Clp_chgColumnLower(Clp_Simplex * model, const double * columnLower); 
87  /** Change column upper bounds */
88  COINLIBAPI void COINLINKAGE Clp_chgColumnUpper(Clp_Simplex * model, const double * columnUpper); 
89  /** Change objective coefficients */
90  COINLIBAPI void COINLINKAGE Clp_chgObjCoefficients(Clp_Simplex * model, const double * objIn); 
91  /** Drops names - makes lengthnames 0 and names empty */
92  COINLIBAPI void COINLINKAGE Clp_dropNames(Clp_Simplex * model);
93  /** Copies in names */
94  COINLIBAPI void COINLINKAGE Clp_copyNames(Clp_Simplex * model, const char * const * rowNames,
95                 const char * const * columnNames);
96 
97  /*@}*/
98  /**@name gets and sets - you will find some synonyms at the end of this file */
99  /*@{*/ 
100  /** Number of rows */
101  COINLIBAPI int COINLINKAGE Clp_numberRows(Clp_Simplex * model);
102  /** Number of columns */
103  COINLIBAPI int COINLINKAGE Clp_numberColumns(Clp_Simplex * model);
104  /** Primal tolerance to use */
105  COINLIBAPI double COINLINKAGE Clp_primalTolerance(Clp_Simplex * model);
106  COINLIBAPI void COINLINKAGE Clp_setPrimalTolerance(Clp_Simplex * model,  double value) ;
107  /** Dual tolerance to use */
108  COINLIBAPI double COINLINKAGE Clp_dualTolerance(Clp_Simplex * model);
109  COINLIBAPI void COINLINKAGE Clp_setDualTolerance(Clp_Simplex * model,  double value) ;
110  /** Dual objective limit */
111  COINLIBAPI double COINLINKAGE Clp_dualObjectiveLimit(Clp_Simplex * model);
112  COINLIBAPI void COINLINKAGE Clp_setDualObjectiveLimit(Clp_Simplex * model, double value);
113  /** Objective offset */
114  COINLIBAPI double COINLINKAGE Clp_objectiveOffset(Clp_Simplex * model);
115  COINLIBAPI void COINLINKAGE Clp_setObjectiveOffset(Clp_Simplex * model, double value);
116  /** Fills in array with problem name  */
117  COINLIBAPI void COINLINKAGE Clp_problemName(Clp_Simplex * model, int maxNumberCharacters, char * array);
118  /* Sets problem name.  Must have \0 at end.  */
119  COINLIBAPI bool COINLINKAGE
120    Clp_setProblemName(Clp_Simplex * model, int maxNumberCharacters, char * array);
121  /** Number of iterations */
122  COINLIBAPI int COINLINKAGE Clp_numberIterations(Clp_Simplex * model);
123  COINLIBAPI void COINLINKAGE Clp_setNumberIterations(Clp_Simplex * model, int numberIterations);
124  /** Maximum number of iterations */
125  COINLIBAPI int maximumIterations(Clp_Simplex * model);
126  COINLIBAPI void COINLINKAGE Clp_setMaximumIterations(Clp_Simplex * model, int value);
127  /** Maximum time in seconds (from when set called) */
128  COINLIBAPI double COINLINKAGE Clp_maximumSeconds(Clp_Simplex * model);
129  COINLIBAPI void COINLINKAGE Clp_setMaximumSeconds(Clp_Simplex * model, double value);
130  /** Returns true if hit maximum iterations (or time) */
131  COINLIBAPI int COINLINKAGE Clp_hitMaximumIterations(Clp_Simplex * model);
132  /** Status of problem:
133      0 - optimal
134      1 - primal infeasible
135      2 - dual infeasible
136      3 - stopped on iterations etc
137      4 - stopped due to errors
138  */
139  COINLIBAPI int COINLINKAGE Clp_status(Clp_Simplex * model);
140  /** Set problem status */
141  COINLIBAPI void COINLINKAGE Clp_setProblemStatus(Clp_Simplex * model, int problemStatus);
142  /** Secondary status of problem - may get extended
143      0 - none
144      1 - primal infeasible because dual limit reached
145      2 - scaled problem optimal - unscaled has primal infeasibilities
146      3 - scaled problem optimal - unscaled has dual infeasibilities
147      4 - scaled problem optimal - unscaled has both dual and primal infeasibilities
148  */
149  COINLIBAPI int COINLINKAGE Clp_secondaryStatus(Clp_Simplex * model);
150  COINLIBAPI void COINLINKAGE Clp_setSecondaryStatus(Clp_Simplex * model, int status);
151  /** Direction of optimization (1 - minimize, -1 - maximize, 0 - ignore */
152  COINLIBAPI double COINLINKAGE Clp_optimizationDirection(Clp_Simplex * model);
153  COINLIBAPI void COINLINKAGE Clp_setOptimizationDirection(Clp_Simplex * model, double value);
154  /** Primal row solution */
155  COINLIBAPI double * COINLINKAGE Clp_primalRowSolution(Clp_Simplex * model);
156  /** Primal column solution */
157  COINLIBAPI double * COINLINKAGE Clp_primalColumnSolution(Clp_Simplex * model);
158  /** Dual row solution */
159  COINLIBAPI double * COINLINKAGE Clp_dualRowSolution(Clp_Simplex * model);
160  /** Reduced costs */
161  COINLIBAPI double * COINLINKAGE Clp_dualColumnSolution(Clp_Simplex * model);
162  /** Row lower */
163  COINLIBAPI double* COINLINKAGE Clp_rowLower(Clp_Simplex * model);
164  /** Row upper  */
165  COINLIBAPI double* COINLINKAGE Clp_rowUpper(Clp_Simplex * model);
166  /** Objective */
167  COINLIBAPI double * COINLINKAGE Clp_objective(Clp_Simplex * model);           
168  /** Column Lower */
169  COINLIBAPI double * COINLINKAGE Clp_columnLower(Clp_Simplex * model);
170  /** Column Upper */
171  COINLIBAPI double * COINLINKAGE Clp_columnUpper(Clp_Simplex * model);
172  /** Number of elements in matrix */
173  COINLIBAPI int COINLINKAGE Clp_getNumElements(Clp_Simplex * model); 
174  /* Column starts in matrix */
175  COINLIBAPI const CoinBigIndex * COINLINKAGE Clp_getVectorStarts(Clp_Simplex * model); 
176  /* Row indices in matrix */
177  COINLIBAPI const int * COINLINKAGE Clp_getIndices(Clp_Simplex * model); 
178  /* Column vector lengths in matrix */
179  COINLIBAPI const int * COINLINKAGE Clp_getVectorLengths(Clp_Simplex * model); 
180  /* Element values in matrix */
181  COINLIBAPI const double * COINLINKAGE Clp_getElements(Clp_Simplex * model); 
182  /** Objective value */
183  COINLIBAPI double COINLINKAGE Clp_objectiveValue(Clp_Simplex * model);
184  /** Integer information */
185  COINLIBAPI char * COINLINKAGE Clp_integerInformation(Clp_Simplex * model);
186  /** Infeasibility/unbounded ray (NULL returned if none/wrong)
187      Up to user to use delete [] on these arrays.  */
188  COINLIBAPI double * COINLINKAGE Clp_infeasibilityRay(Clp_Simplex * model);
189  COINLIBAPI double * COINLINKAGE Clp_unboundedRay(Clp_Simplex * model);
190  /** See if status array exists (partly for OsiClp) */
191  COINLIBAPI int COINLINKAGE Clp_statusExists(Clp_Simplex * model);
192  /** Return address of status array (char[numberRows+numberColumns]) */
193  COINLIBAPI unsigned char *  COINLINKAGE Clp_statusArray(Clp_Simplex * model);
194  /** Copy in status vector */
195  COINLIBAPI void COINLINKAGE Clp_copyinStatus(Clp_Simplex * model, const unsigned char * statusArray);
196  /* status values are as in ClpSimplex.hpp i.e. 0 - free, 1 basic, 2 at upper,
197     3 at lower, 4 superbasic, (5 fixed) */
198  /* Get variable basis info */
199  COINLIBAPI const int COINLINKAGE Clp_getColumnStatus(Clp_Simplex * model,int sequence);
200  /* Get row basis info */
201  COINLIBAPI const int COINLINKAGE Clp_getRowStatus(Clp_Simplex * model,int sequence);
202  /* Set variable basis info (and value if at bound) */
203  COINLIBAPI void COINLINKAGE Clp_setColumnStatus(Clp_Simplex * model,
204                                                  int sequence, int value);
205  /* Set row basis info (and value if at bound) */
206  COINLIBAPI void COINLINKAGE Clp_setRowStatus(Clp_Simplex * model,
207                                               int sequence, int value);
208 
209  /** User pointer for whatever reason */
210  COINLIBAPI void COINLINKAGE Clp_setUserPointer (Clp_Simplex * model, void * pointer);
211  COINLIBAPI void * COINLINKAGE Clp_getUserPointer (Clp_Simplex * model);
212  /*@}*/
213  /**@name Message handling.  Call backs are handled by ONE function */
214  /*@{*/
215  /** Pass in Callback function.
216   Message numbers up to 1000000 are Clp, Coin ones have 1000000 added */
217  COINLIBAPI void COINLINKAGE Clp_registerCallBack(Clp_Simplex * model, 
218                                                   clp_callback userCallBack);
219  /** Unset Callback function */
220  COINLIBAPI void COINLINKAGE Clp_clearCallBack(Clp_Simplex * model);
221  /** Amount of print out:
222      0 - none
223      1 - just final
224      2 - just factorizations
225      3 - as 2 plus a bit more
226      4 - verbose
227      above that 8,16,32 etc just for selective debug
228  */
229  COINLIBAPI void COINLINKAGE Clp_setLogLevel(Clp_Simplex * model, int value);
230  COINLIBAPI int COINLINKAGE Clp_logLevel(Clp_Simplex * model);
231  /** length of names (0 means no names0 */
232  COINLIBAPI int COINLINKAGE Clp_lengthNames(Clp_Simplex * model);
233  /** Fill in array (at least lengthNames+1 long) with a row name */
234  COINLIBAPI void COINLINKAGE Clp_rowName(Clp_Simplex * model, int iRow, char * name);
235  /** Fill in array (at least lengthNames+1 long) with a column name */
236  COINLIBAPI void COINLINKAGE Clp_columnName(Clp_Simplex * model, int iColumn, char * name);
237
238  /*@}*/
239
240
241  /**@name Functions most useful to user */
242  /*@{*/
243  /** General solve algorithm which can do presolve.
244      See  ClpSolve.hpp for options
245   */
246  COINLIBAPI int COINLINKAGE Clp_initialSolve(Clp_Simplex * model);
247  /** Dual initial solve */
248  COINLIBAPI int COINLINKAGE Clp_initialDualSolve(Clp_Simplex * model);
249  /** Primal initial solve */
250  COINLIBAPI int COINLINKAGE Clp_initialPrimalSolve(Clp_Simplex * model);
251  /** Dual algorithm - see ClpSimplexDual.hpp for method */
252  COINLIBAPI int COINLINKAGE Clp_dual(Clp_Simplex * model, int ifValuesPass);
253  /** Primal algorithm - see ClpSimplexPrimal.hpp for method */
254  COINLIBAPI int COINLINKAGE Clp_primal(Clp_Simplex * model, int ifValuesPass);
255  /** Sets or unsets scaling, 0 -off, 1 equilibrium, 2 geometric, 3, auto, 4 dynamic(later) */
256  COINLIBAPI void COINLINKAGE Clp_scaling(Clp_Simplex * model, int mode);
257  /** Gets scalingFlag */
258  COINLIBAPI int COINLINKAGE Clp_scalingFlag(Clp_Simplex * model);
259  /** Crash - at present just aimed at dual, returns
260      -2 if dual preferred and crash basis created
261      -1 if dual preferred and all slack basis preferred
262       0 if basis going in was not all slack
263       1 if primal preferred and all slack basis preferred
264       2 if primal preferred and crash basis created.
265       
266       if gap between bounds <="gap" variables can be flipped
267
268       If "pivot" is
269       0 No pivoting (so will just be choice of algorithm)
270       1 Simple pivoting e.g. gub
271       2 Mini iterations
272  */
273  COINLIBAPI int COINLINKAGE Clp_crash(Clp_Simplex * model, double gap,int pivot);
274  /*@}*/
275
276
277  /**@name most useful gets and sets */
278  /*@{*/ 
279  /** If problem is primal feasible */
280  COINLIBAPI int COINLINKAGE Clp_primalFeasible(Clp_Simplex * model);
281  /** If problem is dual feasible */
282  COINLIBAPI int COINLINKAGE Clp_dualFeasible(Clp_Simplex * model);
283  /** Dual bound */
284  COINLIBAPI double COINLINKAGE Clp_dualBound(Clp_Simplex * model);
285  COINLIBAPI void COINLINKAGE Clp_setDualBound(Clp_Simplex * model, double value);
286  /** Infeasibility cost */
287  COINLIBAPI double COINLINKAGE Clp_infeasibilityCost(Clp_Simplex * model);
288  COINLIBAPI void COINLINKAGE Clp_setInfeasibilityCost(Clp_Simplex * model, double value);
289  /** Perturbation:
290      50  - switch on perturbation
291      100 - auto perturb if takes too long (1.0e-6 largest nonzero)
292      101 - we are perturbed
293      102 - don't try perturbing again
294      default is 100
295      others are for playing
296  */
297  COINLIBAPI int COINLINKAGE Clp_perturbation(Clp_Simplex * model);
298  COINLIBAPI void COINLINKAGE Clp_setPerturbation(Clp_Simplex * model, int value);
299  /** Current (or last) algorithm */
300  COINLIBAPI int COINLINKAGE Clp_algorithm(Clp_Simplex * model); 
301  /** Set algorithm */
302  COINLIBAPI void COINLINKAGE Clp_setAlgorithm(Clp_Simplex * model, int value);
303  /** Sum of dual infeasibilities */
304  COINLIBAPI double COINLINKAGE Clp_sumDualInfeasibilities(Clp_Simplex * model); 
305  /** Number of dual infeasibilities */
306  COINLIBAPI int COINLINKAGE Clp_numberDualInfeasibilities(Clp_Simplex * model); 
307  /** Sum of primal infeasibilities */
308  COINLIBAPI double COINLINKAGE Clp_sumPrimalInfeasibilities(Clp_Simplex * model); 
309  /** Number of primal infeasibilities */
310  COINLIBAPI int COINLINKAGE Clp_numberPrimalInfeasibilities(Clp_Simplex * model); 
311  /** Save model to file, returns 0 if success.  This is designed for
312      use outside algorithms so does not save iterating arrays etc.
313  It does not save any messaging information.
314  Does not save scaling values.
315  It does not know about all types of virtual functions.
316  */
317  COINLIBAPI int COINLINKAGE Clp_saveModel(Clp_Simplex * model, const char * fileName);
318  /** Restore model from file, returns 0 if success,
319      deletes current model */
320  COINLIBAPI int COINLINKAGE Clp_restoreModel(Clp_Simplex * model, const char * fileName);
321 
322  /** Just check solution (for external use) - sets sum of
323      infeasibilities etc */
324  COINLIBAPI void COINLINKAGE Clp_checkSolution(Clp_Simplex * model);
325  /*@}*/
326
327  /******************** End of most useful part **************/
328  /**@name gets and sets - some synonyms */
329  /*@{*/ 
330  /** Number of rows */
331  COINLIBAPI int COINLINKAGE Clp_getNumRows(Clp_Simplex * model);
332  /** Number of columns */
333  COINLIBAPI int COINLINKAGE Clp_getNumCols(Clp_Simplex * model);
334  /** Number of iterations */
335  COINLIBAPI int COINLINKAGE Clp_getIterationCount(Clp_Simplex * model);
336  /** Are there a numerical difficulties? */
337  COINLIBAPI int COINLINKAGE Clp_isAbandoned(Clp_Simplex * model);
338  /** Is optimality proven? */
339  COINLIBAPI int COINLINKAGE Clp_isProvenOptimal(Clp_Simplex * model);
340  /** Is primal infeasiblity proven? */
341  COINLIBAPI int COINLINKAGE Clp_isProvenPrimalInfeasible(Clp_Simplex * model);
342  /** Is dual infeasiblity proven? */
343  COINLIBAPI int COINLINKAGE Clp_isProvenDualInfeasible(Clp_Simplex * model);
344  /** Is the given primal objective limit reached? */
345  COINLIBAPI int COINLINKAGE Clp_isPrimalObjectiveLimitReached(Clp_Simplex * model) ;
346  /** Is the given dual objective limit reached? */
347  COINLIBAPI int COINLINKAGE Clp_isDualObjectiveLimitReached(Clp_Simplex * model) ;
348  /** Iteration limit reached? */
349  COINLIBAPI int COINLINKAGE Clp_isIterationLimitReached(Clp_Simplex * model);
350  /** Direction of optimization (1 - minimize, -1 - maximize, 0 - ignore */
351  COINLIBAPI double COINLINKAGE Clp_getObjSense(Clp_Simplex * model);
352  /** Primal row solution */
353  COINLIBAPI const double * COINLINKAGE Clp_getRowActivity(Clp_Simplex * model);
354  /** Primal column solution */
355  COINLIBAPI const double * COINLINKAGE Clp_getColSolution(Clp_Simplex * model);
356  COINLIBAPI void COINLINKAGE Clp_setColSolution(Clp_Simplex * model, const double * input);
357  /** Dual row solution */
358  COINLIBAPI const double * COINLINKAGE Clp_getRowPrice(Clp_Simplex * model);
359  /** Reduced costs */
360  COINLIBAPI const double * COINLINKAGE Clp_getReducedCost(Clp_Simplex * model);
361  /** Row lower */
362  COINLIBAPI const double* COINLINKAGE Clp_getRowLower(Clp_Simplex * model);
363  /** Row upper  */
364  COINLIBAPI const double* COINLINKAGE Clp_getRowUpper(Clp_Simplex * model);
365  /** Objective */
366  COINLIBAPI const double * COINLINKAGE Clp_getObjCoefficients(Clp_Simplex * model); 
367  /** Column Lower */
368  COINLIBAPI const double * COINLINKAGE Clp_getColLower(Clp_Simplex * model);
369  /** Column Upper */
370  COINLIBAPI const double * COINLINKAGE Clp_getColUpper(Clp_Simplex * model);
371  /** Objective value */
372  COINLIBAPI double COINLINKAGE Clp_getObjValue(Clp_Simplex * model);
373  /** Print model for debugging purposes */
374  COINLIBAPI void COINLINKAGE Clp_printModel(Clp_Simplex * model, const char * prefix);
375  /* Small element value - elements less than this set to zero,
376     default is 1.0e-20 */
377  COINLIBAPI double COINLINKAGE Clp_getSmallElementValue(Clp_Simplex * model);
378  COINLIBAPI void COINLINKAGE Clp_setSmallElementValue(Clp_Simplex * model,double value);
379  /*@}*/
380#ifdef __cplusplus
381          }
382#endif
383#endif
Note: See TracBrowser for help on using the repository browser.