source: trunk/Cbc/src/Cbc_C_Interface.h @ 2020

Last change on this file since 2020 was 2020, checked in by mlubin, 5 years ago

Allow passing arbitrary command-line parameters using the C interface

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 12.3 KB
Line 
1/* $Id: Cbc_C_Interface.h 2020 2014-03-13 18:09:41Z mlubin $ */
2/*
3  Copyright (C) 2004 International Business Machines Corporation and others.
4  All Rights Reserved.
5
6  This code is licensed under the terms of the Eclipse Public License (EPL).
7*/
8#ifndef CbcModelC_H
9#define CbcModelC_H
10
11/* include all defines and ugly stuff */
12#include "Coin_C_defines.h"
13
14/** This is a first "C" interface to Cbc.
15    It is mostly similar to the "C" interface to Clp and
16    was contributed by Bob Entriken.
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 Cbc_Model.
26
27       For all functions outside this group there is an exact C++
28       analogue created by taking the first parameter out, removing the Cbc_
29       from name and applying the method to an object of type ClpSimplex.
30    */
31    /*@{*/
32
33    /** Version */
34    COINLIBAPI double COINLINKAGE Cbc_getVersion()
35    ;
36    /** Default Cbc_Model constructor */
37    COINLIBAPI Cbc_Model * COINLINKAGE
38    Cbc_newModel()
39    ;
40    /** Cbc_Model Destructor */
41    COINLIBAPI void COINLINKAGE
42    Cbc_deleteModel(Cbc_Model * model)
43    ;
44    /*@}*/
45
46    /**@name Load model - loads some stuff and initializes others */
47    /*@{*/
48    /* Loads a problem (the constraints on the
49        rows are given by lower and upper bounds). If a pointer is NULL then the
50        following values are the default:
51        <ul>
52        <li> <code>colub</code>: all columns have upper bound infinity
53        <li> <code>collb</code>: all columns have lower bound 0
54        <li> <code>rowub</code>: all rows have upper bound infinity
55        <li> <code>rowlb</code>: all rows have lower bound -infinity
56        <li> <code>obj</code>: all variables have 0 objective coefficient
57        </ul>
58
59     Just like the other loadProblem() method except that the matrix is
60     given in a standard column major ordered format (without gaps).
61    */
62    COINLIBAPI void COINLINKAGE
63    Cbc_loadProblem (Cbc_Model * model,  const int numcols, const int numrows,
64                     const CoinBigIndex * start, const int* index,
65                     const double* value,
66                     const double* collb, const double* colub,
67                     const double* obj,
68                     const double* rowlb, const double* rowub)
69    ;
70    /** Read an mps file from the given filename */
71    COINLIBAPI int COINLINKAGE
72    Cbc_readMps(Cbc_Model * model, const char *filename)
73    ;
74    /** Write an mps file from the given filename */
75    COINLIBAPI void COINLINKAGE
76    Cbc_writeMps(Cbc_Model * model, const char *filename)
77    ;
78    /** Deletes rows */
79    COINLIBAPI void COINLINKAGE
80    Cbc_deleteRows(Cbc_Model * model, int number, const int * which)
81    ;
82    /** Add rows */
83    COINLIBAPI void COINLINKAGE
84    Cbc_addRows(Cbc_Model * model, const int number, const double * rowLower,
85                const double * rowUpper,
86                const int * rowStarts, const int * columns,
87                const double * elements)
88    ;
89
90    /** Deletes columns */
91    COINLIBAPI void COINLINKAGE
92    Cbc_deleteColumns(Cbc_Model * model, int number, const int * which)
93    ;
94    /** Add columns */
95    COINLIBAPI void COINLINKAGE
96    Cbc_addColumns(Cbc_Model * model, int number, const double * columnLower,
97                   const double * columnUpper,
98                   const double * objective,
99                   const int * columnStarts, const int * rows,
100                   const double * elements);
101    /** Drops names - makes lengthnames 0 and names empty */
102    COINLIBAPI void COINLINKAGE
103    Cbc_dropNames(Cbc_Model * model)
104    ;
105    /** Copies in names */
106    COINLIBAPI void COINLINKAGE
107    Cbc_copyNames(Cbc_Model * model, const char * const * rowNamesIn,
108                  const char * const * columnNamesIn)
109    ;
110
111    /*@}*/
112    /**@name gets and sets - you will find some synonyms at the end of this file */
113    /*@{*/
114    /** Set parameter "name" to value "value". Note that this
115     * translates directly to using "-name value" as a
116     * command-line argument to Cbc.*/
117    COINLIBAPI void COINLINKAGE
118    Cbc_setParameter(Cbc_Model * model, const char * name, const char * value)
119    ;
120    /** Fills in array with problem name  */
121    COINLIBAPI void COINLINKAGE
122    Cbc_problemName(Cbc_Model * model, int maxNumberCharacters, char * array)
123    ;
124    /** Sets problem name.
125   
126      \p array must be a null-terminated string.
127    */
128    COINLIBAPI int COINLINKAGE
129    Cbc_setProblemName(Cbc_Model * model, const char * array)
130    ;
131    /** Status of problem:
132        0 - optimal
133        1 - primal infeasible
134        2 - dual infeasible
135        3 - stopped on iterations etc
136        4 - stopped due to errors
137    */
138    COINLIBAPI int COINLINKAGE
139    Cbc_status(Cbc_Model * model)
140    ;
141    /** Secondary status of problem - may get extended
142        0 - none
143        1 - primal infeasible because dual limit reached
144        2 - scaled problem optimal - unscaled has primal infeasibilities
145        3 - scaled problem optimal - unscaled has dual infeasibilities
146        4 - scaled problem optimal - unscaled has both dual and primal infeasibilities
147    */
148    COINLIBAPI int COINLINKAGE
149    Cbc_secondaryStatus(Cbc_Model * model)
150    ;
151    COINLIBAPI void COINLINKAGE
152    Cbc_setSecondaryStatus(Cbc_Model * model, int status)
153    ;
154    /** Number of elements in matrix */
155    COINLIBAPI int COINLINKAGE
156    Cbc_getNumElements(Cbc_Model * model)
157    ;
158    /** Column starts in matrix */
159    COINLIBAPI const CoinBigIndex * COINLINKAGE
160    Cbc_getVectorStarts(Cbc_Model * model)
161    ;
162    /** Row indices in matrix */
163    COINLIBAPI const int * COINLINKAGE
164    Cbc_getIndices(Cbc_Model * model)
165    ;
166    /** Column vector lengths in matrix */
167    COINLIBAPI const int * COINLINKAGE
168    Cbc_getVectorLengths(Cbc_Model * model)
169    ;
170    /** Element values in matrix */
171    COINLIBAPI const double * COINLINKAGE
172    Cbc_getElements(Cbc_Model * model)
173    ;
174   
175    /*@}*/
176    /**@name Message handling.  Call backs are handled by ONE function */
177    /*@{*/
178    /** Pass in Callback function.
179     Message numbers up to 1000000 are Clp, Coin ones have 1000000 added */
180    COINLIBAPI void COINLINKAGE
181    Cbc_registerCallBack(Cbc_Model * model,
182                         cbc_callback userCallBack)
183    ;
184    /** Unset Callback function */
185    COINLIBAPI void COINLINKAGE
186    Cbc_clearCallBack(Cbc_Model * model)
187    ;
188    /** length of names (0 means no names0 */
189    COINLIBAPI int COINLINKAGE
190    Cbc_lengthNames(Cbc_Model * model)
191    ;
192    /** Fill in array (at least lengthNames+1 long) with a row name */
193    COINLIBAPI void COINLINKAGE
194    Cbc_rowName(Cbc_Model * model, int iRow, char * name)
195    ;
196    /** Fill in array (at least lengthNames+1 long) with a column name */
197    COINLIBAPI void COINLINKAGE
198    Cbc_columnName(Cbc_Model * model, int iColumn, char * name)
199    ;
200
201    /*@}*/
202
203
204    /**@name Functions most useful to user */
205    /*@{*/
206    /* Solve using CbcMain1. This is the recommended default solve function.
207    */
208    COINLIBAPI int COINLINKAGE
209    Cbc_solve(Cbc_Model * model)
210    ;
211    /*@}*/
212
213
214    /**@name most useful gets and sets */
215    /*@{*/
216    /** Sum of primal infeasibilities */
217    COINLIBAPI double COINLINKAGE
218    Cbc_sumPrimalInfeasibilities(Cbc_Model * model)
219    ;
220    /** Number of primal infeasibilities */
221    COINLIBAPI int COINLINKAGE
222    Cbc_numberPrimalInfeasibilities(Cbc_Model * model)
223    ;
224
225    /** Just check solution (for external use) - sets sum of
226        infeasibilities etc */
227    COINLIBAPI void COINLINKAGE
228    Cbc_checkSolution(Cbc_Model * model)
229    ;
230    /*@}*/
231
232    /******************** End of most useful part **************/
233    /**@name gets and sets - some synonyms */
234    /*@{*/
235    /** Number of rows */
236    COINLIBAPI int COINLINKAGE
237    Cbc_getNumRows(Cbc_Model * model)
238    ;
239    /** Number of columns */
240    COINLIBAPI int COINLINKAGE
241    Cbc_getNumCols(Cbc_Model * model)
242    ;
243    /** Number of iterations */
244    COINLIBAPI int COINLINKAGE
245    Cbc_getIterationCount(Cbc_Model * model)
246    ;
247    /** Are there a numerical difficulties? */
248    COINLIBAPI int COINLINKAGE
249    Cbc_isAbandoned(Cbc_Model * model)
250    ;
251    /** Is optimality proven? */
252    COINLIBAPI int COINLINKAGE
253    Cbc_isProvenOptimal(Cbc_Model * model)
254    ;
255    /** Is infeasiblity proven (or none better than cutoff)? */
256    COINLIBAPI int COINLINKAGE
257    Cbc_isProvenInfeasible(Cbc_Model * model)
258    ;
259    /** Was continuous solution unbounded? */
260    COINLIBAPI int COINLINKAGE
261    Cbc_isContinuousUnbounded(Cbc_Model * model)
262    ;
263    /** Node limit reached? */
264    COINLIBAPI int COINLINKAGE
265    Cbc_isNodeLimitReached(Cbc_Model * model)
266    ;
267    /** Time limit reached? */
268    COINLIBAPI int COINLINKAGE
269    Cbc_isSecondsLimitReached(Cbc_Model * model)
270    ;
271    /** Solution limit reached? */
272    COINLIBAPI int COINLINKAGE
273    Cbc_isSolutionLimitReached(Cbc_Model * model)
274    ;
275    /** Are there numerical difficulties (for initialSolve) ? */
276    COINLIBAPI int COINLINKAGE
277    Cbc_isInitialSolveAbandoned(Cbc_Model * model)
278    ;
279    /** Is optimality proven (for initialSolve) ? */
280    COINLIBAPI int COINLINKAGE
281    Cbc_isInitialSolveProvenOptimal(Cbc_Model * model)
282    ;
283    /** Is primal infeasiblity proven (for initialSolve) ? */
284    COINLIBAPI int COINLINKAGE
285    Cbc_isInitialSolveProvenPrimalInfeasible(Cbc_Model * model)
286    ;
287    /** Direction of optimization (1 - minimize, -1 - maximize, 0 - ignore) */
288    COINLIBAPI void COINLINKAGE
289    Cbc_setObjSense(Cbc_Model * model, double sense)
290    ;
291    /** Direction of optimization (1 - minimize, -1 - maximize, 0 - ignore) */
292    COINLIBAPI double COINLINKAGE
293    Cbc_getObjSense(Cbc_Model * model)
294    ;
295    /** Primal row solution
296     *  This is the vector A*x, where A is the constraint matrix
297     *  and x is the current solution. */
298    COINLIBAPI const double * COINLINKAGE
299    Cbc_getRowActivity(Cbc_Model * model)
300    ;
301    /** Primal column solution */
302    COINLIBAPI const double * COINLINKAGE
303    Cbc_getColSolution(Cbc_Model * model)
304    ;
305    COINLIBAPI void COINLINKAGE
306    Cbc_setColSolution(Cbc_Model * model, const double * input)
307    ;
308    /** Row lower */
309    COINLIBAPI const double* COINLINKAGE
310    Cbc_getRowLower(Cbc_Model * model)
311    ;
312    /** Row upper  */
313    COINLIBAPI const double* COINLINKAGE
314    Cbc_getRowUpper(Cbc_Model * model)
315    ;
316    /** Objective */
317    COINLIBAPI const double * COINLINKAGE
318    Cbc_getObjCoefficients(Cbc_Model * model)
319    ;
320    /** Column Lower */
321    COINLIBAPI const double * COINLINKAGE
322    Cbc_getColLower(Cbc_Model * model)
323    ;
324    /** Column Upper */
325    COINLIBAPI const double * COINLINKAGE
326    Cbc_getColUpper(Cbc_Model * model)
327    ;
328    /** Objective value */
329    COINLIBAPI double COINLINKAGE
330    Cbc_getObjValue(Cbc_Model * model)
331    ;
332    /** Print the model */
333    COINLIBAPI void COINLINKAGE
334    Cbc_printModel(Cbc_Model * model, const char * argPrefix)
335    ;
336    /** Determine whether the variable at location i is integer restricted */
337    COINLIBAPI int COINLINKAGE
338    Cbc_isInteger(Cbc_Model * model, int i)
339    ;
340    /** Return CPU time */
341    COINLIBAPI double COINLINKAGE
342    Cbc_cpuTime(Cbc_Model * model)
343    ;
344    /** Number of nodes explored in B&B tree */
345    COINLIBAPI int COINLINKAGE
346    Cbc_getNodeCount(Cbc_Model * model)
347    ;
348    /** Return a copy of this model */
349    COINLIBAPI Cbc_Model * COINLINKAGE
350    Cbc_clone(Cbc_Model * model)
351    ;
352    /** Set this the variable to be continuous */
353    COINLIBAPI Cbc_Model * COINLINKAGE
354    Cbc_setContinuous(Cbc_Model * model, int iColumn)
355    ;
356    /** Set this the variable to be integer */
357    COINLIBAPI Cbc_Model * COINLINKAGE
358    Cbc_setInteger(Cbc_Model * model, int iColumn)
359    ;
360    /** Add SOS constraints to the model using dense matrix */
361    COINLIBAPI void  COINLINKAGE
362    Cbc_addSOS_Dense(Cbc_Model * model, int numObjects, const int * len,
363                     const int * const * which, const double * weights, const int type)
364    ;
365    /** Add SOS constraints to the model using row-order matrix */
366    COINLIBAPI void  COINLINKAGE
367    Cbc_addSOS_Sparse(Cbc_Model * model, const int * rowStarts,
368                      const int * rowIndices, const double * weights, const int type)
369    ;
370    /** Delete all object information */
371    COINLIBAPI void  COINLINKAGE
372    Cbc_deleteObjects(Cbc_Model * model)
373    ;
374    /** Print the solution */
375    COINLIBAPI void  COINLINKAGE
376    Cbc_printSolution(Cbc_Model * model)
377    ;
378    /*@}*/
379#ifdef __cplusplus
380}
381#endif
382#endif
Note: See TracBrowser for help on using the repository browser.