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

Last change on this file since 1525 was 1525, checked in by mjs, 10 years ago

Formatted .cpp, .hpp, .c, .h files with "astyle -A4 -p". This matches the formatting used in the grand CBC reorganization.

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