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

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

Disable non-working SOS constraints
Add non-working attempt at problem modification

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 12.9 KB
Line 
1/* $Id: Cbc_C_Interface.h 2036 2014-05-26 01:07:36Z 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    /** Set the lower bound of a single constraint */
176    COINLIBAPI void COINLINKAGE
177    Cbc_setRowLower(Cbc_Model * model, int index, double value)
178    ;
179    /** Constraint upper bounds */
180    COINLIBAPI const double* COINLINKAGE
181    Cbc_getRowUpper(Cbc_Model * model)
182    ;
183    /** Set the upper bound of a single constraint */
184    COINLIBAPI void COINLINKAGE
185    Cbc_setRowUpper(Cbc_Model * model, int index, double value)
186    ;
187    /** Objective vector */
188    COINLIBAPI const double * COINLINKAGE
189    Cbc_getObjCoefficients(Cbc_Model * model)
190    ;
191    /** Set the objective coefficient of a single variable */
192    COINLIBAPI void COINLINKAGE
193    Cbc_setObjCoeff(Cbc_Model * model, int index, double value)
194    ;
195    /** Variable lower bounds */
196    COINLIBAPI const double * COINLINKAGE
197    Cbc_getColLower(Cbc_Model * model)
198    ;
199    /** Set the lower bound of a single variable */
200    COINLIBAPI void COINLINKAGE
201    Cbc_setColLower(Cbc_Model * model, int index, double value)
202    ;
203    /** Variable upper bounds */
204    COINLIBAPI const double * COINLINKAGE
205    Cbc_getColUpper(Cbc_Model * model)
206    ;
207    /** Set the upper bound of a single variable */
208    COINLIBAPI void COINLINKAGE
209    Cbc_setColUpper(Cbc_Model * model, int index, double value)
210    ;
211    /** Determine whether the ith variable is integer restricted */
212    COINLIBAPI int COINLINKAGE
213    Cbc_isInteger(Cbc_Model * model, int i)
214    ;
215    /** Set this variable to be continuous */
216    COINLIBAPI Cbc_Model * COINLINKAGE
217    Cbc_setContinuous(Cbc_Model * model, int iColumn)
218    ;
219    /** Set this variable to be integer */
220    COINLIBAPI Cbc_Model * COINLINKAGE
221    Cbc_setInteger(Cbc_Model * model, int iColumn)
222    ;
223    /* Add SOS constraints to the model using row-order matrix
224     * Unable to confirm that this function is working. */
225    /*COINLIBAPI void  COINLINKAGE
226    Cbc_addSOS(Cbc_Model * model, int numRows, const int * rowStarts,
227               const int * colIndices, const double * weights, const int type)
228    ;*/
229    /** Print the model */
230    COINLIBAPI void COINLINKAGE
231    Cbc_printModel(Cbc_Model * model, const char * argPrefix)
232    ;
233    /** Return a copy of this model */
234    COINLIBAPI Cbc_Model * COINLINKAGE
235    Cbc_clone(Cbc_Model * model)
236    ;
237    /*@}*/
238    /**@name Solver parameters */
239    /*@{*/
240    /** Set parameter "name" to value "value". Note that this
241     * translates directly to using "-name value" as a
242     * command-line argument to Cbc.*/
243    COINLIBAPI void COINLINKAGE
244    Cbc_setParameter(Cbc_Model * model, const char * name, const char * value)
245    ;
246
247   
248    /*@}*/
249    /**@name Message handling.  Call backs are handled by ONE function */
250    /*@{*/
251    /** Pass in Callback function.
252     Message numbers up to 1000000 are Clp, Coin ones have 1000000 added */
253    COINLIBAPI void COINLINKAGE
254    Cbc_registerCallBack(Cbc_Model * model,
255                         cbc_callback userCallBack)
256    ;
257    /** Unset Callback function */
258    COINLIBAPI void COINLINKAGE
259    Cbc_clearCallBack(Cbc_Model * model)
260    ;
261
262    /*@}*/
263
264
265    /**@name Solving the model */
266    /*@{*/
267    /* Solve the model with Cbc (using CbcMain1).
268    */
269    COINLIBAPI int COINLINKAGE
270    Cbc_solve(Cbc_Model * model)
271    ;
272    /*@}*/
273
274
275    /**@name Accessing the solution and solution status */
276    /*@{*/
277
278    /** Sum of primal infeasibilities */
279    COINLIBAPI double COINLINKAGE
280    Cbc_sumPrimalInfeasibilities(Cbc_Model * model)
281    ;
282    /** Number of primal infeasibilities */
283    COINLIBAPI int COINLINKAGE
284    Cbc_numberPrimalInfeasibilities(Cbc_Model * model)
285    ;
286
287    /** Just check solution (for external use) - sets sum of
288        infeasibilities etc */
289    COINLIBAPI void COINLINKAGE
290    Cbc_checkSolution(Cbc_Model * model)
291    ;
292
293    /** Number of iterations */
294    COINLIBAPI int COINLINKAGE
295    Cbc_getIterationCount(Cbc_Model * model)
296    ;
297    /** Are there a numerical difficulties? */
298    COINLIBAPI int COINLINKAGE
299    Cbc_isAbandoned(Cbc_Model * model)
300    ;
301    /** Is optimality proven? */
302    COINLIBAPI int COINLINKAGE
303    Cbc_isProvenOptimal(Cbc_Model * model)
304    ;
305    /** Is infeasiblity proven (or none better than cutoff)? */
306    COINLIBAPI int COINLINKAGE
307    Cbc_isProvenInfeasible(Cbc_Model * model)
308    ;
309    /** Was continuous solution unbounded? */
310    COINLIBAPI int COINLINKAGE
311    Cbc_isContinuousUnbounded(Cbc_Model * model)
312    ;
313    /** Node limit reached? */
314    COINLIBAPI int COINLINKAGE
315    Cbc_isNodeLimitReached(Cbc_Model * model)
316    ;
317    /** Time limit reached? */
318    COINLIBAPI int COINLINKAGE
319    Cbc_isSecondsLimitReached(Cbc_Model * model)
320    ;
321    /** Solution limit reached? */
322    COINLIBAPI int COINLINKAGE
323    Cbc_isSolutionLimitReached(Cbc_Model * model)
324    ;
325    /** Are there numerical difficulties (for initialSolve) ? */
326    COINLIBAPI int COINLINKAGE
327    Cbc_isInitialSolveAbandoned(Cbc_Model * model)
328    ;
329    /** Is optimality proven (for initialSolve) ? */
330    COINLIBAPI int COINLINKAGE
331    Cbc_isInitialSolveProvenOptimal(Cbc_Model * model)
332    ;
333    /** Is primal infeasiblity proven (for initialSolve) ? */
334    COINLIBAPI int COINLINKAGE
335    Cbc_isInitialSolveProvenPrimalInfeasible(Cbc_Model * model)
336    ;
337    /** "row" solution
338     *  This is the vector A*x, where A is the constraint matrix
339     *  and x is the current solution. */
340    COINLIBAPI const double * COINLINKAGE
341    Cbc_getRowActivity(Cbc_Model * model)
342    ;
343    /** Best feasible solution vector */
344    COINLIBAPI const double * COINLINKAGE
345    Cbc_getColSolution(Cbc_Model * model)
346    ;
347    /** Objective value of best feasible solution */
348    COINLIBAPI double COINLINKAGE
349    Cbc_getObjValue(Cbc_Model * model)
350    ;
351    /** Best known bound on the optimal objective value */
352    COINLIBAPI double COINLINKAGE
353    Cbc_getBestPossibleObjValue(Cbc_Model * model)
354    ;
355    /** Number of nodes explored in B&B tree */
356    COINLIBAPI int COINLINKAGE
357    Cbc_getNodeCount(Cbc_Model * model)
358    ;
359    /** Print the solution */
360    COINLIBAPI void  COINLINKAGE
361    Cbc_printSolution(Cbc_Model * model)
362    ;
363    /** Final status of problem
364        Some of these can be found out by is...... functions
365        -1 before branchAndBound
366        0 finished - check isProvenOptimal or isProvenInfeasible to see if solution found
367        (or check value of best solution)
368        1 stopped - on maxnodes, maxsols, maxtime
369        2 difficulties so run was abandoned
370        (5 event user programmed event occurred)
371    */
372    COINLIBAPI int COINLINKAGE
373    Cbc_status(Cbc_Model * model)
374    ;
375    /** Secondary status of problem
376        -1 unset (status_ will also be -1)
377        0 search completed with solution
378        1 linear relaxation not feasible (or worse than cutoff)
379        2 stopped on gap
380        3 stopped on nodes
381        4 stopped on time
382        5 stopped on user event
383        6 stopped on solutions
384        7 linear relaxation unbounded
385        8 stopped on iteration limit
386    */
387    COINLIBAPI int COINLINKAGE
388    Cbc_secondaryStatus(Cbc_Model * model)
389    ;
390    /*@}*/
391#ifdef __cplusplus
392}
393#endif
394#endif
Note: See TracBrowser for help on using the repository browser.