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

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

SOS updates and test (not yet working)

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