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

Last change on this file since 2424 was 2424, checked in by unxusr, 2 years ago

more functions to the C API

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 12.8 KB
Line 
1/* $Id: Cbc_C_Interface.h 2424 2018-11-17 15:29:59Z unxusr $ */
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#include <stddef.h>
14
15/*
16 * Original verison contributed by Bob Entriken,
17 * significantly updated by Miles Lubin.
18*/
19
20
21#ifdef __cplusplus
22extern "C" {
23#endif
24
25    /**@name Constructors and destructor
26      This is a "C" interface to Cbc.
27      The user does not need to know structure of Cbc_Model.
28    */
29    /*@{*/
30
31    /** Default Cbc_Model constructor */
32    COINLIBAPI Cbc_Model * COINLINKAGE
33    Cbc_newModel(void)
34    ;
35    /** Cbc_Model Destructor */
36    COINLIBAPI void COINLINKAGE
37    Cbc_deleteModel(Cbc_Model * model)
38    ;
39    /** Current version of Cbc */
40    COINLIBAPI const char* COINLINKAGE Cbc_getVersion(void)
41    ;
42    /*@}*/
43
44    /**@name Getting and setting model data
45     Note that problem access and modification methods,
46       such as getColLower and setColLower,
47       are *not valid* after calling Cbc_solve().
48       Therefore it is not recommended to reuse a Cbc_Model
49       object for multiple solves. A workaround is to call Cbc_clone()
50       before solving.
51     * */
52    /*@{*/
53    /** Loads a problem (the constraints on the
54        rows are given by lower and upper bounds). If a pointer is NULL then the
55        following values are the default:
56        <ul>
57        <li> <code>colub</code>: all columns have upper bound infinity
58        <li> <code>collb</code>: all columns have lower bound 0
59        <li> <code>rowub</code>: all rows have upper bound infinity
60        <li> <code>rowlb</code>: all rows have lower bound -infinity
61        <li> <code>obj</code>: all variables have 0 objective coefficient
62        </ul>
63
64     The constraint matrix is
65     given in standard compressed sparse column (without gaps).
66     <ul>
67     <li> <code>start[i]</code> stores the starting index of the ith column
68     <li> <code>index[k]</code> stores the row index of the kth nonzero element
69     <li> <code>value[k]</code> stores the coefficient of the kth nonzero element
70     </ul>
71    */
72    COINLIBAPI void COINLINKAGE
73    Cbc_loadProblem (Cbc_Model * model,  const int numcols, const int numrows,
74                     const CoinBigIndex * start, const int* index,
75                     const double* value,
76                     const double* collb, const double* colub,
77                     const double* obj,
78                     const double* rowlb, const double* rowub)
79    ;
80    /** Read an mps file from the given filename */
81    COINLIBAPI int COINLINKAGE
82    Cbc_readMps(Cbc_Model * model, const char *filename)
83    ;
84    /** Write an mps file from the given filename */
85    COINLIBAPI void COINLINKAGE
86    Cbc_writeMps(Cbc_Model * model, const char *filename)
87    ;
88    /** Read an lp file from the given filename */
89    COINLIBAPI int COINLINKAGE
90    Cbc_readLp(Cbc_Model * model, const char *filename)
91    ;
92    /** Provide an initial feasible solution to accelerate branch-and-bound
93     Note that feasibility of the solution is *not* verified.
94    */
95    COINLIBAPI void COINLINKAGE
96    Cbc_setInitialSolution(Cbc_Model *model, const double * sol)
97    ;
98    /** Fills in array with problem name  */
99    COINLIBAPI void COINLINKAGE
100    Cbc_problemName(Cbc_Model * model, int maxNumberCharacters, char * array)
101    ;
102    /** Sets problem name.
103   
104      \p array must be a null-terminated string.
105    */
106    COINLIBAPI int COINLINKAGE
107    Cbc_setProblemName(Cbc_Model * model, const char * array)
108    ;
109
110    /** Number of nonzero elements in constraint matrix */
111    COINLIBAPI int COINLINKAGE
112    Cbc_getNumElements(Cbc_Model * model)
113    ;
114    /** "Column start" vector of constraint matrix. Same format as Cbc_loadProblem() */
115    COINLIBAPI const CoinBigIndex * COINLINKAGE
116    Cbc_getVectorStarts(Cbc_Model * model)
117    ;
118    /** "Row index" vector of constraint matrix */
119    COINLIBAPI const int * COINLINKAGE
120    Cbc_getIndices(Cbc_Model * model)
121    ;
122    /** Coefficient vector of constraint matrix */
123    COINLIBAPI const double * COINLINKAGE
124    Cbc_getElements(Cbc_Model * model)
125    ;
126
127    /** Maximum lenght of a row or column name */
128    COINLIBAPI size_t COINLINKAGE
129    Cbc_maxNameLength(Cbc_Model * model)
130    ;
131    /** Fill in first maxLength bytes of name array with a row name */
132    COINLIBAPI void COINLINKAGE
133    Cbc_getRowName(Cbc_Model * model, int iRow, char * name, size_t maxLength)
134    ;
135    /** Fill in first maxLength bytes of name array with a column name */
136    COINLIBAPI void COINLINKAGE
137    Cbc_getColName(Cbc_Model * model, int iColumn, char * name, size_t maxLength)
138    ;
139    /** Set the name of a column */
140    COINLIBAPI void COINLINKAGE
141    Cbc_setColName(Cbc_Model * model, int iColumn, const char * name)
142    ;
143    /** Set the name of a row */
144    COINLIBAPI void COINLINKAGE
145    Cbc_setRowName(Cbc_Model * model, int iRow, const char * name)
146    ;
147    /** Number of constraints in the model */
148    COINLIBAPI int COINLINKAGE
149    Cbc_getNumRows(Cbc_Model * model)
150    ;
151    /** Number of variables in the model */
152    COINLIBAPI int COINLINKAGE
153    Cbc_getNumCols(Cbc_Model * model)
154    ;
155    /** Direction of optimization (1 - minimize, -1 - maximize, 0 - ignore) */
156    COINLIBAPI void COINLINKAGE
157    Cbc_setObjSense(Cbc_Model * model, double sense)
158    ;
159    /** Direction of optimization (1 - minimize, -1 - maximize, 0 - ignore) */
160    COINLIBAPI double COINLINKAGE
161    Cbc_getObjSense(Cbc_Model * model)
162    ;
163    /** Constraint lower bounds */
164    COINLIBAPI const double* COINLINKAGE
165    Cbc_getRowLower(Cbc_Model * model)
166    ;
167    /** Set the lower bound of a single constraint */
168    COINLIBAPI void COINLINKAGE
169    Cbc_setRowLower(Cbc_Model * model, int index, double value)
170    ;
171    /** Constraint upper bounds */
172    COINLIBAPI const double* COINLINKAGE
173    Cbc_getRowUpper(Cbc_Model * model)
174    ;
175    /** Set the upper bound of a single constraint */
176    COINLIBAPI void COINLINKAGE
177    Cbc_setRowUpper(Cbc_Model * model, int index, double value)
178    ;
179    /** Objective vector */
180    COINLIBAPI const double * COINLINKAGE
181    Cbc_getObjCoefficients(Cbc_Model * model)
182    ;
183    /** Set the objective coefficient of a single variable */
184    COINLIBAPI void COINLINKAGE
185    Cbc_setObjCoeff(Cbc_Model * model, int index, double value)
186    ;
187    /** Variable lower bounds */
188    COINLIBAPI const double * COINLINKAGE
189    Cbc_getColLower(Cbc_Model * model)
190    ;
191    /** Set the lower bound of a single variable */
192    COINLIBAPI void COINLINKAGE
193    Cbc_setColLower(Cbc_Model * model, int index, double value)
194    ;
195    /** Variable upper bounds */
196    COINLIBAPI const double * COINLINKAGE
197    Cbc_getColUpper(Cbc_Model * model)
198    ;
199    /** Set the upper bound of a single variable */
200    COINLIBAPI void COINLINKAGE
201    Cbc_setColUpper(Cbc_Model * model, int index, double value)
202    ;
203    /** Determine whether the ith variable is integer restricted */
204    COINLIBAPI int COINLINKAGE
205    Cbc_isInteger(Cbc_Model * model, int i)
206    ;
207    /** Set this variable to be continuous */
208    COINLIBAPI void COINLINKAGE
209    Cbc_setContinuous(Cbc_Model * model, int iColumn)
210    ;
211    /** Set this variable to be integer */
212    COINLIBAPI void COINLINKAGE
213    Cbc_setInteger(Cbc_Model * model, int iColumn)
214    ;
215    /** Adds a new column */
216    COINLIBAPI void COINLINKAGE
217    Cbc_addCol( Cbc_Model *model, const char *name, double lb, 
218            double ub, double obj, bool isInteger)
219    ;
220    /** Adds a new row */
221    COINLIBAPI void COINLINKAGE
222    Cbc_addRow( Cbc_Model *model, const char *name, int nz,
223            const int *cols, const double *coefs, char sense, double rhs )
224    ;
225    /** Add SOS constraints to the model using row-order matrix */
226    COINLIBAPI void  COINLINKAGE
227    Cbc_addSOS(Cbc_Model * model, int numRows, const int * rowStarts,
228               const int * colIndices, const double * weights, const int type)
229    ;
230    /** Print the model */
231    COINLIBAPI void COINLINKAGE
232    Cbc_printModel(Cbc_Model * model, const char * argPrefix)
233    ;
234    /** Return a copy of this model */
235    COINLIBAPI Cbc_Model * COINLINKAGE
236    Cbc_clone(Cbc_Model * model)
237    ;
238    /*@}*/
239    /**@name Solver parameters */
240    /*@{*/
241    /** Set parameter "name" to value "value". Note that this
242     * translates directly to using "-name value" as a
243     * command-line argument to Cbc.*/
244    COINLIBAPI void COINLINKAGE
245    Cbc_setParameter(Cbc_Model * model, const char * name, const char * value)
246    ;
247
248   
249    /*@}*/
250    /**@name Message handling.  Call backs are handled by ONE function */
251    /*@{*/
252    /** Pass in Callback function.
253     Message numbers up to 1000000 are Clp, Coin ones have 1000000 added */
254    COINLIBAPI void COINLINKAGE
255    Cbc_registerCallBack(Cbc_Model * model,
256                         cbc_callback userCallBack)
257    ;
258    /** Unset Callback function */
259    COINLIBAPI void COINLINKAGE
260    Cbc_clearCallBack(Cbc_Model * model)
261    ;
262
263    /*@}*/
264
265
266    /**@name Solving the model */
267    /*@{*/
268    /* Solve the model with Cbc (using CbcMain1).
269    */
270    COINLIBAPI int COINLINKAGE
271    Cbc_solve(Cbc_Model * model)
272    ;
273    /*@}*/
274
275
276    /**@name Accessing the solution and solution status */
277    /*@{*/
278
279    /** Sum of primal infeasibilities */
280    COINLIBAPI double COINLINKAGE
281    Cbc_sumPrimalInfeasibilities(Cbc_Model * model)
282    ;
283    /** Number of primal infeasibilities */
284    COINLIBAPI int COINLINKAGE
285    Cbc_numberPrimalInfeasibilities(Cbc_Model * model)
286    ;
287
288    /** Just check solution (for external use) - sets sum of
289        infeasibilities etc */
290    COINLIBAPI void COINLINKAGE
291    Cbc_checkSolution(Cbc_Model * model)
292    ;
293
294    /** Number of iterations */
295    COINLIBAPI int COINLINKAGE
296    Cbc_getIterationCount(Cbc_Model * model)
297    ;
298    /** Are there a numerical difficulties? */
299    COINLIBAPI int COINLINKAGE
300    Cbc_isAbandoned(Cbc_Model * model)
301    ;
302    /** Is optimality proven? */
303    COINLIBAPI int COINLINKAGE
304    Cbc_isProvenOptimal(Cbc_Model * model)
305    ;
306    /** Is infeasiblity proven (or none better than cutoff)? */
307    COINLIBAPI int COINLINKAGE
308    Cbc_isProvenInfeasible(Cbc_Model * model)
309    ;
310    /** Was continuous solution unbounded? */
311    COINLIBAPI int COINLINKAGE
312    Cbc_isContinuousUnbounded(Cbc_Model * model)
313    ;
314    /** Node limit reached? */
315    COINLIBAPI int COINLINKAGE
316    Cbc_isNodeLimitReached(Cbc_Model * model)
317    ;
318    /** Time limit reached? */
319    COINLIBAPI int COINLINKAGE
320    Cbc_isSecondsLimitReached(Cbc_Model * model)
321    ;
322    /** Solution limit reached? */
323    COINLIBAPI int COINLINKAGE
324    Cbc_isSolutionLimitReached(Cbc_Model * model)
325    ;
326    /** Are there numerical difficulties (for initialSolve) ? */
327    COINLIBAPI int COINLINKAGE
328    Cbc_isInitialSolveAbandoned(Cbc_Model * model)
329    ;
330    /** Is optimality proven (for initialSolve) ? */
331    COINLIBAPI int COINLINKAGE
332    Cbc_isInitialSolveProvenOptimal(Cbc_Model * model)
333    ;
334    /** Is primal infeasiblity proven (for initialSolve) ? */
335    COINLIBAPI int COINLINKAGE
336    Cbc_isInitialSolveProvenPrimalInfeasible(Cbc_Model * model)
337    ;
338    /** "row" solution
339     *  This is the vector A*x, where A is the constraint matrix
340     *  and x is the current solution. */
341    COINLIBAPI const double * COINLINKAGE
342    Cbc_getRowActivity(Cbc_Model * model)
343    ;
344    /** Best feasible solution vector */
345    COINLIBAPI const double * COINLINKAGE
346    Cbc_getColSolution(Cbc_Model * model)
347    ;
348    /** Objective value of best feasible solution */
349    COINLIBAPI double COINLINKAGE
350    Cbc_getObjValue(Cbc_Model * model)
351    ;
352    /** Best known bound on the optimal objective value */
353    COINLIBAPI double COINLINKAGE
354    Cbc_getBestPossibleObjValue(Cbc_Model * model)
355    ;
356    /** Number of nodes explored in B&B tree */
357    COINLIBAPI int COINLINKAGE
358    Cbc_getNodeCount(Cbc_Model * model)
359    ;
360    /** Print the solution */
361    COINLIBAPI void  COINLINKAGE
362    Cbc_printSolution(Cbc_Model * model)
363    ;
364    /** Final status of problem
365        Some of these can be found out by is...... functions
366        -1 before branchAndBound
367        0 finished - check isProvenOptimal or isProvenInfeasible to see if solution found
368        (or check value of best solution)
369        1 stopped - on maxnodes, maxsols, maxtime
370        2 difficulties so run was abandoned
371        (5 event user programmed event occurred)
372    */
373    COINLIBAPI int COINLINKAGE
374    Cbc_status(Cbc_Model * model)
375    ;
376    /** Secondary status of problem
377        -1 unset (status_ will also be -1)
378        0 search completed with solution
379        1 linear relaxation not feasible (or worse than cutoff)
380        2 stopped on gap
381        3 stopped on nodes
382        4 stopped on time
383        5 stopped on user event
384        6 stopped on solutions
385        7 linear relaxation unbounded
386        8 stopped on iteration limit
387    */
388    COINLIBAPI int COINLINKAGE
389    Cbc_secondaryStatus(Cbc_Model * model)
390    ;
391    /*@}*/
392#ifdef __cplusplus
393}
394#endif
395#endif
Note: See TracBrowser for help on using the repository browser.