1 | /* $Id: Cbc_C_Interface.h 2573 2019-05-08 10:35:04Z unxusr $ */ |
---|
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 | /* |
---|
16 | * Original version contributed by Bob Entriken, |
---|
17 | * significantly updated by Miles Lubin. |
---|
18 | * 2018: several updates by Haroldo |
---|
19 | */ |
---|
20 | |
---|
21 | #ifdef __cplusplus |
---|
22 | extern "C" { |
---|
23 | #endif |
---|
24 | |
---|
25 | /** Current version of Cbc */ |
---|
26 | COINLIBAPI const char *COINLINKAGE Cbc_getVersion(void); |
---|
27 | |
---|
28 | /** \name Problem creation and modification routines */ |
---|
29 | //@{ |
---|
30 | |
---|
31 | /** @brief Creates an empty problem */ |
---|
32 | COINLIBAPI Cbc_Model *COINLINKAGE |
---|
33 | Cbc_newModel(void); |
---|
34 | |
---|
35 | /** @brief Sets problem name. |
---|
36 | * |
---|
37 | * @param model problem object |
---|
38 | * @param array string with problem name |
---|
39 | **/ |
---|
40 | COINLIBAPI int COINLINKAGE |
---|
41 | Cbc_setProblemName(Cbc_Model *model, const char *array); |
---|
42 | |
---|
43 | /** @brief activates/deactivates name indexes |
---|
44 | * |
---|
45 | * @param model problem object |
---|
46 | * @param store: 1 maintain indexes of column and constraints names for searching indexes, 0 not |
---|
47 | **/ |
---|
48 | COINLIBAPI void COINLINKAGE |
---|
49 | Cbc_storeNameIndexes(Cbc_Model *model, char _store); |
---|
50 | |
---|
51 | /** @brief searches columns by name and returns its index |
---|
52 | * |
---|
53 | * call Cbc_storeNameIndexes to enable search by name |
---|
54 | * |
---|
55 | * @param model problem object |
---|
56 | * @param name column (variable) name |
---|
57 | * @return column index or -1 if not found |
---|
58 | **/ |
---|
59 | COINLIBAPI int COINLINKAGE |
---|
60 | Cbc_getColNameIndex(Cbc_Model *model, const char *name); |
---|
61 | |
---|
62 | /** @brief searches rows by name and returns its index |
---|
63 | * |
---|
64 | * call Cbc_storeNameIndexes to enable search by name |
---|
65 | * |
---|
66 | * @param model problem object |
---|
67 | * @param name row (constraint) name |
---|
68 | * @return row index or -1 if not found |
---|
69 | **/ |
---|
70 | COINLIBAPI int COINLINKAGE |
---|
71 | Cbc_getRowNameIndex(Cbc_Model *model, const char *name); |
---|
72 | |
---|
73 | /** @brief Creates a new column |
---|
74 | * |
---|
75 | * Creates a new column (variable) |
---|
76 | * |
---|
77 | * @param model problem object |
---|
78 | * @param name variable name |
---|
79 | * @param lb column lower bound |
---|
80 | * @param ub column upper bound |
---|
81 | * @param obj objective function coefficient |
---|
82 | * @param isInteger 1 if variable is integral, 0 otherwise |
---|
83 | * @param nz number of rows (constraints) where this column appears, can be 0 if constraints will be added later |
---|
84 | * @param rows index of rows where this column appears, NULL if rows will be added later |
---|
85 | * @param coefs coefficients that this column appears in its rows, NULL if rows will be added later |
---|
86 | ***/ |
---|
87 | COINLIBAPI void COINLINKAGE |
---|
88 | Cbc_addCol(Cbc_Model *model, const char *name, double lb, |
---|
89 | double ub, double obj, char isInteger, |
---|
90 | int nz, int *rows, double *coefs); |
---|
91 | |
---|
92 | |
---|
93 | /** @brief Deletes some columns |
---|
94 | * |
---|
95 | * Deletes some columns (variables) |
---|
96 | * |
---|
97 | * @param model problem object |
---|
98 | * @param numCols |
---|
99 | * @param cols columns that will be deleted |
---|
100 | * */ |
---|
101 | COINLIBAPI void COINLINKAGE |
---|
102 | Cbc_deleteCols(Cbc_Model *model, int numCols, const int cols[]); |
---|
103 | |
---|
104 | /** @brief Adds a new row |
---|
105 | * |
---|
106 | * Adds a new row (linear constraint) to the problem |
---|
107 | * |
---|
108 | * @param model problem object |
---|
109 | * @param name constraint name |
---|
110 | * @param nz number of variables with non-zero coefficients in this row |
---|
111 | * @param cols index of variables that appear in this row |
---|
112 | * @param coefs cofficients that that variables appear |
---|
113 | * @param sense constraint sense: L if <=, G if >=, E if =, R if ranged and N if free |
---|
114 | * @param rhs right hand size |
---|
115 | * */ |
---|
116 | COINLIBAPI void COINLINKAGE |
---|
117 | Cbc_addRow(Cbc_Model *model, const char *name, int nz, |
---|
118 | const int *cols, const double *coefs, char sense, double rhs); |
---|
119 | |
---|
120 | /** @brief Deletes some rows |
---|
121 | * |
---|
122 | * Deletes some rows from the model |
---|
123 | * |
---|
124 | * @param model problem object |
---|
125 | * @param numRows number of rows |
---|
126 | * @param rows rows to be deleted |
---|
127 | * */ |
---|
128 | COINLIBAPI void COINLINKAGE |
---|
129 | Cbc_deleteRows(Cbc_Model *model, int numRows, const int rows[]); |
---|
130 | |
---|
131 | /** @brief Add SOS constraints to the model using row-order matrix */ |
---|
132 | COINLIBAPI void COINLINKAGE |
---|
133 | Cbc_addSOS(Cbc_Model *model, int numRows, const int *rowStarts, |
---|
134 | const int *colIndices, const double *weights, const int type); |
---|
135 | |
---|
136 | /** Loads a problem (the constraints on the |
---|
137 | rows are given by lower and upper bounds). If a pointer is NULL then the |
---|
138 | following values are the default: |
---|
139 | <ul> |
---|
140 | <li> <code>colub</code>: all columns have upper bound infinity |
---|
141 | <li> <code>collb</code>: all columns have lower bound 0 |
---|
142 | <li> <code>rowub</code>: all rows have upper bound infinity |
---|
143 | <li> <code>rowlb</code>: all rows have lower bound -infinity |
---|
144 | <li> <code>obj</code>: all variables have 0 objective coefficient |
---|
145 | </ul> |
---|
146 | |
---|
147 | The constraint matrix is |
---|
148 | given in standard compressed sparse column (without gaps). |
---|
149 | <ul> |
---|
150 | <li> <code>start[i]</code> stores the starting index of the ith column |
---|
151 | <li> <code>index[k]</code> stores the row index of the kth nonzero element |
---|
152 | <li> <code>value[k]</code> stores the coefficient of the kth nonzero element |
---|
153 | </ul> |
---|
154 | */ |
---|
155 | COINLIBAPI void COINLINKAGE |
---|
156 | Cbc_loadProblem(Cbc_Model *model, const int numcols, const int numrows, |
---|
157 | const CoinBigIndex *start, const int *index, |
---|
158 | const double *value, |
---|
159 | const double *collb, const double *colub, |
---|
160 | const double *obj, |
---|
161 | const double *rowlb, const double *rowub); |
---|
162 | |
---|
163 | /** @brief Set the name of a column |
---|
164 | * |
---|
165 | * @param model problem object |
---|
166 | * @param iColumn column index |
---|
167 | * @param column name |
---|
168 | **/ |
---|
169 | COINLIBAPI void COINLINKAGE |
---|
170 | Cbc_setColName(Cbc_Model *model, int iColumn, const char *name); |
---|
171 | |
---|
172 | /** @brief Set the name of a row |
---|
173 | * |
---|
174 | * @param model problem object |
---|
175 | * @param iRow row index |
---|
176 | * @param name row name |
---|
177 | **/ |
---|
178 | COINLIBAPI void COINLINKAGE |
---|
179 | Cbc_setRowName(Cbc_Model *model, int iRow, const char *name); |
---|
180 | |
---|
181 | /** @brief Sets optimization direction |
---|
182 | * |
---|
183 | * @param model problem object |
---|
184 | * @param sense: direction of optimization (1 - minimize, -1 - maximize, 0 - ignore) |
---|
185 | **/ |
---|
186 | COINLIBAPI void COINLINKAGE |
---|
187 | Cbc_setObjSense(Cbc_Model *model, double sense); |
---|
188 | |
---|
189 | /** @brief Set the lower bound of a single constraint |
---|
190 | * |
---|
191 | * @param model problem object |
---|
192 | * @param index row index |
---|
193 | * @param value new row lower bound |
---|
194 | **/ |
---|
195 | COINLIBAPI void COINLINKAGE |
---|
196 | Cbc_setRowLower(Cbc_Model *model, int index, double value); |
---|
197 | |
---|
198 | /** @brief Set the upper bound of a single constraint |
---|
199 | * |
---|
200 | * @param model problem object |
---|
201 | * @param index row index |
---|
202 | * @param value new row upper bound |
---|
203 | **/ |
---|
204 | COINLIBAPI void COINLINKAGE |
---|
205 | Cbc_setRowUpper(Cbc_Model *model, int index, double value); |
---|
206 | |
---|
207 | /** @brief Set the objective coefficient of a single variable |
---|
208 | * |
---|
209 | * @param model problem object |
---|
210 | * @param index variable index |
---|
211 | * @param value new objective function coefficient for this variable |
---|
212 | **/ |
---|
213 | COINLIBAPI void COINLINKAGE |
---|
214 | Cbc_setObjCoeff(Cbc_Model *model, int index, double value); |
---|
215 | |
---|
216 | /** @brief Set the lower bound of a single variable |
---|
217 | * |
---|
218 | * @param model problem object |
---|
219 | * @param index variable index |
---|
220 | * @param value variable lower bound |
---|
221 | **/ |
---|
222 | COINLIBAPI void COINLINKAGE |
---|
223 | Cbc_setColLower(Cbc_Model *model, int index, double value); |
---|
224 | |
---|
225 | /** @brief Set the upper bound of a single variable |
---|
226 | * |
---|
227 | * @param model problem object |
---|
228 | * @param index variable index |
---|
229 | * @param value new variable upper bound |
---|
230 | **/ |
---|
231 | COINLIBAPI void COINLINKAGE |
---|
232 | Cbc_setColUpper(Cbc_Model *model, int index, double value); |
---|
233 | |
---|
234 | /** @brief Set this variable to be continuous |
---|
235 | * |
---|
236 | * @param model problem object |
---|
237 | * @param iColumn column index |
---|
238 | **/ |
---|
239 | COINLIBAPI void COINLINKAGE |
---|
240 | Cbc_setContinuous(Cbc_Model *model, int iColumn); |
---|
241 | |
---|
242 | /** @brief Set this variable to be integer |
---|
243 | * |
---|
244 | * @param model problem object |
---|
245 | * @param iColumn column index |
---|
246 | **/ |
---|
247 | COINLIBAPI void COINLINKAGE |
---|
248 | Cbc_setInteger(Cbc_Model *model, int iColumn); |
---|
249 | |
---|
250 | /** @brief Cbc_Model destructor */ |
---|
251 | COINLIBAPI void COINLINKAGE |
---|
252 | Cbc_deleteModel(Cbc_Model *model); |
---|
253 | |
---|
254 | /** @brief Enter initial feasible solution |
---|
255 | * |
---|
256 | * Enter an initial feasible solution. Only the non-zero main |
---|
257 | * binary/integer decision variables need to be informed. |
---|
258 | * Auxiliary and/or continuous variables are computed |
---|
259 | * automatically. |
---|
260 | * |
---|
261 | * @param model problem object |
---|
262 | * @param count number of variables |
---|
263 | * @param colNames names of variables |
---|
264 | * @param colValues variable values |
---|
265 | * |
---|
266 | **/ |
---|
267 | COINLIBAPI void COINLINKAGE |
---|
268 | Cbc_setMIPStart(Cbc_Model *model, int count, const char **colNames, const double colValues[]); |
---|
269 | |
---|
270 | /** @brief Enter initial feasible solution |
---|
271 | * |
---|
272 | * Enter an initial feasible solution. Only the non-zero main |
---|
273 | * binary/integer decision variables need to be informed. |
---|
274 | * Auxiliary and/or continuous variables are computed |
---|
275 | * automatically. Same as setMIPStart but using variable indexes. |
---|
276 | * |
---|
277 | * @param model problem object |
---|
278 | * @param count number of variables |
---|
279 | * @param colIdxs indexes of variables |
---|
280 | * @param colValues variable values |
---|
281 | * |
---|
282 | **/ |
---|
283 | COINLIBAPI void COINLINKAGE |
---|
284 | Cbc_setMIPStartI(Cbc_Model *model, int count, const int colIdxs[], const double colValues[]); |
---|
285 | |
---|
286 | /** @brief Creates a copy of the current model |
---|
287 | * |
---|
288 | * @param model problem object |
---|
289 | * @return model copy |
---|
290 | **/ |
---|
291 | COINLIBAPI Cbc_Model *COINLINKAGE |
---|
292 | Cbc_clone(Cbc_Model *model); |
---|
293 | |
---|
294 | //@} |
---|
295 | |
---|
296 | /** \name Routines to query problem contents |
---|
297 | */ |
---|
298 | //@{ |
---|
299 | |
---|
300 | /** @brief Queries problem name |
---|
301 | * |
---|
302 | * @param model problem object |
---|
303 | * @param maxNumberCharacters space in string array |
---|
304 | * @param array string where problem name will be saved |
---|
305 | **/ |
---|
306 | COINLIBAPI void COINLINKAGE |
---|
307 | Cbc_problemName(Cbc_Model *model, int maxNumberCharacters, char *array); |
---|
308 | |
---|
309 | /** @brief Number of nonzero elements in constraint matrix |
---|
310 | * |
---|
311 | * @param model problem object |
---|
312 | * @return number of non-zero entries in constraint matrix |
---|
313 | **/ |
---|
314 | COINLIBAPI int COINLINKAGE |
---|
315 | Cbc_getNumElements(Cbc_Model *model); |
---|
316 | |
---|
317 | /** @brief Number of variables in the model |
---|
318 | * @param model problem object |
---|
319 | * @return number of columns (variables) |
---|
320 | **/ |
---|
321 | COINLIBAPI int COINLINKAGE |
---|
322 | Cbc_getNumCols(Cbc_Model *model); |
---|
323 | |
---|
324 | /** @brief Number of integer variables in the model |
---|
325 | * |
---|
326 | * @param model problem object |
---|
327 | * @return number of integer variables in this model |
---|
328 | **/ |
---|
329 | COINLIBAPI int COINLINKAGE |
---|
330 | Cbc_getNumIntegers(Cbc_Model *model); |
---|
331 | |
---|
332 | /** Number of constraints in the model |
---|
333 | * @param model problem object |
---|
334 | * @return number of rows (constraints) in the model |
---|
335 | **/ |
---|
336 | COINLIBAPI int COINLINKAGE |
---|
337 | Cbc_getNumRows(Cbc_Model *model); |
---|
338 | |
---|
339 | /** @brief Queries row name |
---|
340 | * |
---|
341 | * @param model problem object |
---|
342 | * @param row index |
---|
343 | * @param name string where row name will be stored |
---|
344 | * @param string where row name will be stored |
---|
345 | **/ |
---|
346 | COINLIBAPI void COINLINKAGE |
---|
347 | Cbc_getRowName(Cbc_Model *model, int iRow, char *name, size_t maxLength); |
---|
348 | |
---|
349 | /** Queries column name |
---|
350 | * |
---|
351 | * @param model problem object |
---|
352 | * @param iColumn column index |
---|
353 | * @param name where name will be stored |
---|
354 | * @param maxLength maximum length of name string |
---|
355 | **/ |
---|
356 | COINLIBAPI void COINLINKAGE |
---|
357 | Cbc_getColName(Cbc_Model *model, int iColumn, char *name, size_t maxLength); |
---|
358 | |
---|
359 | /** @brief Number of non-zero entries in a row |
---|
360 | * |
---|
361 | * @param model problem object |
---|
362 | * @param row row index |
---|
363 | * @return number of non-zero entries in row |
---|
364 | **/ |
---|
365 | COINLIBAPI int COINLINKAGE |
---|
366 | Cbc_getRowNz(Cbc_Model *model, int row); |
---|
367 | |
---|
368 | /** @brief Indices of variables that appear on a row |
---|
369 | * |
---|
370 | * @param model problem object |
---|
371 | * @param row row index |
---|
372 | * @return vector with indexes of columns that appear on this row |
---|
373 | **/ |
---|
374 | COINLIBAPI const int *COINLINKAGE |
---|
375 | Cbc_getRowIndices(Cbc_Model *model, int row); |
---|
376 | |
---|
377 | /** @brief Coefficients of variables that appear on this row |
---|
378 | * |
---|
379 | * @param model problem object |
---|
380 | * @param row row index |
---|
381 | * @return coefficients of variables that appear on this row |
---|
382 | **/ |
---|
383 | COINLIBAPI const double *COINLINKAGE |
---|
384 | Cbc_getRowCoeffs(Cbc_Model *model, int row); |
---|
385 | |
---|
386 | /** @brief Number of non-zero entries in a column |
---|
387 | * |
---|
388 | * @param model problem object |
---|
389 | * @param col column index |
---|
390 | * @return numbef of rows that this column appears |
---|
391 | **/ |
---|
392 | COINLIBAPI int COINLINKAGE |
---|
393 | Cbc_getColNz(Cbc_Model *model, int col); |
---|
394 | |
---|
395 | /** @brief Indices of rows that a column appears |
---|
396 | * |
---|
397 | * @param model problem object |
---|
398 | * @param col column index |
---|
399 | * @return indices of rows that this column appears |
---|
400 | **/ |
---|
401 | COINLIBAPI const int *COINLINKAGE |
---|
402 | Cbc_getColIndices(Cbc_Model *model, int col); |
---|
403 | |
---|
404 | /** @brief Coefficients that a column appear in rows |
---|
405 | * |
---|
406 | * @param model problem object |
---|
407 | * @param col column index |
---|
408 | * @return coefficients of this column in rows |
---|
409 | **/ |
---|
410 | COINLIBAPI const double *COINLINKAGE |
---|
411 | Cbc_getColCoeffs(Cbc_Model *model, int col); |
---|
412 | |
---|
413 | /** @brief Right hand side of a row |
---|
414 | * |
---|
415 | * @param model problem object |
---|
416 | * @param row row index |
---|
417 | * @return row right hand side |
---|
418 | **/ |
---|
419 | COINLIBAPI double COINLINKAGE |
---|
420 | Cbc_getRowRHS(Cbc_Model *model, int row); |
---|
421 | |
---|
422 | /** @brief Sense a row |
---|
423 | * @param model problem object |
---|
424 | * @param row row index |
---|
425 | * @return row sense: E for =, L for <=, G for >= and R for ranged row |
---|
426 | **/ |
---|
427 | COINLIBAPI char COINLINKAGE |
---|
428 | Cbc_getRowSense(Cbc_Model *model, int row); |
---|
429 | |
---|
430 | /** @brief Direction of optimization |
---|
431 | * |
---|
432 | * @param model problem object |
---|
433 | * @return Direction of optimization (1 - minimize, -1 - maximize, 0 - ignore) |
---|
434 | **/ |
---|
435 | COINLIBAPI double COINLINKAGE |
---|
436 | Cbc_getObjSense(Cbc_Model *model); |
---|
437 | |
---|
438 | /** @brief Constraint lower bounds |
---|
439 | * |
---|
440 | * @param model problem object |
---|
441 | * @return vector with lower bounds of constraints |
---|
442 | **/ |
---|
443 | COINLIBAPI const double *COINLINKAGE |
---|
444 | Cbc_getRowLower(Cbc_Model *model); |
---|
445 | |
---|
446 | /** @brief Constraint upper bounds |
---|
447 | * |
---|
448 | * @param model problem object |
---|
449 | * @return constraint upper bounds |
---|
450 | **/ |
---|
451 | COINLIBAPI const double *COINLINKAGE |
---|
452 | Cbc_getRowUpper(Cbc_Model *model); |
---|
453 | |
---|
454 | /** @brief Objective vector |
---|
455 | * |
---|
456 | * @param model problem object |
---|
457 | * @return vector with coefficients of variables in the objective function |
---|
458 | **/ |
---|
459 | COINLIBAPI const double *COINLINKAGE |
---|
460 | Cbc_getObjCoefficients(Cbc_Model *model); |
---|
461 | |
---|
462 | /** @brief Variable lower bounds |
---|
463 | * |
---|
464 | * @param model problem object |
---|
465 | * @return vector with lower bounds of variables |
---|
466 | **/ |
---|
467 | COINLIBAPI const double *COINLINKAGE |
---|
468 | Cbc_getColLower(Cbc_Model *model); |
---|
469 | |
---|
470 | /** @brief Variable upper bounds |
---|
471 | * |
---|
472 | * @param model problem object |
---|
473 | * @return vector with column upper bounds |
---|
474 | **/ |
---|
475 | COINLIBAPI const double *COINLINKAGE |
---|
476 | Cbc_getColUpper(Cbc_Model *model); |
---|
477 | |
---|
478 | /** @brief Determine whether the ith variable is integer restricted |
---|
479 | * |
---|
480 | * @param model problem object |
---|
481 | * @param i variable index |
---|
482 | * @return 1 if variable is integer, 0 otherwise |
---|
483 | **/ |
---|
484 | COINLIBAPI int COINLINKAGE |
---|
485 | Cbc_isInteger(Cbc_Model *model, int i); |
---|
486 | |
---|
487 | |
---|
488 | //@} |
---|
489 | |
---|
490 | /** \name Routines to load and save problems from disk |
---|
491 | */ |
---|
492 | //@{ |
---|
493 | |
---|
494 | /** @brief Read an mps file from the given filename |
---|
495 | * |
---|
496 | * @param model problem object |
---|
497 | * @param fileName file name |
---|
498 | **/ |
---|
499 | COINLIBAPI int COINLINKAGE |
---|
500 | Cbc_readMps(Cbc_Model *model, const char *filename); |
---|
501 | |
---|
502 | /** @brief Read an lp file from the given filename |
---|
503 | * |
---|
504 | * @param model problem object |
---|
505 | * @param fileName file name |
---|
506 | **/ |
---|
507 | COINLIBAPI int COINLINKAGE |
---|
508 | Cbc_readLp(Cbc_Model *model, const char *filename); |
---|
509 | |
---|
510 | /** @brief Write an mps file from the given filename |
---|
511 | * |
---|
512 | * @param model problem object |
---|
513 | * @param fileName file name |
---|
514 | **/ |
---|
515 | COINLIBAPI void COINLINKAGE |
---|
516 | Cbc_writeMps(Cbc_Model *model, const char *filename); |
---|
517 | |
---|
518 | /** @brief Write an lp file from the given filename |
---|
519 | * |
---|
520 | * @param model problem object |
---|
521 | * @param fileName file name |
---|
522 | **/ |
---|
523 | COINLIBAPI void COINLINKAGE |
---|
524 | Cbc_writeLp(Cbc_Model *model, const char *filename); |
---|
525 | |
---|
526 | //@} |
---|
527 | |
---|
528 | /**@name Getting and setting model data |
---|
529 | Note that problem access and modification methods, |
---|
530 | such as getColLower and setColLower, |
---|
531 | are *not valid* after calling Cbc_solve(). |
---|
532 | Therefore it is not recommended to reuse a Cbc_Model |
---|
533 | object for multiple solves. A workaround is to call Cbc_clone() |
---|
534 | before solving. |
---|
535 | * */ |
---|
536 | /*@{*/ |
---|
537 | |
---|
538 | /** Provide an initial feasible solution to accelerate branch-and-bound |
---|
539 | Note that feasibility of the solution is *not* verified. |
---|
540 | */ |
---|
541 | COINLIBAPI void COINLINKAGE |
---|
542 | Cbc_setInitialSolution(Cbc_Model *model, const double *sol); |
---|
543 | /** "Column start" vector of constraint matrix. Same format as Cbc_loadProblem() */ |
---|
544 | COINLIBAPI const CoinBigIndex *COINLINKAGE |
---|
545 | Cbc_getVectorStarts(Cbc_Model *model); |
---|
546 | /** "Row index" vector of constraint matrix */ |
---|
547 | COINLIBAPI const int *COINLINKAGE |
---|
548 | Cbc_getIndices(Cbc_Model *model); |
---|
549 | /** Coefficient vector of constraint matrix */ |
---|
550 | COINLIBAPI const double *COINLINKAGE |
---|
551 | Cbc_getElements(Cbc_Model *model); |
---|
552 | |
---|
553 | /** Maximum lenght of a row or column name */ |
---|
554 | COINLIBAPI size_t COINLINKAGE |
---|
555 | Cbc_maxNameLength(Cbc_Model *model); |
---|
556 | /** Print the model */ |
---|
557 | COINLIBAPI void COINLINKAGE |
---|
558 | Cbc_printModel(Cbc_Model *model, const char *argPrefix); |
---|
559 | /*@}*/ |
---|
560 | |
---|
561 | /**@name Solver parameters */ |
---|
562 | /*@{*/ |
---|
563 | /** Set parameter "name" to value "value". Note that this |
---|
564 | * translates directly to using "-name value" as a |
---|
565 | * command-line argument to Cbc.*/ |
---|
566 | COINLIBAPI void COINLINKAGE |
---|
567 | Cbc_setParameter(Cbc_Model *model, const char *name, const char *value); |
---|
568 | |
---|
569 | |
---|
570 | /** returns the allowable gap |
---|
571 | */ |
---|
572 | COINLIBAPI double COINLINKAGE |
---|
573 | Cbc_getAllowableGap(Cbc_Model *model); |
---|
574 | |
---|
575 | /** sets the allowable gap |
---|
576 | */ |
---|
577 | COINLIBAPI void COINLINKAGE |
---|
578 | Cbc_setAllowableGap(Cbc_Model *model, double allowedGap); |
---|
579 | |
---|
580 | /** returns the allowable fraction gap |
---|
581 | */ |
---|
582 | COINLIBAPI double COINLINKAGE |
---|
583 | Cbc_getAllowableFractionGap(Cbc_Model *model); |
---|
584 | |
---|
585 | /** sets the allowable fraction gap |
---|
586 | */ |
---|
587 | COINLIBAPI void COINLINKAGE |
---|
588 | Cbc_setAllowableFractionGap(Cbc_Model *model, double allowedFracionGap); |
---|
589 | |
---|
590 | /** returns the allowable percentage gap |
---|
591 | */ |
---|
592 | COINLIBAPI double COINLINKAGE |
---|
593 | Cbc_getAllowablePercentageGap(Cbc_Model *model); |
---|
594 | |
---|
595 | /** sets the allowable percentage gap |
---|
596 | */ |
---|
597 | COINLIBAPI void COINLINKAGE |
---|
598 | Cbc_setAllowablePercentageGap(Cbc_Model *model, double allowedPercentageGap); |
---|
599 | |
---|
600 | /** returns the time limit for the search process |
---|
601 | */ |
---|
602 | COINLIBAPI double COINLINKAGE |
---|
603 | Cbc_getMaximumSeconds(Cbc_Model *model); |
---|
604 | |
---|
605 | /** sets the time limit for the search process |
---|
606 | */ |
---|
607 | COINLIBAPI void COINLINKAGE |
---|
608 | Cbc_setMaximumSeconds(Cbc_Model *model, double maxSeconds); |
---|
609 | |
---|
610 | |
---|
611 | /** returns the maximum number of nodes that can be explored in the search tree |
---|
612 | */ |
---|
613 | COINLIBAPI int COINLINKAGE |
---|
614 | Cbc_getMaximumNodes(Cbc_Model *model); |
---|
615 | |
---|
616 | /** sets the maximum number of nodes that can be explored in the search tree |
---|
617 | */ |
---|
618 | COINLIBAPI void COINLINKAGE |
---|
619 | Cbc_setMaximumNodes(Cbc_Model *model, int maxNodes); |
---|
620 | |
---|
621 | /** returns solution limit for the search process |
---|
622 | */ |
---|
623 | COINLIBAPI int COINLINKAGE |
---|
624 | Cbc_getMaximumSolutions(Cbc_Model *model); |
---|
625 | |
---|
626 | /** sets a solution limit as a stopping criterion |
---|
627 | */ |
---|
628 | COINLIBAPI void COINLINKAGE |
---|
629 | Cbc_setMaximumSolutions(Cbc_Model *model, int maxSolutions); |
---|
630 | |
---|
631 | /** returns the current log leven |
---|
632 | */ |
---|
633 | COINLIBAPI int COINLINKAGE |
---|
634 | Cbc_getLogLevel(Cbc_Model *model); |
---|
635 | |
---|
636 | /** sets the log level |
---|
637 | */ |
---|
638 | COINLIBAPI void COINLINKAGE |
---|
639 | Cbc_setLogLevel(Cbc_Model *model, int logLevel); |
---|
640 | |
---|
641 | |
---|
642 | /** returns the cutoff |
---|
643 | */ |
---|
644 | COINLIBAPI double COINLINKAGE |
---|
645 | Cbc_getCutoff(Cbc_Model *model); |
---|
646 | |
---|
647 | /** sets the cutoff |
---|
648 | */ |
---|
649 | COINLIBAPI void COINLINKAGE |
---|
650 | Cbc_setCutoff(Cbc_Model *model, double cutoff); |
---|
651 | |
---|
652 | |
---|
653 | |
---|
654 | /*@}*/ |
---|
655 | /**@name Message handling. Call backs are handled by ONE function */ |
---|
656 | /*@{*/ |
---|
657 | /** Pass in Callback function. |
---|
658 | Message numbers up to 1000000 are Clp, Coin ones have 1000000 added */ |
---|
659 | COINLIBAPI void COINLINKAGE |
---|
660 | Cbc_registerCallBack(Cbc_Model *model, |
---|
661 | cbc_callback userCallBack); |
---|
662 | |
---|
663 | /** Unset Callback function */ |
---|
664 | COINLIBAPI void COINLINKAGE |
---|
665 | Cbc_clearCallBack(Cbc_Model *model); |
---|
666 | |
---|
667 | COINLIBAPI void COINLINKAGE Cbc_addCutCallback( |
---|
668 | Cbc_Model *model, cbc_cut_callback cutcb, |
---|
669 | const char *name, void *appData ); |
---|
670 | |
---|
671 | COINLIBAPI void COINLINKAGE Cbc_addIncCallback( |
---|
672 | Cbc_Model *model, cbc_incumbent_callback inccb, |
---|
673 | void *appData ); |
---|
674 | |
---|
675 | /*@}*/ |
---|
676 | |
---|
677 | /**@name Solving the model */ |
---|
678 | /*@{*/ |
---|
679 | /* Solve the model with Cbc (using CbcMain1). |
---|
680 | */ |
---|
681 | COINLIBAPI int COINLINKAGE |
---|
682 | Cbc_solve(Cbc_Model *model); |
---|
683 | /*@}*/ |
---|
684 | |
---|
685 | /**@name Accessing the solution and optimization status */ |
---|
686 | /*@{*/ |
---|
687 | |
---|
688 | /** @brief Best feasible solution vector |
---|
689 | * |
---|
690 | * @param model problem object |
---|
691 | * @return vector with best solution found |
---|
692 | **/ |
---|
693 | COINLIBAPI const double *COINLINKAGE |
---|
694 | Cbc_getColSolution(Cbc_Model *model); |
---|
695 | |
---|
696 | |
---|
697 | /** @brief Best known bound on the optimal objective value |
---|
698 | * |
---|
699 | * @param model problem object |
---|
700 | * @return best possible cost (lower bound) |
---|
701 | **/ |
---|
702 | COINLIBAPI double COINLINKAGE |
---|
703 | Cbc_getBestPossibleObjValue(Cbc_Model *model); |
---|
704 | |
---|
705 | /** @brief Best integer feasible solution |
---|
706 | * |
---|
707 | * Best integer feasible solution or NULL if no integer feas sol found |
---|
708 | * |
---|
709 | * @param model problem object |
---|
710 | * @return vector with the best solution found or NULL if no feasible solution was found |
---|
711 | **/ |
---|
712 | COINLIBAPI double *COINLINKAGE |
---|
713 | Cbc_bestSolution(Cbc_Model *model); |
---|
714 | |
---|
715 | /** @brief number of integer feasible solution saved |
---|
716 | * |
---|
717 | * @param model problem object |
---|
718 | * @return number of saved solutions |
---|
719 | **/ |
---|
720 | COINLIBAPI int COINLINKAGE |
---|
721 | Cbc_numberSavedSolutions(Cbc_Model *model); |
---|
722 | |
---|
723 | /** @brief Vector with the i-th saved solution |
---|
724 | * |
---|
725 | * @param model problem object |
---|
726 | * @param whichSol index of the solution to be retrieved |
---|
727 | * @return vector with integer feasible solution |
---|
728 | **/ |
---|
729 | COINLIBAPI const double *COINLINKAGE |
---|
730 | Cbc_savedSolution(Cbc_Model *model, int whichSol); |
---|
731 | |
---|
732 | /** @brief Cost of the whichSol solution |
---|
733 | * |
---|
734 | * @param model problem object |
---|
735 | * @param whichSol solution index |
---|
736 | * @return solution cost |
---|
737 | **/ |
---|
738 | COINLIBAPI double COINLINKAGE |
---|
739 | Cbc_savedSolutionObj(Cbc_Model *model, int whichSol); |
---|
740 | |
---|
741 | /** @brief Queries vector of reduced costs |
---|
742 | * |
---|
743 | * @param model problem object |
---|
744 | * @return reduced cost vector |
---|
745 | **/ |
---|
746 | COINLIBAPI const double *COINLINKAGE |
---|
747 | Cbc_getReducedCost(Cbc_Model *model); |
---|
748 | |
---|
749 | /** If optimization was abandoned due to numerical difficulties |
---|
750 | * |
---|
751 | * @param model problem object |
---|
752 | * @return 1 if numerical difficulties interrupted the optimization, 0 otherwise |
---|
753 | * */ |
---|
754 | COINLIBAPI int COINLINKAGE |
---|
755 | Cbc_isAbandoned(Cbc_Model *model); |
---|
756 | |
---|
757 | /** @brief If the optimal solution was found |
---|
758 | * |
---|
759 | * @param model problem object |
---|
760 | * @return 1 if optimal solution was found, 0 otherwise |
---|
761 | **/ |
---|
762 | COINLIBAPI int COINLINKAGE |
---|
763 | Cbc_isProvenOptimal(Cbc_Model *model); |
---|
764 | |
---|
765 | /** @brief If infeasibility was proven |
---|
766 | * |
---|
767 | * If model is infeasible, please note that infeasibility can also be declared |
---|
768 | * if cutoff is informed and no solution better than the cutoff exists. |
---|
769 | * |
---|
770 | * @param model problem object |
---|
771 | * @return 1 if model is infeasible, 0 otherwise |
---|
772 | **/ |
---|
773 | COINLIBAPI int COINLINKAGE |
---|
774 | Cbc_isProvenInfeasible(Cbc_Model *model); |
---|
775 | |
---|
776 | /** @brief Is continuous model unbounded ? |
---|
777 | * |
---|
778 | * @param model problem object |
---|
779 | * @return 1 if model is unbounded, 0 otherwise |
---|
780 | * */ |
---|
781 | COINLIBAPI int COINLINKAGE |
---|
782 | Cbc_isContinuousUnbounded(Cbc_Model *model); |
---|
783 | |
---|
784 | /** Objective value of best feasible solution |
---|
785 | * |
---|
786 | * @param model problem object |
---|
787 | * @return cost of the best solution found |
---|
788 | * */ |
---|
789 | COINLIBAPI double COINLINKAGE |
---|
790 | Cbc_getObjValue(Cbc_Model *model); |
---|
791 | |
---|
792 | /** @brief Final optimization status |
---|
793 | * |
---|
794 | * Returns the optimization status. For more info check function |
---|
795 | * isProvenOptimal, isProvenInfeasible, etc. Check also secondary status. |
---|
796 | * Possible status are: |
---|
797 | * |
---|
798 | * -1 before branchAndBound |
---|
799 | * 0 finished - check isProvenOptimal or isProvenInfeasible to see if solution found (or check value of best solution) |
---|
800 | * 1 stopped - on maxnodes, maxsols, maxtime |
---|
801 | * 2 execution abandoned due to numerical dificulties |
---|
802 | * 5 user programmed interruption |
---|
803 | * |
---|
804 | * @param model problem object |
---|
805 | * @return problem status |
---|
806 | */ |
---|
807 | COINLIBAPI int COINLINKAGE Cbc_status(Cbc_Model *model); |
---|
808 | |
---|
809 | /** @brief Secondary status of problem |
---|
810 | * |
---|
811 | * Returns additional information regarding the optimization status |
---|
812 | * |
---|
813 | * -1 unset (status_ will also be -1) |
---|
814 | * 0 search completed with solution |
---|
815 | * 1 linear relaxation not feasible (or worse than cutoff) |
---|
816 | * 2 stopped on gap |
---|
817 | * 3 stopped on nodes |
---|
818 | * 4 stopped on time |
---|
819 | * 5 stopped on user event |
---|
820 | * 6 stopped on solutions |
---|
821 | * 7 linear relaxation unbounded |
---|
822 | * 8 stopped on iteration limit |
---|
823 | * |
---|
824 | * @model problem object |
---|
825 | * @return optimization status |
---|
826 | */ |
---|
827 | COINLIBAPI int COINLINKAGE |
---|
828 | Cbc_secondaryStatus(Cbc_Model *model); |
---|
829 | |
---|
830 | /** Sum of primal infeasibilities */ |
---|
831 | COINLIBAPI double COINLINKAGE |
---|
832 | Cbc_sumPrimalInfeasibilities(Cbc_Model *model); |
---|
833 | |
---|
834 | /** Number of primal infeasibilities */ |
---|
835 | COINLIBAPI int COINLINKAGE |
---|
836 | Cbc_numberPrimalInfeasibilities(Cbc_Model *model); |
---|
837 | |
---|
838 | /** Just check solution (for external use) - sets sum of |
---|
839 | infeasibilities etc */ |
---|
840 | COINLIBAPI void COINLINKAGE |
---|
841 | Cbc_checkSolution(Cbc_Model *model); |
---|
842 | |
---|
843 | /** Number of iterations */ |
---|
844 | COINLIBAPI int COINLINKAGE |
---|
845 | Cbc_getIterationCount(Cbc_Model *model); |
---|
846 | |
---|
847 | /** Node limit reached? */ |
---|
848 | COINLIBAPI int COINLINKAGE |
---|
849 | Cbc_isNodeLimitReached(Cbc_Model *model); |
---|
850 | /** Time limit reached? */ |
---|
851 | COINLIBAPI int COINLINKAGE |
---|
852 | Cbc_isSecondsLimitReached(Cbc_Model *model); |
---|
853 | /** Solution limit reached? */ |
---|
854 | COINLIBAPI int COINLINKAGE |
---|
855 | Cbc_isSolutionLimitReached(Cbc_Model *model); |
---|
856 | /** Are there numerical difficulties (for initialSolve) ? */ |
---|
857 | COINLIBAPI int COINLINKAGE |
---|
858 | Cbc_isInitialSolveAbandoned(Cbc_Model *model); |
---|
859 | /** Is optimality proven (for initialSolve) ? */ |
---|
860 | COINLIBAPI int COINLINKAGE |
---|
861 | Cbc_isInitialSolveProvenOptimal(Cbc_Model *model); |
---|
862 | /** Is primal infeasiblity proven (for initialSolve) ? */ |
---|
863 | COINLIBAPI int COINLINKAGE |
---|
864 | Cbc_isInitialSolveProvenPrimalInfeasible(Cbc_Model *model); |
---|
865 | /** "row" solution |
---|
866 | * This is the vector A*x, where A is the constraint matrix |
---|
867 | * and x is the current solution. */ |
---|
868 | COINLIBAPI const double *COINLINKAGE |
---|
869 | Cbc_getRowActivity(Cbc_Model *model); |
---|
870 | /** Number of nodes explored in B&B tree */ |
---|
871 | COINLIBAPI int COINLINKAGE |
---|
872 | Cbc_getNodeCount(Cbc_Model *model); |
---|
873 | /** Print the solution */ |
---|
874 | COINLIBAPI void COINLINKAGE |
---|
875 | Cbc_printSolution(Cbc_Model *model); |
---|
876 | |
---|
877 | /*@}*/ |
---|
878 | |
---|
879 | /** \name OsiSolverInterface related routines (used in callbacks) */ |
---|
880 | //@{ |
---|
881 | |
---|
882 | /** @brief Returns number of cols in OsiSolverInterface object */ |
---|
883 | COINLIBAPI int COINLINKAGE |
---|
884 | Osi_getNumCols( void *osi ); |
---|
885 | |
---|
886 | /** @brief Returns column name in OsiSolverInterface object */ |
---|
887 | COINLIBAPI void COINLINKAGE |
---|
888 | Osi_getColName( void *osi, int i, char *name, int maxLen ); |
---|
889 | |
---|
890 | /** @brief Returns column lower bounds in OsiSolverInterface object */ |
---|
891 | COINLIBAPI const double * COINLINKAGE |
---|
892 | Osi_getColLower( void *osi ); |
---|
893 | |
---|
894 | /** @brief Returns column upper bounds in OsiSolverInterface object */ |
---|
895 | COINLIBAPI const double * COINLINKAGE |
---|
896 | Osi_getColUpper( void *osi ); |
---|
897 | |
---|
898 | /** @brief Returns integrality information for columns in OsiSolverInterface object */ |
---|
899 | COINLIBAPI int COINLINKAGE |
---|
900 | Osi_isInteger( void *osi, int col ); |
---|
901 | |
---|
902 | /** @brief Returns number of rows in OsiSolverInterface object */ |
---|
903 | COINLIBAPI int COINLINKAGE |
---|
904 | Osi_getNumRows( void *osi ); |
---|
905 | |
---|
906 | COINLIBAPI int COINLINKAGE |
---|
907 | Osi_getRowNz(void *osi, int row); |
---|
908 | |
---|
909 | /** @brief Indices of variables that appear on a row */ |
---|
910 | COINLIBAPI const int *COINLINKAGE |
---|
911 | Osi_getRowIndices(void *osi, int row); |
---|
912 | |
---|
913 | /** @brief Coefficients of variables that appear on this row |
---|
914 | * |
---|
915 | * @param model problem object |
---|
916 | * @param row row index |
---|
917 | * @return coefficients of variables that appear on this row |
---|
918 | **/ |
---|
919 | COINLIBAPI const double *COINLINKAGE |
---|
920 | Osi_getRowCoeffs(void *osi, int row); |
---|
921 | |
---|
922 | /** @brief Right hand side of a row |
---|
923 | * |
---|
924 | * @param model problem object |
---|
925 | * @param row row index |
---|
926 | * @return row right hand side |
---|
927 | **/ |
---|
928 | COINLIBAPI double COINLINKAGE |
---|
929 | Osi_getRowRHS(void *osi, int row); |
---|
930 | |
---|
931 | /** @brief Sense a row |
---|
932 | * @param model problem object |
---|
933 | * @param row row index |
---|
934 | * @return row sense: E for =, L for <=, G for >= and R for ranged row |
---|
935 | **/ |
---|
936 | COINLIBAPI char COINLINKAGE |
---|
937 | Osi_getRowSense(void *osi, int row); |
---|
938 | |
---|
939 | /** @brief Returns solution vector in OsiSolverInterface object */ |
---|
940 | COINLIBAPI const double * COINLINKAGE |
---|
941 | Osi_getColSolution( void *osi ); |
---|
942 | |
---|
943 | |
---|
944 | /*@}*/ |
---|
945 | |
---|
946 | /** \name OsiCuts related routines (used in callbacks) */ |
---|
947 | //@{ |
---|
948 | |
---|
949 | /** adds a row cut (used in callback) */ |
---|
950 | COINLIBAPI void COINLINKAGE |
---|
951 | OsiCuts_addRowCut( void *osiCuts, int nz, const int *idx, const double *coef, char sense, double rhs ); |
---|
952 | |
---|
953 | /*@}*/ |
---|
954 | |
---|
955 | #ifdef __cplusplus |
---|
956 | } |
---|
957 | #endif |
---|
958 | #endif |
---|
959 | |
---|
960 | /* vi: softtabstop=2 shiftwidth=2 expandtab tabstop=2 |
---|
961 | */ |
---|