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

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

Major cleaning of C interface, more to come

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 12.2 KB
RevLine 
[1271]1/* $Id: Cbc_C_Interface.h 2019 2014-03-11 21:10:15Z mlubin $ */
[1573]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*/
[2]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
[1286]20extern "C" {
[2]21#endif
22
[1286]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.
[2]26
[1286]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    /*@{*/
[703]32
[1286]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    /*@}*/
[2]45
[1286]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>
[2]58
[1286]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    ;
[2]89
[1286]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    ;
[2]110
[1286]111    /*@}*/
112    /**@name gets and sets - you will find some synonyms at the end of this file */
113    /*@{*/
114    /** Objective offset */
115    COINLIBAPI double COINLINKAGE
116    Cbc_objectiveOffset(Cbc_Model * model)
117    ;
118    COINLIBAPI void COINLINKAGE
119    Cbc_setObjectiveOffset(Cbc_Model * model, double value)
120    ;
121    /** Fills in array with problem name  */
122    COINLIBAPI void COINLINKAGE
123    Cbc_problemName(Cbc_Model * model, int maxNumberCharacters, char * array)
124    ;
[1600]125    /** Sets problem name.
126   
127      \p array must be a null-terminated string.
128    */
[1286]129    COINLIBAPI int COINLINKAGE
130    Cbc_setProblemName(Cbc_Model * model, int maxNumberCharacters, char * array)
131    ;
132    /** Status of problem:
133        0 - optimal
134        1 - primal infeasible
135        2 - dual infeasible
136        3 - stopped on iterations etc
137        4 - stopped due to errors
138    */
139    COINLIBAPI int COINLINKAGE
140    Cbc_status(Cbc_Model * model)
141    ;
142    /** Secondary status of problem - may get extended
143        0 - none
144        1 - primal infeasible because dual limit reached
145        2 - scaled problem optimal - unscaled has primal infeasibilities
146        3 - scaled problem optimal - unscaled has dual infeasibilities
147        4 - scaled problem optimal - unscaled has both dual and primal infeasibilities
148    */
149    COINLIBAPI int COINLINKAGE
150    Cbc_secondaryStatus(Cbc_Model * model)
151    ;
152    COINLIBAPI void COINLINKAGE
153    Cbc_setSecondaryStatus(Cbc_Model * model, int status)
154    ;
155    /** Number of elements in matrix */
156    COINLIBAPI int COINLINKAGE
157    Cbc_getNumElements(Cbc_Model * model)
158    ;
159    /** Column starts in matrix */
160    COINLIBAPI const CoinBigIndex * COINLINKAGE
161    Cbc_getVectorStarts(Cbc_Model * model)
162    ;
163    /** Row indices in matrix */
164    COINLIBAPI const int * COINLINKAGE
165    Cbc_getIndices(Cbc_Model * model)
166    ;
167    /** Column vector lengths in matrix */
168    COINLIBAPI const int * COINLINKAGE
169    Cbc_getVectorLengths(Cbc_Model * model)
170    ;
171    /** Element values in matrix */
172    COINLIBAPI const double * COINLINKAGE
173    Cbc_getElements(Cbc_Model * model)
174    ;
[2019]175   
[1286]176    /*@}*/
177    /**@name Message handling.  Call backs are handled by ONE function */
178    /*@{*/
179    /** Pass in Callback function.
180     Message numbers up to 1000000 are Clp, Coin ones have 1000000 added */
181    COINLIBAPI void COINLINKAGE
182    Cbc_registerCallBack(Cbc_Model * model,
183                         cbc_callback userCallBack)
184    ;
185    /** Unset Callback function */
186    COINLIBAPI void COINLINKAGE
187    Cbc_clearCallBack(Cbc_Model * model)
188    ;
189    /** length of names (0 means no names0 */
190    COINLIBAPI int COINLINKAGE
191    Cbc_lengthNames(Cbc_Model * model)
192    ;
193    /** Fill in array (at least lengthNames+1 long) with a row name */
194    COINLIBAPI void COINLINKAGE
195    Cbc_rowName(Cbc_Model * model, int iRow, char * name)
196    ;
197    /** Fill in array (at least lengthNames+1 long) with a column name */
198    COINLIBAPI void COINLINKAGE
199    Cbc_columnName(Cbc_Model * model, int iColumn, char * name)
200    ;
[2]201
[1286]202    /*@}*/
[2]203
204
[1286]205    /**@name Functions most useful to user */
206    /*@{*/
[2016]207    /* Solve using CbcMain1. This is the recommended default solve function.
208    */
209    COINLIBAPI int COINLINKAGE
210    Cbc_solve(Cbc_Model * model)
211    ;
[1286]212    /*@}*/
213
214
215    /**@name most useful gets and sets */
216    /*@{*/
217    /** Sum of primal infeasibilities */
218    COINLIBAPI double COINLINKAGE
219    Cbc_sumPrimalInfeasibilities(Cbc_Model * model)
220    ;
221    /** Number of primal infeasibilities */
222    COINLIBAPI int COINLINKAGE
223    Cbc_numberPrimalInfeasibilities(Cbc_Model * model)
224    ;
225
226    /** Just check solution (for external use) - sets sum of
227        infeasibilities etc */
228    COINLIBAPI void COINLINKAGE
229    Cbc_checkSolution(Cbc_Model * model)
230    ;
231    /*@}*/
232
233    /******************** End of most useful part **************/
234    /**@name gets and sets - some synonyms */
235    /*@{*/
236    /** Number of rows */
237    COINLIBAPI int COINLINKAGE
238    Cbc_getNumRows(Cbc_Model * model)
239    ;
240    /** Number of columns */
241    COINLIBAPI int COINLINKAGE
242    Cbc_getNumCols(Cbc_Model * model)
243    ;
244    /** Number of iterations */
245    COINLIBAPI int COINLINKAGE
246    Cbc_getIterationCount(Cbc_Model * model)
247    ;
248    /** Are there a numerical difficulties? */
249    COINLIBAPI int COINLINKAGE
250    Cbc_isAbandoned(Cbc_Model * model)
251    ;
252    /** Is optimality proven? */
253    COINLIBAPI int COINLINKAGE
254    Cbc_isProvenOptimal(Cbc_Model * model)
255    ;
[2019]256    /** Is infeasiblity proven (or none better than cutoff)? */
[1286]257    COINLIBAPI int COINLINKAGE
[2019]258    Cbc_isProvenInfeasible(Cbc_Model * model)
[1286]259    ;
[2019]260    /** Was continuous solution unbounded? */
[1286]261    COINLIBAPI int COINLINKAGE
[2019]262    Cbc_isContinuousUnbounded(Cbc_Model * model)
[1286]263    ;
[2019]264    /** Node limit reached? */
[1286]265    COINLIBAPI int COINLINKAGE
[2019]266    Cbc_isNodeLimitReached(Cbc_Model * model)
[1286]267    ;
[2019]268    /** Time limit reached? */
[1286]269    COINLIBAPI int COINLINKAGE
[2019]270    Cbc_isSecondsLimitReached(Cbc_Model * model)
[1286]271    ;
[2019]272    /** Solution limit reached? */
[1286]273    COINLIBAPI int COINLINKAGE
[2019]274    Cbc_isSolutionLimitReached(Cbc_Model * model)
[1286]275    ;
[2019]276    /** Are there numerical difficulties (for initialSolve) ? */
277    COINLIBAPI int COINLINKAGE
278    Cbc_isInitialSolveAbandoned(Cbc_Model * model)
279    ;
280    /** Is optimality proven (for initialSolve) ? */
281    COINLIBAPI int COINLINKAGE
282    Cbc_isInitialSolveProvenOptimal(Cbc_Model * model)
283    ;
284    /** Is primal infeasiblity proven (for initialSolve) ? */
285    COINLIBAPI int COINLINKAGE
286    Cbc_isInitialSolveProvenPrimalInfeasible(Cbc_Model * model)
287    ;
288    /** Direction of optimization (1 - minimize, -1 - maximize, 0 - ignore) */
289    COINLIBAPI void COINLINKAGE
290    Cbc_setObjSense(Cbc_Model * model, double sense)
291    ;
292    /** Direction of optimization (1 - minimize, -1 - maximize, 0 - ignore) */
[1286]293    COINLIBAPI double COINLINKAGE
294    Cbc_getObjSense(Cbc_Model * model)
295    ;
[2019]296    /** Primal row solution
297     *  This is the vector A*x, where A is the constraint matrix
298     *  and x is the current solution. */
[1286]299    COINLIBAPI const double * COINLINKAGE
300    Cbc_getRowActivity(Cbc_Model * model)
301    ;
302    /** Primal column solution */
303    COINLIBAPI const double * COINLINKAGE
304    Cbc_getColSolution(Cbc_Model * model)
305    ;
306    COINLIBAPI void COINLINKAGE
307    Cbc_setColSolution(Cbc_Model * model, const double * input)
308    ;
309    /** Row lower */
310    COINLIBAPI const double* COINLINKAGE
311    Cbc_getRowLower(Cbc_Model * model)
312    ;
313    /** Row upper  */
314    COINLIBAPI const double* COINLINKAGE
315    Cbc_getRowUpper(Cbc_Model * model)
316    ;
317    /** Objective */
318    COINLIBAPI const double * COINLINKAGE
319    Cbc_getObjCoefficients(Cbc_Model * model)
320    ;
321    /** Column Lower */
322    COINLIBAPI const double * COINLINKAGE
323    Cbc_getColLower(Cbc_Model * model)
324    ;
325    /** Column Upper */
326    COINLIBAPI const double * COINLINKAGE
327    Cbc_getColUpper(Cbc_Model * model)
328    ;
329    /** Objective value */
330    COINLIBAPI double COINLINKAGE
331    Cbc_getObjValue(Cbc_Model * model)
332    ;
333    /** Print the model */
334    COINLIBAPI void COINLINKAGE
335    Cbc_printModel(Cbc_Model * model, const char * argPrefix)
336    ;
337    /** Determine whether the variable at location i is integer restricted */
338    COINLIBAPI int COINLINKAGE
339    Cbc_isInteger(Cbc_Model * model, int i)
340    ;
341    /** Return CPU time */
342    COINLIBAPI double COINLINKAGE
343    Cbc_cpuTime(Cbc_Model * model)
344    ;
345    /** Number of nodes explored in B&B tree */
346    COINLIBAPI int COINLINKAGE
347    Cbc_getNodeCount(Cbc_Model * model)
348    ;
349    /** Return a copy of this model */
350    COINLIBAPI Cbc_Model * COINLINKAGE
351    Cbc_clone(Cbc_Model * model)
352    ;
353    /** Set this the variable to be continuous */
354    COINLIBAPI Cbc_Model * COINLINKAGE
355    Cbc_setContinuous(Cbc_Model * model, int iColumn)
356    ;
[2019]357    /** Set this the variable to be integer */
358    COINLIBAPI Cbc_Model * COINLINKAGE
359    Cbc_setInteger(Cbc_Model * model, int iColumn)
360    ;
[1286]361    /** Add SOS constraints to the model using dense matrix */
362    COINLIBAPI void  COINLINKAGE
363    Cbc_addSOS_Dense(Cbc_Model * model, int numObjects, const int * len,
[1898]364                     const int * const * which, const double * weights, const int type)
[1286]365    ;
366    /** Add SOS constraints to the model using row-order matrix */
367    COINLIBAPI void  COINLINKAGE
368    Cbc_addSOS_Sparse(Cbc_Model * model, const int * rowStarts,
369                      const int * rowIndices, const double * weights, const int type)
370    ;
371    /** Delete all object information */
372    COINLIBAPI void  COINLINKAGE
373    Cbc_deleteObjects(Cbc_Model * model)
374    ;
375    /** Print the solution */
376    COINLIBAPI void  COINLINKAGE
377    Cbc_printSolution(Cbc_Model * model)
378    ;
379    /*@}*/
[2]380#ifdef __cplusplus
[1286]381}
[2]382#endif
383#endif
Note: See TracBrowser for help on using the repository browser.