File: Cbc_C_Interface.h

package info (click to toggle)
coinor-cbc 2.9.9+repack1-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 7,848 kB
  • ctags: 5,787
  • sloc: cpp: 104,337; sh: 8,921; xml: 2,950; makefile: 520; ansic: 491; awk: 197
file content (381 lines) | stat: -rw-r--r-- 12,656 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
/* $Id: Cbc_C_Interface.h 2091 2014-10-03 00:46:49Z mlubin $ */
/*
  Copyright (C) 2004 International Business Machines Corporation and others.
  All Rights Reserved.

  This code is licensed under the terms of the Eclipse Public License (EPL).
*/
#ifndef CbcModelC_H
#define CbcModelC_H

/* include all defines and ugly stuff */
#include "Coin_C_defines.h"
#include <stddef.h>

/*
 * Original verison contributed by Bob Entriken,
 * significantly updated by Miles Lubin.
*/


#ifdef __cplusplus
extern "C" {
#endif

    /**@name Constructors and destructor
      This is a "C" interface to Cbc.
      The user does not need to know structure of Cbc_Model.
    */
    /*@{*/

    /** Default Cbc_Model constructor */
    COINLIBAPI Cbc_Model * COINLINKAGE
    Cbc_newModel(void)
    ;
    /** Cbc_Model Destructor */
    COINLIBAPI void COINLINKAGE
    Cbc_deleteModel(Cbc_Model * model)
    ;
    /** Current version of Cbc */
    COINLIBAPI const char* COINLINKAGE Cbc_getVersion(void)
    ;
    /*@}*/

    /**@name Getting and setting model data
     Note that problem access and modification methods,
       such as getColLower and setColLower,
       are *not valid* after calling Cbc_solve().
       Therefore it is not recommended to reuse a Cbc_Model
       object for multiple solves. A workaround is to call Cbc_clone()
       before solving.
     * */
    /*@{*/
    /** Loads a problem (the constraints on the
        rows are given by lower and upper bounds). If a pointer is NULL then the
        following values are the default:
        <ul>
        <li> <code>colub</code>: all columns have upper bound infinity
        <li> <code>collb</code>: all columns have lower bound 0
        <li> <code>rowub</code>: all rows have upper bound infinity
        <li> <code>rowlb</code>: all rows have lower bound -infinity
        <li> <code>obj</code>: all variables have 0 objective coefficient
        </ul>

     The constraint matrix is
     given in standard compressed sparse column (without gaps).
     <ul>
     <li> <code>start[i]</code> stores the starting index of the ith column
     <li> <code>index[k]</code> stores the row index of the kth nonzero element
     <li> <code>value[k]</code> stores the coefficient of the kth nonzero element
     </ul>
    */
    COINLIBAPI void COINLINKAGE
    Cbc_loadProblem (Cbc_Model * model,  const int numcols, const int numrows,
                     const CoinBigIndex * start, const int* index,
                     const double* value,
                     const double* collb, const double* colub,
                     const double* obj,
                     const double* rowlb, const double* rowub)
    ;
    /** Read an mps file from the given filename */
    COINLIBAPI int COINLINKAGE
    Cbc_readMps(Cbc_Model * model, const char *filename)
    ;
    /** Write an mps file from the given filename */
    COINLIBAPI void COINLINKAGE
    Cbc_writeMps(Cbc_Model * model, const char *filename)
    ;
    /** Provide an initial feasible solution to accelerate branch-and-bound 
     Note that feasibility of the solution is *not* verified.
    */
    COINLIBAPI void COINLINKAGE
    Cbc_setInitialSolution(Cbc_Model *model, const double * sol)
    ;
    /** Fills in array with problem name  */
    COINLIBAPI void COINLINKAGE
    Cbc_problemName(Cbc_Model * model, int maxNumberCharacters, char * array)
    ;
    /** Sets problem name.
    
      \p array must be a null-terminated string.
    */
    COINLIBAPI int COINLINKAGE
    Cbc_setProblemName(Cbc_Model * model, const char * array)
    ;

    /** Number of nonzero elements in constraint matrix */
    COINLIBAPI int COINLINKAGE
    Cbc_getNumElements(Cbc_Model * model)
    ;
    /** "Column start" vector of constraint matrix. Same format as Cbc_loadProblem() */
    COINLIBAPI const CoinBigIndex * COINLINKAGE
    Cbc_getVectorStarts(Cbc_Model * model)
    ;
    /** "Row index" vector of constraint matrix */
    COINLIBAPI const int * COINLINKAGE
    Cbc_getIndices(Cbc_Model * model)
    ;
    /** Coefficient vector of constraint matrix */
    COINLIBAPI const double * COINLINKAGE
    Cbc_getElements(Cbc_Model * model)
    ;

    /** Maximum lenght of a row or column name */
    COINLIBAPI size_t COINLINKAGE
    Cbc_maxNameLength(Cbc_Model * model)
    ;
    /** Fill in first maxLength bytes of name array with a row name */
    COINLIBAPI void COINLINKAGE
    Cbc_getRowName(Cbc_Model * model, int iRow, char * name, size_t maxLength)
    ;
    /** Fill in first maxLength bytes of name array with a column name */
    COINLIBAPI void COINLINKAGE
    Cbc_getColName(Cbc_Model * model, int iColumn, char * name, size_t maxLength)
    ;
    /** Set the name of a column */
    COINLIBAPI void COINLINKAGE
    Cbc_setColName(Cbc_Model * model, int iColumn, const char * name)
    ;
    /** Set the name of a row */
    COINLIBAPI void COINLINKAGE
    Cbc_setRowName(Cbc_Model * model, int iRow, const char * name)
    ;
    /** Number of constraints in the model */
    COINLIBAPI int COINLINKAGE
    Cbc_getNumRows(Cbc_Model * model)
    ;
    /** Number of variables in the model */
    COINLIBAPI int COINLINKAGE
    Cbc_getNumCols(Cbc_Model * model)
    ;
    /** Direction of optimization (1 - minimize, -1 - maximize, 0 - ignore) */
    COINLIBAPI void COINLINKAGE
    Cbc_setObjSense(Cbc_Model * model, double sense)
    ;
    /** Direction of optimization (1 - minimize, -1 - maximize, 0 - ignore) */
    COINLIBAPI double COINLINKAGE
    Cbc_getObjSense(Cbc_Model * model)
    ;
    /** Constraint lower bounds */
    COINLIBAPI const double* COINLINKAGE
    Cbc_getRowLower(Cbc_Model * model)
    ;
    /** Set the lower bound of a single constraint */
    COINLIBAPI void COINLINKAGE
    Cbc_setRowLower(Cbc_Model * model, int index, double value)
    ;
    /** Constraint upper bounds */
    COINLIBAPI const double* COINLINKAGE
    Cbc_getRowUpper(Cbc_Model * model)
    ;
    /** Set the upper bound of a single constraint */
    COINLIBAPI void COINLINKAGE
    Cbc_setRowUpper(Cbc_Model * model, int index, double value)
    ;
    /** Objective vector */
    COINLIBAPI const double * COINLINKAGE
    Cbc_getObjCoefficients(Cbc_Model * model)
    ;
    /** Set the objective coefficient of a single variable */
    COINLIBAPI void COINLINKAGE
    Cbc_setObjCoeff(Cbc_Model * model, int index, double value)
    ;
    /** Variable lower bounds */
    COINLIBAPI const double * COINLINKAGE
    Cbc_getColLower(Cbc_Model * model)
    ;
    /** Set the lower bound of a single variable */
    COINLIBAPI void COINLINKAGE
    Cbc_setColLower(Cbc_Model * model, int index, double value)
    ;
    /** Variable upper bounds */
    COINLIBAPI const double * COINLINKAGE
    Cbc_getColUpper(Cbc_Model * model)
    ;
    /** Set the upper bound of a single variable */
    COINLIBAPI void COINLINKAGE
    Cbc_setColUpper(Cbc_Model * model, int index, double value)
    ;
    /** Determine whether the ith variable is integer restricted */
    COINLIBAPI int COINLINKAGE
    Cbc_isInteger(Cbc_Model * model, int i)
    ;
    /** Set this variable to be continuous */
    COINLIBAPI void COINLINKAGE
    Cbc_setContinuous(Cbc_Model * model, int iColumn)
    ;
    /** Set this variable to be integer */
    COINLIBAPI void COINLINKAGE
    Cbc_setInteger(Cbc_Model * model, int iColumn)
    ;
    /** Add SOS constraints to the model using row-order matrix */
    COINLIBAPI void  COINLINKAGE
    Cbc_addSOS(Cbc_Model * model, int numRows, const int * rowStarts,
               const int * colIndices, const double * weights, const int type)
    ;
    /** Print the model */
    COINLIBAPI void COINLINKAGE
    Cbc_printModel(Cbc_Model * model, const char * argPrefix)
    ;
    /** Return a copy of this model */
    COINLIBAPI Cbc_Model * COINLINKAGE
    Cbc_clone(Cbc_Model * model)
    ;
    /*@}*/
    /**@name Solver parameters */
    /*@{*/
    /** Set parameter "name" to value "value". Note that this
     * translates directly to using "-name value" as a 
     * command-line argument to Cbc.*/
    COINLIBAPI void COINLINKAGE
    Cbc_setParameter(Cbc_Model * model, const char * name, const char * value)
    ;

    
    /*@}*/
    /**@name Message handling.  Call backs are handled by ONE function */
    /*@{*/
    /** Pass in Callback function.
     Message numbers up to 1000000 are Clp, Coin ones have 1000000 added */
    COINLIBAPI void COINLINKAGE
    Cbc_registerCallBack(Cbc_Model * model,
                         cbc_callback userCallBack)
    ;
    /** Unset Callback function */
    COINLIBAPI void COINLINKAGE
    Cbc_clearCallBack(Cbc_Model * model)
    ;

    /*@}*/


    /**@name Solving the model */
    /*@{*/
    /* Solve the model with Cbc (using CbcMain1).
    */
    COINLIBAPI int COINLINKAGE
    Cbc_solve(Cbc_Model * model)
    ;
    /*@}*/


    /**@name Accessing the solution and solution status */
    /*@{*/

    /** Sum of primal infeasibilities */
    COINLIBAPI double COINLINKAGE
    Cbc_sumPrimalInfeasibilities(Cbc_Model * model)
    ;
    /** Number of primal infeasibilities */
    COINLIBAPI int COINLINKAGE
    Cbc_numberPrimalInfeasibilities(Cbc_Model * model)
    ;

    /** Just check solution (for external use) - sets sum of
        infeasibilities etc */
    COINLIBAPI void COINLINKAGE
    Cbc_checkSolution(Cbc_Model * model)
    ;

    /** Number of iterations */
    COINLIBAPI int COINLINKAGE
    Cbc_getIterationCount(Cbc_Model * model)
    ;
    /** Are there a numerical difficulties? */
    COINLIBAPI int COINLINKAGE
    Cbc_isAbandoned(Cbc_Model * model)
    ;
    /** Is optimality proven? */
    COINLIBAPI int COINLINKAGE
    Cbc_isProvenOptimal(Cbc_Model * model)
    ;
    /** Is infeasiblity proven (or none better than cutoff)? */
    COINLIBAPI int COINLINKAGE
    Cbc_isProvenInfeasible(Cbc_Model * model)
    ;
    /** Was continuous solution unbounded? */
    COINLIBAPI int COINLINKAGE
    Cbc_isContinuousUnbounded(Cbc_Model * model)
    ;
    /** Node limit reached? */
    COINLIBAPI int COINLINKAGE
    Cbc_isNodeLimitReached(Cbc_Model * model)
    ;
    /** Time limit reached? */
    COINLIBAPI int COINLINKAGE
    Cbc_isSecondsLimitReached(Cbc_Model * model)
    ;
    /** Solution limit reached? */
    COINLIBAPI int COINLINKAGE
    Cbc_isSolutionLimitReached(Cbc_Model * model)
    ;
    /** Are there numerical difficulties (for initialSolve) ? */
    COINLIBAPI int COINLINKAGE
    Cbc_isInitialSolveAbandoned(Cbc_Model * model)
    ;
    /** Is optimality proven (for initialSolve) ? */
    COINLIBAPI int COINLINKAGE
    Cbc_isInitialSolveProvenOptimal(Cbc_Model * model)
    ;
    /** Is primal infeasiblity proven (for initialSolve) ? */
    COINLIBAPI int COINLINKAGE
    Cbc_isInitialSolveProvenPrimalInfeasible(Cbc_Model * model)
    ;
    /** "row" solution
     *  This is the vector A*x, where A is the constraint matrix
     *  and x is the current solution. */
    COINLIBAPI const double * COINLINKAGE
    Cbc_getRowActivity(Cbc_Model * model)
    ;
    /** Best feasible solution vector */
    COINLIBAPI const double * COINLINKAGE
    Cbc_getColSolution(Cbc_Model * model)
    ;
    /** Objective value of best feasible solution */
    COINLIBAPI double COINLINKAGE
    Cbc_getObjValue(Cbc_Model * model)
    ;
    /** Best known bound on the optimal objective value */
    COINLIBAPI double COINLINKAGE
    Cbc_getBestPossibleObjValue(Cbc_Model * model)
    ;
    /** Number of nodes explored in B&B tree */
    COINLIBAPI int COINLINKAGE
    Cbc_getNodeCount(Cbc_Model * model)
    ;
    /** Print the solution */
    COINLIBAPI void  COINLINKAGE
    Cbc_printSolution(Cbc_Model * model)
    ;
    /** Final status of problem
        Some of these can be found out by is...... functions
        -1 before branchAndBound
        0 finished - check isProvenOptimal or isProvenInfeasible to see if solution found
        (or check value of best solution)
        1 stopped - on maxnodes, maxsols, maxtime
        2 difficulties so run was abandoned
        (5 event user programmed event occurred)
    */
    COINLIBAPI int COINLINKAGE
    Cbc_status(Cbc_Model * model)
    ;
    /** Secondary status of problem
        -1 unset (status_ will also be -1)
        0 search completed with solution
        1 linear relaxation not feasible (or worse than cutoff)
        2 stopped on gap
        3 stopped on nodes
        4 stopped on time
        5 stopped on user event
        6 stopped on solutions
        7 linear relaxation unbounded
        8 stopped on iteration limit
    */
    COINLIBAPI int COINLINKAGE
    Cbc_secondaryStatus(Cbc_Model * model)
    ;
    /*@}*/
#ifdef __cplusplus
}
#endif
#endif