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