Changeset 2457
 Timestamp:
 Dec 30, 2018 1:35:23 PM (4 months ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/Cbc/src/Cbc_C_Interface.h
r2453 r2457 14 14 15 15 /* 16 * Original ver ison contributed by Bob Entriken,16 * Original version contributed by Bob Entriken, 17 17 * significantly updated by Miles Lubin. 18 */ 18 * 2018: several updates by Haroldo 19 */ 19 20 20 21 … … 23 24 #endif 24 25 25 /**@name Constructors and destructor 26 This is a "C" interface to Cbc. 27 The user does not need to know structure of Cbc_Model. 28 */ 29 /*@{*/ 30 31 /** Default Cbc_Model constructor */ 26 /** Current version of Cbc */ 27 COINLIBAPI const char* COINLINKAGE Cbc_getVersion(void) 28 ; 29 30 /** \name Problem creation and modification routines */ 31 //@{ 32 33 /** @brief Creates an empty problem */ 32 34 COINLIBAPI Cbc_Model * COINLINKAGE 33 35 Cbc_newModel(void) 34 36 ; 35 /** Cbc_Model Destructor */ 36 COINLIBAPI void COINLINKAGE 37 Cbc_deleteModel(Cbc_Model * model) 38 ; 39 /** Current version of Cbc */ 40 COINLIBAPI const char* COINLINKAGE Cbc_getVersion(void) 41 ; 42 /*@}*/ 43 44 /**@name Getting and setting model data 45 Note that problem access and modification methods, 46 such as getColLower and setColLower, 47 are *not valid* after calling Cbc_solve(). 48 Therefore it is not recommended to reuse a Cbc_Model 49 object for multiple solves. A workaround is to call Cbc_clone() 50 before solving. 37 38 /** @brief Sets problem name. 39 * 40 * @param model problem object 41 * @param array string with problem name 42 **/ 43 COINLIBAPI int COINLINKAGE 44 Cbc_setProblemName(Cbc_Model * model, const char *array) 45 ; 46 47 /** @brief Creates a new column 48 * 49 * Creates a new column (variable) 50 * 51 * @param model problem object 52 * @param name variable name 53 * @param lb column lower bound 54 * @param ub column upper bound 55 * @param obj objective function coefficient 56 * @param isInteger 1 if variable is integral, 0 otherwise 57 * @param nz number of rows (constraints) where this column appears, can be 0 if constraints will be added later 58 * @param rows index of rows where this column appears, NULL if rows will be added later 59 * @param coefs coefficients that this column appears in its rows, NULL if rows will be added later 60 ***/ 61 COINLIBAPI void COINLINKAGE 62 Cbc_addCol( Cbc_Model *model, const char *name, double lb, 63 double ub, double obj, char isInteger, 64 int nz, int *rows, double *coefs ) 65 ; 66 67 /** @brief Adds a new row 68 * 69 * Adds a new row (linear constraint) to the problem 70 * 71 * @param model problem object 72 * @param name constraint name 73 * @param nz number of variables with nonzero coefficients in this row 74 * @param cols index of variables that appear in this row 75 * @param coefs cofficients that that variables appear 76 * @param sense constraint sense: L if <=, G if >=, E if =, R if ranged and N if free 77 * @param rhs right hand size 51 78 * */ 52 /*@{*/ 79 COINLIBAPI void COINLINKAGE 80 Cbc_addRow( Cbc_Model *model, const char *name, int nz, 81 const int *cols, const double *coefs, char sense, double rhs ) 82 ; 83 84 /** @brief Add SOS constraints to the model using roworder matrix */ 85 COINLIBAPI void COINLINKAGE 86 Cbc_addSOS(Cbc_Model * model, int numRows, const int * rowStarts, 87 const int * colIndices, const double * weights, const int type) 88 ; 89 90 53 91 /** Loads a problem (the constraints on the 54 92 rows are given by lower and upper bounds). If a pointer is NULL then the … … 78 116 const double* rowlb, const double* rowub) 79 117 ; 80 /** Read an mps file from the given filename */ 118 119 /** @brief Set the name of a column 120 * 121 * @param model problem object 122 * @param iColumn column index 123 * @param column name 124 **/ 125 COINLIBAPI void COINLINKAGE 126 Cbc_setColName(Cbc_Model * model, int iColumn, const char * name) 127 ; 128 129 /** @brief Set the name of a row 130 * 131 * @param model problem object 132 * @param iRow row index 133 * @param name row name 134 **/ 135 COINLIBAPI void COINLINKAGE 136 Cbc_setRowName(Cbc_Model * model, int iRow, const char * name) 137 ; 138 139 /** @brief Sets optimization direction 140 * 141 * @param model problem object 142 * @param sense: direction of optimization (1  minimize, 1  maximize, 0  ignore) 143 **/ 144 COINLIBAPI void COINLINKAGE 145 Cbc_setObjSense(Cbc_Model * model, double sense) 146 ; 147 148 /** @brief Set the lower bound of a single constraint 149 * 150 * @param model problem object 151 * @param index row index 152 * @param value new row lower bound 153 **/ 154 COINLIBAPI void COINLINKAGE 155 Cbc_setRowLower(Cbc_Model * model, int index, double value) 156 ; 157 158 /** @brief Set the upper bound of a single constraint 159 * 160 * @param model problem object 161 * @param index row index 162 * @param value new row upper bound 163 **/ 164 COINLIBAPI void COINLINKAGE 165 Cbc_setRowUpper(Cbc_Model * model, int index, double value) 166 ; 167 168 /** @brief Set the objective coefficient of a single variable 169 * 170 * @param model problem object 171 * @param index variable index 172 * @param value new objective function coefficient for this variable 173 **/ 174 COINLIBAPI void COINLINKAGE 175 Cbc_setObjCoeff(Cbc_Model * model, int index, double value) 176 ; 177 178 /** @brief Set the lower bound of a single variable 179 * 180 * @param model problem object 181 * @param index variable index 182 * @param value variable lower bound 183 **/ 184 COINLIBAPI void COINLINKAGE 185 Cbc_setColLower(Cbc_Model * model, int index, double value) 186 ; 187 188 /** @brief Set the upper bound of a single variable 189 * 190 * @param model problem object 191 * @param index variable index 192 * @param value new variable upper bound 193 **/ 194 COINLIBAPI void COINLINKAGE 195 Cbc_setColUpper(Cbc_Model * model, int index, double value) 196 ; 197 198 /** @brief Set this variable to be continuous 199 * 200 * @param model problem object 201 * @param iColumn column index 202 **/ 203 COINLIBAPI void COINLINKAGE 204 Cbc_setContinuous(Cbc_Model * model, int iColumn) 205 ; 206 207 /** @brief Set this variable to be integer 208 * 209 * @param model problem object 210 * @param iColumn column index 211 **/ 212 COINLIBAPI void COINLINKAGE 213 Cbc_setInteger(Cbc_Model * model, int iColumn) 214 ; 215 216 /** @brief Cbc_Model destructor */ 217 COINLIBAPI void COINLINKAGE 218 Cbc_deleteModel(Cbc_Model * model) 219 ; 220 221 //@} 222 223 /** \name Routines to query problem contents 224 */ 225 //@{ 226 227 228 /** @brief Queries problem name 229 * 230 * @param model problem object 231 * @param maxNumberCharacters space in string array 232 * @param array string where problem name will be saved 233 **/ 234 COINLIBAPI void COINLINKAGE 235 Cbc_problemName(Cbc_Model * model, int maxNumberCharacters, char * array) 236 ; 237 238 /** @brief Number of nonzero elements in constraint matrix 239 * 240 * @param model problem object 241 * @return number of nonzero entries in constraint matrix 242 **/ 243 COINLIBAPI int COINLINKAGE 244 Cbc_getNumElements(Cbc_Model * model) 245 ; 246 247 /** @brief Number of variables in the model 248 * @param model problem object 249 * @return number of columns (variables) 250 **/ 251 COINLIBAPI int COINLINKAGE 252 Cbc_getNumCols(Cbc_Model * model) 253 ; 254 255 /** @brief Number of integer variables in the model 256 * 257 * @param model problem object 258 * @return number of integer variables in this model 259 **/ 260 COINLIBAPI int COINLINKAGE 261 Cbc_getNumIntegers(Cbc_Model * model) 262 ; 263 264 /** Number of constraints in the model 265 * @param model problem object 266 * @return number of rows (constraints) in the model 267 **/ 268 COINLIBAPI int COINLINKAGE 269 Cbc_getNumRows(Cbc_Model * model) 270 ; 271 272 /** @brief Queries row name 273 * 274 * @param model problem object 275 * @param row index 276 * @param name string where row name will be stored 277 * @param string where row name will be stored 278 **/ 279 COINLIBAPI void COINLINKAGE 280 Cbc_getRowName(Cbc_Model * model, int iRow, char * name, size_t maxLength) 281 ; 282 283 /** Queries column name 284 * 285 * @param model problem object 286 * @param iColumn column index 287 * @param name where name will be stored 288 * @param maxLength maximum length of name string 289 **/ 290 COINLIBAPI void COINLINKAGE 291 Cbc_getColName(Cbc_Model * model, int iColumn, char * name, size_t maxLength) 292 ; 293 294 /** @brief Number of nonzero entries in a row 295 * 296 * @param model problem object 297 * @param row row index 298 * @return number of nonzero entries in row 299 **/ 300 COINLIBAPI int COINLINKAGE 301 Cbc_getRowNz(Cbc_Model * model, int row) 302 ; 303 304 /** @brief Indices of variables that appear on a row 305 * 306 * @param model problem object 307 * @param row row index 308 * @return vector with indexes of columns that appear on this row 309 **/ 310 COINLIBAPI const int * COINLINKAGE 311 Cbc_getRowIndices(Cbc_Model * model, int row) 312 ; 313 314 /** @brief Coefficients of variables that appear on this row 315 * 316 * @param model problem object 317 * @param row row index 318 * @return coefficients of variables that appear on this row 319 **/ 320 COINLIBAPI const double * COINLINKAGE 321 Cbc_getRowCoeffs(Cbc_Model * model, int row) 322 ; 323 324 /** @brief Number of nonzero entries in a column 325 * 326 * @param model problem object 327 * @param col column index 328 * @return numbef of rows that this column appears 329 **/ 330 COINLIBAPI int COINLINKAGE 331 Cbc_getColNz(Cbc_Model * model, int col) 332 ; 333 334 /** @brief Indices of rows that a column appears 335 * 336 * @param model problem object 337 * @param col column index 338 * @return indices of rows that this column appears 339 **/ 340 COINLIBAPI const int * COINLINKAGE 341 Cbc_getColIndices(Cbc_Model * model, int col) 342 ; 343 344 /** @brief Coefficients that a column appear in rows 345 * 346 * @param model problem object 347 * @param col column index 348 * @return coefficients of this column in rows 349 **/ 350 COINLIBAPI const double * COINLINKAGE 351 Cbc_getColCoeffs(Cbc_Model * model, int col) 352 ; 353 354 /** @brief Right hand side of a row 355 * 356 * @param model problem object 357 * @param row row index 358 * @return row right hand side 359 **/ 360 COINLIBAPI double COINLINKAGE 361 Cbc_getRowRHS(Cbc_Model * model, int row) 362 ; 363 364 /** @brief Sense a row 365 * @param model problem object 366 * @param row row index 367 * @return row sense: E for =, L for <=, G for >= and R for ranged row 368 **/ 369 COINLIBAPI char COINLINKAGE 370 Cbc_getRowSense(Cbc_Model * model, int row) 371 ; 372 373 /** @brief Direction of optimization 374 * 375 * @param model problem object 376 * @return Direction of optimization (1  minimize, 1  maximize, 0  ignore) 377 **/ 378 COINLIBAPI double COINLINKAGE 379 Cbc_getObjSense(Cbc_Model * model) 380 ; 381 382 /** @brief Constraint lower bounds 383 * 384 * @param model problem object 385 * @return vector with lower bounds of constraints 386 **/ 387 COINLIBAPI const double* COINLINKAGE 388 Cbc_getRowLower(Cbc_Model * model) 389 ; 390 391 /** @brief Constraint upper bounds 392 * 393 * @param model problem object 394 * @return constraint upper bounds 395 **/ 396 COINLIBAPI const double* COINLINKAGE 397 Cbc_getRowUpper(Cbc_Model * model) 398 ; 399 400 /** @brief Objective vector 401 * 402 * @param model problem object 403 * @return vector with coefficients of variables in the objective function 404 **/ 405 COINLIBAPI const double * COINLINKAGE 406 Cbc_getObjCoefficients(Cbc_Model * model) 407 ; 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 418 /** @brief Variable upper bounds 419 * 420 * @param model problem object 421 * @return vector with column upper bounds 422 **/ 423 COINLIBAPI const double * COINLINKAGE 424 Cbc_getColUpper(Cbc_Model * model) 425 ; 426 427 /** @brief Determine whether the ith variable is integer restricted 428 * 429 * @param model problem object 430 * @param i variable index 431 * @return 1 if variable is integer, 0 otherwise 432 **/ 433 COINLIBAPI int COINLINKAGE 434 Cbc_isInteger(Cbc_Model * model, int i) 435 ; 436 437 //@} 438 439 /** \name Routines to load and save problems from disk 440 */ 441 //@{ 442 443 444 /** @brief Read an mps file from the given filename 445 * 446 * @param model problem object 447 * @param fileName file name 448 **/ 81 449 COINLIBAPI int COINLINKAGE 82 450 Cbc_readMps(Cbc_Model * model, const char *filename) 83 451 ; 84 /** Read an lp file from the given filename */ 452 453 /** @brief Read an lp file from the given filename 454 * 455 * @param model problem object 456 * @param fileName file name 457 **/ 85 458 COINLIBAPI int COINLINKAGE 86 459 Cbc_readLp(Cbc_Model * model, const char *filename) 87 460 ; 88 /** Write an mps file from the given filename */ 461 462 /** @brief Write an mps file from the given filename 463 * 464 * @param model problem object 465 * @param fileName file name 466 **/ 89 467 COINLIBAPI void COINLINKAGE 90 468 Cbc_writeMps(Cbc_Model * model, const char *filename) 91 469 ; 92 /** Write an lp file from the given filename */ 470 471 /** @brief Write an lp file from the given filename 472 * 473 * @param model problem object 474 * @param fileName file name 475 **/ 93 476 COINLIBAPI void COINLINKAGE 94 477 Cbc_writeLp(Cbc_Model * model, const char *filename) 95 478 ; 96 /** Provide an initial feasible solution to accelerate branchandbound 479 480 //@} 481 482 /**@name Getting and setting model data 483 Note that problem access and modification methods, 484 such as getColLower and setColLower, 485 are *not valid* after calling Cbc_solve(). 486 Therefore it is not recommended to reuse a Cbc_Model 487 object for multiple solves. A workaround is to call Cbc_clone() 488 before solving. 489 * */ 490 /*@{*/ 491 492 /** Provide an initial feasible solution to accelerate branchandbound 97 493 Note that feasibility of the solution is *not* verified. 98 494 */ … … 100 496 Cbc_setInitialSolution(Cbc_Model *model, const double * sol) 101 497 ; 102 /** Fills in array with problem name */ 103 COINLIBAPI void COINLINKAGE 104 Cbc_problemName(Cbc_Model * model, int maxNumberCharacters, char * array) 105 ; 106 /** Sets problem name. 107 108 \p array must be a nullterminated string. 109 */ 110 COINLIBAPI int COINLINKAGE 111 Cbc_setProblemName(Cbc_Model * model, const char * array) 112 ; 113 114 /** Number of nonzero elements in constraint matrix */ 115 COINLIBAPI int COINLINKAGE 116 Cbc_getNumElements(Cbc_Model * model) 117 ; 118 /** "Column start" vector of constraint matrix. Same format as Cbc_loadProblem() */ 498 /** "Column start" vector of constraint matrix. Same format as Cbc_loadProblem() */ 119 499 COINLIBAPI const CoinBigIndex * COINLINKAGE 120 500 Cbc_getVectorStarts(Cbc_Model * model) … … 133 513 Cbc_maxNameLength(Cbc_Model * model) 134 514 ; 135 /** Fill in first maxLength bytes of name array with a row name */136 COINLIBAPI void COINLINKAGE137 Cbc_getRowName(Cbc_Model * model, int iRow, char * name, size_t maxLength)138 ;139 /** Fill in first maxLength bytes of name array with a column name */140 COINLIBAPI void COINLINKAGE141 Cbc_getColName(Cbc_Model * model, int iColumn, char * name, size_t maxLength)142 ;143 /** Set the name of a column */144 COINLIBAPI void COINLINKAGE145 Cbc_setColName(Cbc_Model * model, int iColumn, const char * name)146 ;147 /** Set the name of a row */148 COINLIBAPI void COINLINKAGE149 Cbc_setRowName(Cbc_Model * model, int iRow, const char * name)150 ;151 /** Number of constraints in the model */152 COINLIBAPI int COINLINKAGE153 Cbc_getNumRows(Cbc_Model * model)154 ;155 /** Number of nonzero entries in a row */156 COINLIBAPI int COINLINKAGE157 Cbc_getRowNz(Cbc_Model * model, int row)158 ;159 /** Indices of variables that appear on this row */160 COINLIBAPI const int * COINLINKAGE161 Cbc_getRowIndices(Cbc_Model * model, int row)162 ;163 /** Coefficients of variables that appear on this row */164 COINLIBAPI const double * COINLINKAGE165 Cbc_getRowCoeffs(Cbc_Model * model, int row)166 ;167 /** Number of nonzero entries in a column */168 COINLIBAPI int COINLINKAGE169 Cbc_getColNz(Cbc_Model * model, int col)170 ;171 /** Indices of rows that a column appears */172 COINLIBAPI const int * COINLINKAGE173 Cbc_getColIndices(Cbc_Model * model, int col)174 ;175 /** Coefficients that a column appear in rows */176 COINLIBAPI const double * COINLINKAGE177 Cbc_getColCoeffs(Cbc_Model * model, int col)178 ;179 /** Right hand side of a row */180 COINLIBAPI double COINLINKAGE181 Cbc_getRowRHS(Cbc_Model * model, int row)182 ;183 /** Sense a row */184 COINLIBAPI char COINLINKAGE185 Cbc_getRowSense(Cbc_Model * model, int row)186 ;187 /** Number of variables in the model */188 COINLIBAPI int COINLINKAGE189 Cbc_getNumCols(Cbc_Model * model)190 ;191 /** Number of integer variables in the model */192 COINLIBAPI int COINLINKAGE193 Cbc_getNumIntegers(Cbc_Model * model)194 ;195 /** Direction of optimization (1  minimize, 1  maximize, 0  ignore) */196 COINLIBAPI void COINLINKAGE197 Cbc_setObjSense(Cbc_Model * model, double sense)198 ;199 /** Direction of optimization (1  minimize, 1  maximize, 0  ignore) */200 COINLIBAPI double COINLINKAGE201 Cbc_getObjSense(Cbc_Model * model)202 ;203 /** Constraint lower bounds */204 COINLIBAPI const double* COINLINKAGE205 Cbc_getRowLower(Cbc_Model * model)206 ;207 /** Set the lower bound of a single constraint */208 COINLIBAPI void COINLINKAGE209 Cbc_setRowLower(Cbc_Model * model, int index, double value)210 ;211 /** Constraint upper bounds */212 COINLIBAPI const double* COINLINKAGE213 Cbc_getRowUpper(Cbc_Model * model)214 ;215 /** Set the upper bound of a single constraint */216 COINLIBAPI void COINLINKAGE217 Cbc_setRowUpper(Cbc_Model * model, int index, double value)218 ;219 /** Objective vector */220 COINLIBAPI const double * COINLINKAGE221 Cbc_getObjCoefficients(Cbc_Model * model)222 ;223 /** Set the objective coefficient of a single variable */224 COINLIBAPI void COINLINKAGE225 Cbc_setObjCoeff(Cbc_Model * model, int index, double value)226 ;227 /** Variable lower bounds */228 COINLIBAPI const double * COINLINKAGE229 Cbc_getColLower(Cbc_Model * model)230 ;231 /** Set the lower bound of a single variable */232 COINLIBAPI void COINLINKAGE233 Cbc_setColLower(Cbc_Model * model, int index, double value)234 ;235 /** Variable upper bounds */236 COINLIBAPI const double * COINLINKAGE237 Cbc_getColUpper(Cbc_Model * model)238 ;239 /** Set the upper bound of a single variable */240 COINLIBAPI void COINLINKAGE241 Cbc_setColUpper(Cbc_Model * model, int index, double value)242 ;243 /** Determine whether the ith variable is integer restricted */244 COINLIBAPI int COINLINKAGE245 Cbc_isInteger(Cbc_Model * model, int i)246 ;247 /** Set this variable to be continuous */248 COINLIBAPI void COINLINKAGE249 Cbc_setContinuous(Cbc_Model * model, int iColumn)250 ;251 /** Set this variable to be integer */252 COINLIBAPI void COINLINKAGE253 Cbc_setInteger(Cbc_Model * model, int iColumn)254 ;255 /** Adds a new column */256 COINLIBAPI void COINLINKAGE257 Cbc_addCol( Cbc_Model *model, const char *name, double lb,258 double ub, double obj, char isInteger,259 int nz, int *rows, double *coefs )260 ;261 /** Adds a new row */262 COINLIBAPI void COINLINKAGE263 Cbc_addRow( Cbc_Model *model, const char *name, int nz,264 const int *cols, const double *coefs, char sense, double rhs )265 ;266 /** Add SOS constraints to the model using roworder matrix */267 COINLIBAPI void COINLINKAGE268 Cbc_addSOS(Cbc_Model * model, int numRows, const int * rowStarts,269 const int * colIndices, const double * weights, const int type)270 ;271 515 /** Print the model */ 272 516 COINLIBAPI void COINLINKAGE … … 278 522 ; 279 523 /*@}*/ 524 280 525 /**@name Solver parameters */ 281 526 /*@{*/
Note: See TracChangeset
for help on using the changeset viewer.