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

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

Implement Cbc_setInitialSolution for providing a feasible solution.

  • 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 2032 2014-05-08 04:11:17Z 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 dense matrix */
204    COINLIBAPI void  COINLINKAGE
205    Cbc_addSOS_Dense(Cbc_Model * model, int numObjects, const int * len,
206                     const int * const * which, const double * weights, const int type)
207    ;
208    /** Add SOS constraints to the model using row-order matrix */
209    COINLIBAPI void  COINLINKAGE
210    Cbc_addSOS_Sparse(Cbc_Model * model, const int * rowStarts,
211                      const int * rowIndices, const double * weights, const int type)
212    ;
213    /** Print the model */
214    COINLIBAPI void COINLINKAGE
215    Cbc_printModel(Cbc_Model * model, const char * argPrefix)
216    ;
217    /** Return a copy of this model */
218    COINLIBAPI Cbc_Model * COINLINKAGE
219    Cbc_clone(Cbc_Model * model)
220    ;
221    /*@}*/
222    /**@name Solver parameters */
223    /*@{*/
224    /** Set parameter "name" to value "value". Note that this
225     * translates directly to using "-name value" as a
226     * command-line argument to Cbc.*/
227    COINLIBAPI void COINLINKAGE
228    Cbc_setParameter(Cbc_Model * model, const char * name, const char * value)
229    ;
230
231   
232    /*@}*/
233    /**@name Message handling.  Call backs are handled by ONE function */
234    /*@{*/
235    /** Pass in Callback function.
236     Message numbers up to 1000000 are Clp, Coin ones have 1000000 added */
237    COINLIBAPI void COINLINKAGE
238    Cbc_registerCallBack(Cbc_Model * model,
239                         cbc_callback userCallBack)
240    ;
241    /** Unset Callback function */
242    COINLIBAPI void COINLINKAGE
243    Cbc_clearCallBack(Cbc_Model * model)
244    ;
245
246    /*@}*/
247
248
249    /**@name Solving the model */
250    /*@{*/
251    /* Solve the model with Cbc (using CbcMain1).
252    */
253    COINLIBAPI int COINLINKAGE
254    Cbc_solve(Cbc_Model * model)
255    ;
256    /*@}*/
257
258
259    /**@name Accessing the solution and solution status */
260    /*@{*/
261
262    /** Sum of primal infeasibilities */
263    COINLIBAPI double COINLINKAGE
264    Cbc_sumPrimalInfeasibilities(Cbc_Model * model)
265    ;
266    /** Number of primal infeasibilities */
267    COINLIBAPI int COINLINKAGE
268    Cbc_numberPrimalInfeasibilities(Cbc_Model * model)
269    ;
270
271    /** Just check solution (for external use) - sets sum of
272        infeasibilities etc */
273    COINLIBAPI void COINLINKAGE
274    Cbc_checkSolution(Cbc_Model * model)
275    ;
276
277    /** Number of iterations */
278    COINLIBAPI int COINLINKAGE
279    Cbc_getIterationCount(Cbc_Model * model)
280    ;
281    /** Are there a numerical difficulties? */
282    COINLIBAPI int COINLINKAGE
283    Cbc_isAbandoned(Cbc_Model * model)
284    ;
285    /** Is optimality proven? */
286    COINLIBAPI int COINLINKAGE
287    Cbc_isProvenOptimal(Cbc_Model * model)
288    ;
289    /** Is infeasiblity proven (or none better than cutoff)? */
290    COINLIBAPI int COINLINKAGE
291    Cbc_isProvenInfeasible(Cbc_Model * model)
292    ;
293    /** Was continuous solution unbounded? */
294    COINLIBAPI int COINLINKAGE
295    Cbc_isContinuousUnbounded(Cbc_Model * model)
296    ;
297    /** Node limit reached? */
298    COINLIBAPI int COINLINKAGE
299    Cbc_isNodeLimitReached(Cbc_Model * model)
300    ;
301    /** Time limit reached? */
302    COINLIBAPI int COINLINKAGE
303    Cbc_isSecondsLimitReached(Cbc_Model * model)
304    ;
305    /** Solution limit reached? */
306    COINLIBAPI int COINLINKAGE
307    Cbc_isSolutionLimitReached(Cbc_Model * model)
308    ;
309    /** Are there numerical difficulties (for initialSolve) ? */
310    COINLIBAPI int COINLINKAGE
311    Cbc_isInitialSolveAbandoned(Cbc_Model * model)
312    ;
313    /** Is optimality proven (for initialSolve) ? */
314    COINLIBAPI int COINLINKAGE
315    Cbc_isInitialSolveProvenOptimal(Cbc_Model * model)
316    ;
317    /** Is primal infeasiblity proven (for initialSolve) ? */
318    COINLIBAPI int COINLINKAGE
319    Cbc_isInitialSolveProvenPrimalInfeasible(Cbc_Model * model)
320    ;
321    /** "row" solution
322     *  This is the vector A*x, where A is the constraint matrix
323     *  and x is the current solution. */
324    COINLIBAPI const double * COINLINKAGE
325    Cbc_getRowActivity(Cbc_Model * model)
326    ;
327    /** Best feasible solution vector */
328    COINLIBAPI const double * COINLINKAGE
329    Cbc_getColSolution(Cbc_Model * model)
330    ;
331    /** Objective value of best feasible solution */
332    COINLIBAPI double COINLINKAGE
333    Cbc_getObjValue(Cbc_Model * model)
334    ;
335    /** Best known bound on the optimal objective value */
336    COINLIBAPI double COINLINKAGE
337    Cbc_getBestPossibleObjValue(Cbc_Model * model)
338    ;
339    /** Number of nodes explored in B&B tree */
340    COINLIBAPI int COINLINKAGE
341    Cbc_getNodeCount(Cbc_Model * model)
342    ;
343    /** Print the solution */
344    COINLIBAPI void  COINLINKAGE
345    Cbc_printSolution(Cbc_Model * model)
346    ;
347    /** Final status of problem
348        Some of these can be found out by is...... functions
349        -1 before branchAndBound
350        0 finished - check isProvenOptimal or isProvenInfeasible to see if solution found
351        (or check value of best solution)
352        1 stopped - on maxnodes, maxsols, maxtime
353        2 difficulties so run was abandoned
354        (5 event user programmed event occurred)
355    */
356    COINLIBAPI int COINLINKAGE
357    Cbc_status(Cbc_Model * model)
358    ;
359    /** Secondary status of problem
360        -1 unset (status_ will also be -1)
361        0 search completed with solution
362        1 linear relaxation not feasible (or worse than cutoff)
363        2 stopped on gap
364        3 stopped on nodes
365        4 stopped on time
366        5 stopped on user event
367        6 stopped on solutions
368        7 linear relaxation unbounded
369        8 stopped on iteration limit
370    */
371    COINLIBAPI int COINLINKAGE
372    Cbc_secondaryStatus(Cbc_Model * model)
373    ;
374    /*@}*/
375#ifdef __cplusplus
376}
377#endif
378#endif
Note: See TracBrowser for help on using the repository browser.