source: branches/ClpForOsi2/Clp/src/Clp_C_Interface.h @ 1759

Last change on this file since 1759 was 1759, checked in by lou, 9 years ago

Add a Clp_model routine to return the underlying ClpSimplex? object.

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