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

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

improve return types of Cbc_setInteger and Cbc_setContinuous

  • 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 2038 2014-06-12 03:16:06Z 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#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    /** Provide an initial feasible solution to accelerate branch-and-bound */
89    COINLIBAPI void COINLINKAGE
90    Cbc_setInitialSolution(Cbc_Model *model, const double * sol)
91    ;
92    /** Fills in array with problem name  */
93    COINLIBAPI void COINLINKAGE
94    Cbc_problemName(Cbc_Model * model, int maxNumberCharacters, char * array)
95    ;
96    /** Sets problem name.
97   
98      \p array must be a null-terminated string.
99    */
100    COINLIBAPI int COINLINKAGE
101    Cbc_setProblemName(Cbc_Model * model, const char * array)
102    ;
103
104    /** Number of nonzero elements in constraint matrix */
105    COINLIBAPI int COINLINKAGE
106    Cbc_getNumElements(Cbc_Model * model)
107    ;
108    /** "Column start" vector of constraint matrix. Same format as Cbc_loadProblem() */
109    COINLIBAPI const CoinBigIndex * COINLINKAGE
110    Cbc_getVectorStarts(Cbc_Model * model)
111    ;
112    /** "Row index" vector of constraint matrix */
113    COINLIBAPI const int * COINLINKAGE
114    Cbc_getIndices(Cbc_Model * model)
115    ;
116    /** Coefficient vector of constraint matrix */
117    COINLIBAPI const double * COINLINKAGE
118    Cbc_getElements(Cbc_Model * model)
119    ;
120
121    /** Maximum lenght of a row or column name */
122    COINLIBAPI size_t COINLINKAGE
123    Cbc_maxNameLength(Cbc_Model * model)
124    ;
125    /** Fill in first maxLength bytes of name array with a row name */
126    COINLIBAPI void COINLINKAGE
127    Cbc_getRowName(Cbc_Model * model, int iRow, char * name, size_t maxLength)
128    ;
129    /** Fill in first maxLength bytes of name array with a column name */
130    COINLIBAPI void COINLINKAGE
131    Cbc_getColName(Cbc_Model * model, int iColumn, char * name, size_t maxLength)
132    ;
133    /** Set the name of a column */
134    COINLIBAPI void COINLINKAGE
135    Cbc_setColName(Cbc_Model * model, int iColumn, const char * name)
136    ;
137    /** Set the name of a row */
138    COINLIBAPI void COINLINKAGE
139    Cbc_setRowName(Cbc_Model * model, int iRow, const char * name)
140    ;
141    /** Number of constraints in the model */
142    COINLIBAPI int COINLINKAGE
143    Cbc_getNumRows(Cbc_Model * model)
144    ;
145    /** Number of variables in the model */
146    COINLIBAPI int COINLINKAGE
147    Cbc_getNumCols(Cbc_Model * model)
148    ;
149    /** Direction of optimization (1 - minimize, -1 - maximize, 0 - ignore) */
150    COINLIBAPI void COINLINKAGE
151    Cbc_setObjSense(Cbc_Model * model, double sense)
152    ;
153    /** Direction of optimization (1 - minimize, -1 - maximize, 0 - ignore) */
154    COINLIBAPI double COINLINKAGE
155    Cbc_getObjSense(Cbc_Model * model)
156    ;
157    /** Constraint lower bounds */
158    COINLIBAPI const double* COINLINKAGE
159    Cbc_getRowLower(Cbc_Model * model)
160    ;
161    /** Set the lower bound of a single constraint */
162    COINLIBAPI void COINLINKAGE
163    Cbc_setRowLower(Cbc_Model * model, int index, double value)
164    ;
165    /** Constraint upper bounds */
166    COINLIBAPI const double* COINLINKAGE
167    Cbc_getRowUpper(Cbc_Model * model)
168    ;
169    /** Set the upper bound of a single constraint */
170    COINLIBAPI void COINLINKAGE
171    Cbc_setRowUpper(Cbc_Model * model, int index, double value)
172    ;
173    /** Objective vector */
174    COINLIBAPI const double * COINLINKAGE
175    Cbc_getObjCoefficients(Cbc_Model * model)
176    ;
177    /** Set the objective coefficient of a single variable */
178    COINLIBAPI void COINLINKAGE
179    Cbc_setObjCoeff(Cbc_Model * model, int index, double value)
180    ;
181    /** Variable lower bounds */
182    COINLIBAPI const double * COINLINKAGE
183    Cbc_getColLower(Cbc_Model * model)
184    ;
185    /** Set the lower bound of a single variable */
186    COINLIBAPI void COINLINKAGE
187    Cbc_setColLower(Cbc_Model * model, int index, double value)
188    ;
189    /** Variable upper bounds */
190    COINLIBAPI const double * COINLINKAGE
191    Cbc_getColUpper(Cbc_Model * model)
192    ;
193    /** Set the upper bound of a single variable */
194    COINLIBAPI void COINLINKAGE
195    Cbc_setColUpper(Cbc_Model * model, int index, double value)
196    ;
197    /** Determine whether the ith variable is integer restricted */
198    COINLIBAPI int COINLINKAGE
199    Cbc_isInteger(Cbc_Model * model, int i)
200    ;
201    /** Set this variable to be continuous */
202    COINLIBAPI void COINLINKAGE
203    Cbc_setContinuous(Cbc_Model * model, int iColumn)
204    ;
205    /** Set this variable to be integer */
206    COINLIBAPI void COINLINKAGE
207    Cbc_setInteger(Cbc_Model * model, int iColumn)
208    ;
209    /* Add SOS constraints to the model using row-order matrix
210     * Unable to confirm that this function is working. */
211    /*COINLIBAPI void  COINLINKAGE
212    Cbc_addSOS(Cbc_Model * model, int numRows, const int * rowStarts,
213               const int * colIndices, const double * weights, const int type)
214    ;*/
215    /** Print the model */
216    COINLIBAPI void COINLINKAGE
217    Cbc_printModel(Cbc_Model * model, const char * argPrefix)
218    ;
219    /** Return a copy of this model */
220    COINLIBAPI Cbc_Model * COINLINKAGE
221    Cbc_clone(Cbc_Model * model)
222    ;
223    /*@}*/
224    /**@name Solver parameters */
225    /*@{*/
226    /** Set parameter "name" to value "value". Note that this
227     * translates directly to using "-name value" as a
228     * command-line argument to Cbc.*/
229    COINLIBAPI void COINLINKAGE
230    Cbc_setParameter(Cbc_Model * model, const char * name, const char * value)
231    ;
232
233   
234    /*@}*/
235    /**@name Message handling.  Call backs are handled by ONE function */
236    /*@{*/
237    /** Pass in Callback function.
238     Message numbers up to 1000000 are Clp, Coin ones have 1000000 added */
239    COINLIBAPI void COINLINKAGE
240    Cbc_registerCallBack(Cbc_Model * model,
241                         cbc_callback userCallBack)
242    ;
243    /** Unset Callback function */
244    COINLIBAPI void COINLINKAGE
245    Cbc_clearCallBack(Cbc_Model * model)
246    ;
247
248    /*@}*/
249
250
251    /**@name Solving the model */
252    /*@{*/
253    /* Solve the model with Cbc (using CbcMain1).
254    */
255    COINLIBAPI int COINLINKAGE
256    Cbc_solve(Cbc_Model * model)
257    ;
258    /*@}*/
259
260
261    /**@name Accessing the solution and solution status */
262    /*@{*/
263
264    /** Sum of primal infeasibilities */
265    COINLIBAPI double COINLINKAGE
266    Cbc_sumPrimalInfeasibilities(Cbc_Model * model)
267    ;
268    /** Number of primal infeasibilities */
269    COINLIBAPI int COINLINKAGE
270    Cbc_numberPrimalInfeasibilities(Cbc_Model * model)
271    ;
272
273    /** Just check solution (for external use) - sets sum of
274        infeasibilities etc */
275    COINLIBAPI void COINLINKAGE
276    Cbc_checkSolution(Cbc_Model * model)
277    ;
278
279    /** Number of iterations */
280    COINLIBAPI int COINLINKAGE
281    Cbc_getIterationCount(Cbc_Model * model)
282    ;
283    /** Are there a numerical difficulties? */
284    COINLIBAPI int COINLINKAGE
285    Cbc_isAbandoned(Cbc_Model * model)
286    ;
287    /** Is optimality proven? */
288    COINLIBAPI int COINLINKAGE
289    Cbc_isProvenOptimal(Cbc_Model * model)
290    ;
291    /** Is infeasiblity proven (or none better than cutoff)? */
292    COINLIBAPI int COINLINKAGE
293    Cbc_isProvenInfeasible(Cbc_Model * model)
294    ;
295    /** Was continuous solution unbounded? */
296    COINLIBAPI int COINLINKAGE
297    Cbc_isContinuousUnbounded(Cbc_Model * model)
298    ;
299    /** Node limit reached? */
300    COINLIBAPI int COINLINKAGE
301    Cbc_isNodeLimitReached(Cbc_Model * model)
302    ;
303    /** Time limit reached? */
304    COINLIBAPI int COINLINKAGE
305    Cbc_isSecondsLimitReached(Cbc_Model * model)
306    ;
307    /** Solution limit reached? */
308    COINLIBAPI int COINLINKAGE
309    Cbc_isSolutionLimitReached(Cbc_Model * model)
310    ;
311    /** Are there numerical difficulties (for initialSolve) ? */
312    COINLIBAPI int COINLINKAGE
313    Cbc_isInitialSolveAbandoned(Cbc_Model * model)
314    ;
315    /** Is optimality proven (for initialSolve) ? */
316    COINLIBAPI int COINLINKAGE
317    Cbc_isInitialSolveProvenOptimal(Cbc_Model * model)
318    ;
319    /** Is primal infeasiblity proven (for initialSolve) ? */
320    COINLIBAPI int COINLINKAGE
321    Cbc_isInitialSolveProvenPrimalInfeasible(Cbc_Model * model)
322    ;
323    /** "row" solution
324     *  This is the vector A*x, where A is the constraint matrix
325     *  and x is the current solution. */
326    COINLIBAPI const double * COINLINKAGE
327    Cbc_getRowActivity(Cbc_Model * model)
328    ;
329    /** Best feasible solution vector */
330    COINLIBAPI const double * COINLINKAGE
331    Cbc_getColSolution(Cbc_Model * model)
332    ;
333    /** Objective value of best feasible solution */
334    COINLIBAPI double COINLINKAGE
335    Cbc_getObjValue(Cbc_Model * model)
336    ;
337    /** Best known bound on the optimal objective value */
338    COINLIBAPI double COINLINKAGE
339    Cbc_getBestPossibleObjValue(Cbc_Model * model)
340    ;
341    /** Number of nodes explored in B&B tree */
342    COINLIBAPI int COINLINKAGE
343    Cbc_getNodeCount(Cbc_Model * model)
344    ;
345    /** Print the solution */
346    COINLIBAPI void  COINLINKAGE
347    Cbc_printSolution(Cbc_Model * model)
348    ;
349    /** Final status of problem
350        Some of these can be found out by is...... functions
351        -1 before branchAndBound
352        0 finished - check isProvenOptimal or isProvenInfeasible to see if solution found
353        (or check value of best solution)
354        1 stopped - on maxnodes, maxsols, maxtime
355        2 difficulties so run was abandoned
356        (5 event user programmed event occurred)
357    */
358    COINLIBAPI int COINLINKAGE
359    Cbc_status(Cbc_Model * model)
360    ;
361    /** Secondary status of problem
362        -1 unset (status_ will also be -1)
363        0 search completed with solution
364        1 linear relaxation not feasible (or worse than cutoff)
365        2 stopped on gap
366        3 stopped on nodes
367        4 stopped on time
368        5 stopped on user event
369        6 stopped on solutions
370        7 linear relaxation unbounded
371        8 stopped on iteration limit
372    */
373    COINLIBAPI int COINLINKAGE
374    Cbc_secondaryStatus(Cbc_Model * model)
375    ;
376    /*@}*/
377#ifdef __cplusplus
378}
379#endif
380#endif
Note: See TracBrowser for help on using the repository browser.