1
/* Copyright (C) 2004 International Business Machines
2
Corporation and others. All Rights Reserved.*/
6
/* include all defines and ugly stuff */
7
#include "Coin_C_defines.h"
9
/** This is a first "C" interface to Cbc.
10
It is mostly similar to the "C" interface to Clp and
11
was contributed by Bob Entriken.
18
/**@name Constructors and destructor
19
These do not have an exact analogue in C++.
20
The user does not need to know structure of Cbc_Model.
22
For all functions outside this group there is an exact C++
23
analogue created by taking the first parameter out, removing the Cbc_
24
from name and applying the method to an object of type ClpSimplex.
29
COINLIBAPI double COINLINKAGE Cbc_getVersion()
31
/** Default Cbc_Model constructor */
32
COINLIBAPI Cbc_Model * COINLINKAGE
35
/** Cbc_Model Destructor */
36
COINLIBAPI void COINLINKAGE
37
Cbc_deleteModel(Cbc_Model * model)
41
/**@name Load model - loads some stuff and initializes others */
43
/* Loads a problem (the constraints on the
44
rows are given by lower and upper bounds). If a pointer is NULL then the
45
following values are the default:
47
<li> <code>colub</code>: all columns have upper bound infinity
48
<li> <code>collb</code>: all columns have lower bound 0
49
<li> <code>rowub</code>: all rows have upper bound infinity
50
<li> <code>rowlb</code>: all rows have lower bound -infinity
51
<li> <code>obj</code>: all variables have 0 objective coefficient
54
Just like the other loadProblem() method except that the matrix is
55
given in a standard column major ordered format (without gaps).
57
COINLIBAPI void COINLINKAGE
58
Cbc_loadProblem (Cbc_Model * model, const int numcols, const int numrows,
59
const CoinBigIndex * start, const int* index,
61
const double* collb, const double* colub,
63
const double* rowlb, const double* rowub)
65
/** Read an mps file from the given filename */
66
COINLIBAPI int COINLINKAGE
67
Cbc_readMps(Cbc_Model * model,const char *filename)
69
/** Write an mps file from the given filename */
70
COINLIBAPI void COINLINKAGE
71
Cbc_writeMps(Cbc_Model * model,const char *filename)
73
/** Integer information */
74
COINLIBAPI char * COINLINKAGE
75
Cbc_integerInformation(Cbc_Model * model)
77
/** Copy in integer information */
78
COINLIBAPI void COINLINKAGE
79
Cbc_copyInIntegerInformation(Cbc_Model * model,const char * information)
81
/** Drop integer informations */
82
COINLIBAPI void COINLINKAGE
83
Cbc_deleteIntegerInformation(Cbc_Model * model)
85
/** Resizes rim part of model */
86
COINLIBAPI void COINLINKAGE
87
Cbc_resize (Cbc_Model * model, int newNumberRows, int newNumberColumns)
90
COINLIBAPI void COINLINKAGE
91
Cbc_deleteRows(Cbc_Model * model, int number, const int * which)
94
COINLIBAPI void COINLINKAGE
95
Cbc_addRows(Cbc_Model * model, const int number, const double * rowLower,
96
const double * rowUpper,
97
const int * rowStarts, const int * columns,
98
const double * elements)
101
/** Deletes columns */
102
COINLIBAPI void COINLINKAGE
103
Cbc_deleteColumns(Cbc_Model * model, int number, const int * which)
106
COINLIBAPI void COINLINKAGE
107
Cbc_addColumns(Cbc_Model * model, int number, const double * columnLower,
108
const double * columnUpper,
109
const double * objective,
110
const int * columnStarts, const int * rows,
111
const double * elements);
112
/** Drops names - makes lengthnames 0 and names empty */
113
COINLIBAPI void COINLINKAGE
114
Cbc_dropNames(Cbc_Model * model)
116
/** Copies in names */
117
COINLIBAPI void COINLINKAGE
118
Cbc_copyNames(Cbc_Model * model, const char * const * rowNamesIn,
119
const char * const * columnNamesIn)
123
/**@name gets and sets - you will find some synonyms at the end of this file */
125
/** Number of rows */
126
COINLIBAPI int COINLINKAGE
127
Cbc_numberRows(Cbc_Model * model)
129
/** Number of columns */
130
COINLIBAPI int COINLINKAGE
131
Cbc_numberColumns(Cbc_Model * model)
133
/** Primal tolerance to use */
134
COINLIBAPI double COINLINKAGE
135
Cbc_primalTolerance(Cbc_Model * model)
137
COINLIBAPI void COINLINKAGE
138
Cbc_setPrimalTolerance(Cbc_Model * model, double value)
140
/** Dual tolerance to use */
141
COINLIBAPI double COINLINKAGE
142
Cbc_dualTolerance(Cbc_Model * model)
144
COINLIBAPI void COINLINKAGE
145
Cbc_setDualTolerance(Cbc_Model * model, double value)
147
/* Integer tolerance to use */
148
COINLIBAPI double COINLINKAGE
149
Cbc_integerTolerance(Cbc_Model * model)
151
COINLIBAPI void COINLINKAGE
152
Cbc_setIntegerTolerance(Cbc_Model * model, double value)
154
/** Dual objective limit */
155
COINLIBAPI double COINLINKAGE
156
Cbc_dualObjectiveLimit(Cbc_Model * model)
158
COINLIBAPI void COINLINKAGE
159
Cbc_setDualObjectiveLimit(Cbc_Model * model, double value)
161
/** Objective offset */
162
COINLIBAPI double COINLINKAGE
163
Cbc_objectiveOffset(Cbc_Model * model)
165
COINLIBAPI void COINLINKAGE
166
Cbc_setObjectiveOffset(Cbc_Model * model, double value)
168
/** Fills in array with problem name */
169
COINLIBAPI void COINLINKAGE
170
Cbc_problemName(Cbc_Model * model, int maxNumberCharacters, char * array)
172
/** Sets problem name. Must have \0 at end. */
173
COINLIBAPI int COINLINKAGE
174
Cbc_setProblemName(Cbc_Model * model, int maxNumberCharacters, char * array)
176
/** Number of iterations */
177
COINLIBAPI int COINLINKAGE
178
Cbc_numberIterations(Cbc_Model * model)
180
COINLIBAPI void COINLINKAGE
181
Cbc_setNumberIterations(Cbc_Model * model, int numberIterations)
183
/** Maximum number of iterations */
184
COINLIBAPI int COINLINKAGE
185
Cbc_maximumIterations(Cbc_Model * model)
187
COINLIBAPI void COINLINKAGE
188
Cbc_setMaximumIterations(Cbc_Model * model, int value)
190
/** Maximum number of nodes */
191
COINLIBAPI int COINLINKAGE
192
Cbc_maxNumNode(Cbc_Model * model)
194
COINLIBAPI void COINLINKAGE
195
Cbc_setMaxNumNode(Cbc_Model * model, int value)
197
/* Maximum number of solutions */
198
COINLIBAPI int COINLINKAGE
199
Cbc_maxNumSol(Cbc_Model * model)
201
COINLIBAPI void COINLINKAGE
202
Cbc_setMaxNumSol(Cbc_Model * model, int value)
204
/** Maximum time in seconds (from when set called) */
205
COINLIBAPI double COINLINKAGE
206
Cbc_maximumSeconds(Cbc_Model * model)
208
COINLIBAPI void COINLINKAGE
209
Cbc_setMaximumSeconds(Cbc_Model * model, double value)
211
/** Returns true if hit maximum iterations (or time) */
212
COINLIBAPI int COINLINKAGE
213
Cbc_hitMaximumIterations(Cbc_Model * model)
215
/** Status of problem:
217
1 - primal infeasible
219
3 - stopped on iterations etc
220
4 - stopped due to errors
222
COINLIBAPI int COINLINKAGE
223
Cbc_status(Cbc_Model * model)
225
/** Set problem status */
226
COINLIBAPI void COINLINKAGE
227
Cbc_setProblemStatus(Cbc_Model * model, int problemStatus)
229
/** Secondary status of problem - may get extended
231
1 - primal infeasible because dual limit reached
232
2 - scaled problem optimal - unscaled has primal infeasibilities
233
3 - scaled problem optimal - unscaled has dual infeasibilities
234
4 - scaled problem optimal - unscaled has both dual and primal infeasibilities
236
COINLIBAPI int COINLINKAGE
237
Cbc_secondaryStatus(Cbc_Model * model)
239
COINLIBAPI void COINLINKAGE
240
Cbc_setSecondaryStatus(Cbc_Model * model, int status)
242
/** Direction of optimization (1 - minimize, -1 - maximize, 0 - ignore */
243
COINLIBAPI double COINLINKAGE
244
Cbc_optimizationDirection(Cbc_Model * model)
246
COINLIBAPI void COINLINKAGE
247
Cbc_setOptimizationDirection(Cbc_Model * model, double value)
249
/** Primal row solution */
250
COINLIBAPI double * COINLINKAGE
251
Cbc_primalRowSolution(Cbc_Model * model)
253
/** Primal column solution */
254
COINLIBAPI double * COINLINKAGE
255
Cbc_primalColumnSolution(Cbc_Model * model)
257
/** Dual row solution */
258
COINLIBAPI double * COINLINKAGE
259
Cbc_dualRowSolution(Cbc_Model * model)
262
COINLIBAPI double * COINLINKAGE
263
Cbc_dualColumnSolution(Cbc_Model * model)
266
COINLIBAPI double* COINLINKAGE
267
Cbc_rowLower(Cbc_Model * model)
270
COINLIBAPI double* COINLINKAGE
271
Cbc_rowUpper(Cbc_Model * model)
274
COINLIBAPI double * COINLINKAGE
275
Cbc_objective(Cbc_Model * model)
278
COINLIBAPI double * COINLINKAGE
279
Cbc_columnLower(Cbc_Model * model)
282
COINLIBAPI double * COINLINKAGE
283
Cbc_columnUpper(Cbc_Model * model)
285
/** Number of elements in matrix */
286
COINLIBAPI int COINLINKAGE
287
Cbc_getNumElements(Cbc_Model * model)
289
/** Column starts in matrix */
290
COINLIBAPI const CoinBigIndex * COINLINKAGE
291
Cbc_getVectorStarts(Cbc_Model * model)
293
/** Row indices in matrix */
294
COINLIBAPI const int * COINLINKAGE
295
Cbc_getIndices(Cbc_Model * model)
297
/** Column vector lengths in matrix */
298
COINLIBAPI const int * COINLINKAGE
299
Cbc_getVectorLengths(Cbc_Model * model)
301
/** Element values in matrix */
302
COINLIBAPI const double * COINLINKAGE
303
Cbc_getElements(Cbc_Model * model)
305
/** Objective value */
306
COINLIBAPI double COINLINKAGE
307
Cbc_objectiveValue(Cbc_Model * model)
309
/** Infeasibility/unbounded ray (NULL returned if none/wrong)
310
Up to user to use delete [] on these arrays. */
311
COINLIBAPI double * COINLINKAGE
312
Cbc_infeasibilityRay(Cbc_Model * model)
314
COINLIBAPI double * COINLINKAGE
315
Cbc_unboundedRay(Cbc_Model * model)
317
/** See if status array exists (partly for OsiClp) */
318
COINLIBAPI int COINLINKAGE
319
Cbc_statusExists(Cbc_Model * model)
321
/** Return address of status array (char[numberRows+numberColumns]) */
322
COINLIBAPI void COINLINKAGE
323
Cbc_getBasisStatus(Cbc_Model * model, int * cstat, int * rstat)
325
/** Copy in status vector */
326
COINLIBAPI void COINLINKAGE
327
Cbc_setBasisStatus(Cbc_Model * model, int * cstat, int * rstat)
330
/** User pointer for whatever reason */
331
COINLIBAPI void COINLINKAGE
332
Cbc_setUserPointer (Cbc_Model * model, void * pointer)
334
COINLIBAPI void * COINLINKAGE
335
Cbc_getUserPointer (Cbc_Model * model)
338
/**@name Message handling. Call backs are handled by ONE function */
340
/** Pass in Callback function.
341
Message numbers up to 1000000 are Clp, Coin ones have 1000000 added */
342
COINLIBAPI void COINLINKAGE
343
Cbc_registerCallBack(Cbc_Model * model,
344
cbc_callback userCallBack)
346
/** Unset Callback function */
347
COINLIBAPI void COINLINKAGE
348
Cbc_clearCallBack(Cbc_Model * model)
350
/** Amount of print out:
353
2 - just factorizations
354
3 - as 2 plus a bit more
356
above that 8,16,32 etc just for selective debug
358
COINLIBAPI void COINLINKAGE
359
Cbc_setLogLevel(Cbc_Model * model, int value)
361
COINLIBAPI int COINLINKAGE
362
Cbc_logLevel(Cbc_Model * model)
364
/** length of names (0 means no names0 */
365
COINLIBAPI int COINLINKAGE
366
Cbc_lengthNames(Cbc_Model * model)
368
/** Fill in array (at least lengthNames+1 long) with a row name */
369
COINLIBAPI void COINLINKAGE
370
Cbc_rowName(Cbc_Model * model, int iRow, char * name)
372
/** Fill in array (at least lengthNames+1 long) with a column name */
373
COINLIBAPI void COINLINKAGE
374
Cbc_columnName(Cbc_Model * model, int iColumn, char * name)
380
/**@name Functions most useful to user */
382
/** General solve algorithm which can do presolve.
383
See ClpSolve.hpp for options
385
COINLIBAPI int COINLINKAGE
386
Cbc_initialSolve(Cbc_Model * model)
388
/* General solve algorithm which can do presolve.
389
See CbcModel.hpp for options
391
COINLIBAPI int COINLINKAGE
392
Cbc_branchAndBound(Cbc_Model * model)
394
/** Sets or unsets scaling, 0 -off, 1 equilibrium, 2 geometric, 3, auto, 4 dynamic(later) */
395
COINLIBAPI void COINLINKAGE
396
Cbc_scaling(Cbc_Model * model, int mode)
398
/** Gets scalingFlag */
399
COINLIBAPI int COINLINKAGE
400
Cbc_scalingFlag(Cbc_Model * model)
402
/** Crash - at present just aimed at dual, returns
403
-2 if dual preferred and crash basis created
404
-1 if dual preferred and all slack basis preferred
405
0 if basis going in was not all slack
406
1 if primal preferred and all slack basis preferred
407
2 if primal preferred and crash basis created.
409
if gap between bounds <="gap" variables can be flipped
412
0 No pivoting (so will just be choice of algorithm)
413
1 Simple pivoting e.g. gub
416
COINLIBAPI int COINLINKAGE
417
Cbc_crash(Cbc_Model * model, double gap,int pivot)
422
/**@name most useful gets and sets */
424
/** If problem is primal feasible */
425
COINLIBAPI int COINLINKAGE
426
Cbc_primalFeasible(Cbc_Model * model)
428
/** If problem is dual feasible */
429
COINLIBAPI int COINLINKAGE
430
Cbc_dualFeasible(Cbc_Model * model)
433
COINLIBAPI double COINLINKAGE
434
Cbc_dualBound(Cbc_Model * model)
436
COINLIBAPI void COINLINKAGE
437
Cbc_setDualBound(Cbc_Model * model, double value)
439
/** Infeasibility cost */
440
COINLIBAPI double COINLINKAGE
441
Cbc_infeasibilityCost(Cbc_Model * model)
443
COINLIBAPI void COINLINKAGE
444
Cbc_setInfeasibilityCost(Cbc_Model * model, double value)
447
50 - switch on perturbation
448
100 - auto perturb if takes too long (1.0e-6 largest nonzero)
449
101 - we are perturbed
450
102 - don't try perturbing again
452
others are for playing
454
COINLIBAPI int COINLINKAGE
455
Cbc_perturbation(Cbc_Model * model)
457
COINLIBAPI void COINLINKAGE
458
Cbc_setPerturbation(Cbc_Model * model, int value)
460
/** Current (or last) algorithm */
461
COINLIBAPI int COINLINKAGE
462
Cbc_algorithm(Cbc_Model * model)
465
COINLIBAPI void COINLINKAGE
466
Cbc_setAlgorithm(Cbc_Model * model, int value)
468
/** Sum of dual infeasibilities */
469
COINLIBAPI double COINLINKAGE
470
Cbc_sumDualInfeasibilities(Cbc_Model * model)
472
/** Number of dual infeasibilities */
473
COINLIBAPI int COINLINKAGE
474
Cbc_numberDualInfeasibilities(Cbc_Model * model)
476
/** Sum of primal infeasibilities */
477
COINLIBAPI double COINLINKAGE
478
Cbc_sumPrimalInfeasibilities(Cbc_Model * model)
480
/** Number of primal infeasibilities */
481
COINLIBAPI int COINLINKAGE
482
Cbc_numberPrimalInfeasibilities(Cbc_Model * model)
484
/** Save model to file, returns 0 if success. This is designed for
485
use outside algorithms so does not save iterating arrays etc.
486
It does not save any messaging information.
487
Does not save scaling values.
488
It does not know about all types of virtual functions.
490
COINLIBAPI int COINLINKAGE
491
Cbc_saveModel(Cbc_Model * model, const char * fileName)
493
/** Restore model from file, returns 0 if success,
494
deletes current model */
495
COINLIBAPI int COINLINKAGE
496
Cbc_restoreModel(Cbc_Model * model, const char * fileName)
499
/** Just check solution (for external use) - sets sum of
500
infeasibilities etc */
501
COINLIBAPI void COINLINKAGE
502
Cbc_checkSolution(Cbc_Model * model)
506
/******************** End of most useful part **************/
507
/**@name gets and sets - some synonyms */
509
/** Number of rows */
510
COINLIBAPI int COINLINKAGE
511
Cbc_getNumRows(Cbc_Model * model)
513
/** Number of columns */
514
COINLIBAPI int COINLINKAGE
515
Cbc_getNumCols(Cbc_Model * model)
517
/** Number of iterations */
518
COINLIBAPI int COINLINKAGE
519
Cbc_getIterationCount(Cbc_Model * model)
521
/** Are there a numerical difficulties? */
522
COINLIBAPI int COINLINKAGE
523
Cbc_isAbandoned(Cbc_Model * model)
525
/** Is optimality proven? */
526
COINLIBAPI int COINLINKAGE
527
Cbc_isProvenOptimal(Cbc_Model * model)
529
/** Is primal infeasiblity proven? */
530
COINLIBAPI int COINLINKAGE
531
Cbc_isProvenPrimalInfeasible(Cbc_Model * model)
533
/** Is dual infeasiblity proven? */
534
COINLIBAPI int COINLINKAGE
535
Cbc_isProvenDualInfeasible(Cbc_Model * model)
537
/** Is the given primal objective limit reached? */
538
COINLIBAPI int COINLINKAGE
539
Cbc_isPrimalObjectiveLimitReached(Cbc_Model * model)
541
/** Is the given dual objective limit reached? */
542
COINLIBAPI int COINLINKAGE
543
Cbc_isDualObjectiveLimitReached(Cbc_Model * model)
545
/** Iteration limit reached? */
546
COINLIBAPI int COINLINKAGE
547
Cbc_isIterationLimitReached(Cbc_Model * model)
549
/** Direction of optimization (1 - minimize, -1 - maximize, 0 - ignore */
550
COINLIBAPI double COINLINKAGE
551
Cbc_getObjSense(Cbc_Model * model)
553
/** Primal row solution */
554
COINLIBAPI const double * COINLINKAGE
555
Cbc_getRowActivity(Cbc_Model * model)
557
/** Primal column solution */
558
COINLIBAPI const double * COINLINKAGE
559
Cbc_getColSolution(Cbc_Model * model)
561
COINLIBAPI void COINLINKAGE
562
Cbc_setColSolution(Cbc_Model * model, const double * input)
564
/** Dual row solution */
565
COINLIBAPI const double * COINLINKAGE
566
Cbc_getRowPrice(Cbc_Model * model)
569
COINLIBAPI const double * COINLINKAGE
570
Cbc_getReducedCost(Cbc_Model * model)
573
COINLIBAPI const double* COINLINKAGE
574
Cbc_getRowLower(Cbc_Model * model)
577
COINLIBAPI const double* COINLINKAGE
578
Cbc_getRowUpper(Cbc_Model * model)
581
COINLIBAPI const double * COINLINKAGE
582
Cbc_getObjCoefficients(Cbc_Model * model)
585
COINLIBAPI const double * COINLINKAGE
586
Cbc_getColLower(Cbc_Model * model)
589
COINLIBAPI const double * COINLINKAGE
590
Cbc_getColUpper(Cbc_Model * model)
592
/** Objective value */
593
COINLIBAPI double COINLINKAGE
594
Cbc_getObjValue(Cbc_Model * model)
596
/** Print the model */
597
COINLIBAPI void COINLINKAGE
598
Cbc_printModel(Cbc_Model * model, const char * argPrefix)
600
/** Determine whether the variable at location i is integer restricted */
601
COINLIBAPI int COINLINKAGE
602
Cbc_isInteger(Cbc_Model * model, int i)
604
/** Return CPU time */
605
COINLIBAPI double COINLINKAGE
606
Cbc_cpuTime(Cbc_Model * model)
608
/** Number of nodes explored in B&B tree */
609
COINLIBAPI int COINLINKAGE
610
Cbc_getNodeCount(Cbc_Model * model)
612
/** Return a copy of this model */
613
COINLIBAPI Cbc_Model * COINLINKAGE
614
Cbc_clone(Cbc_Model * model)
616
/** Set this the variable to be continuous */
617
COINLIBAPI Cbc_Model * COINLINKAGE
618
Cbc_setContinuous(Cbc_Model * model, int iColumn)
620
/** Add SOS constraints to the model using dense matrix */
621
COINLIBAPI void COINLINKAGE
622
Cbc_addSOS_Dense(Cbc_Model * model, int numObjects, const int * len,
623
const int ** which, const double * weights, const int type)
625
/** Add SOS constraints to the model using row-order matrix */
626
COINLIBAPI void COINLINKAGE
627
Cbc_addSOS_Sparse(Cbc_Model * model, const int * rowStarts,
628
const int * rowIndices, const double * weights, const int type)
630
/** Delete all object information */
631
COINLIBAPI void COINLINKAGE
632
Cbc_deleteObjects(Cbc_Model * model)
634
/** Print the solution */
635
COINLIBAPI void COINLINKAGE
636
Cbc_printSolution(Cbc_Model * model)
638
/** Dual initial solve */
639
COINLIBAPI int COINLINKAGE
640
Cbc_initialDualSolve(Cbc_Model * model)
642
/** Primal initial solve */
643
COINLIBAPI int COINLINKAGE
644
Cbc_initialPrimalSolve(Cbc_Model * model)
646
/** Dual algorithm - see ClpSimplexDual.hpp for method */
647
COINLIBAPI int COINLINKAGE
648
Cbc_dual(Cbc_Model * model, int ifValuesPass)
650
/** Primal algorithm - see ClpSimplexPrimal.hpp for method */
651
COINLIBAPI int COINLINKAGE
652
Cbc_primal(Cbc_Model * model, int ifValuesPass)