source: branches/BSP/trunk/Clp/src/Clp_C_Interface.h @ 1079

Last change on this file since 1079 was 1079, checked in by stefan, 12 years ago

avoid warning that const-qualifier will be ignored in return argument by taking const-qualifier out

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