1 2 #ifndef HEADER_lp_lib 3 #define HEADER_lp_lib 4 5 /* -------------------------------------------------------------------------- 6 7 This is the main library header file for the lp_solve v5.0 release 8 9 Starting at version 3.0, LP_Solve is released under the LGPL license. 10 For full information, see the enclosed file LGPL.txt. 11 12 Original developer: Michel Berkelaar - michel@ics.ele.tue.nl 13 Most changes 1.5-2.0: Jeroen Dirks - jeroend@tor.numetrix.com 14 Changes 3.2-4.0: Kjell Eikland - kjell.eikland@broadpark.no 15 (Simplex code, SOS, SC, code optimization) 16 Peter Notebaert - lpsolve@peno.be 17 (Sensitivity analysis, documentation) 18 Changes 5.0+: Kjell Eikland - kjell.eikland@broadpark.no 19 (BFP, XLI, simplex, B&B, code modularization) 20 Peter Notebaert - lpsolve@peno.be 21 (Sensitivity analysis, New lp parser, LINDO (XLI) 22 parser, VB/.NET interface, documentation) 23 24 Release notes: 25 26 Version 4.0 enhances version 3.2 in terms of internal program/simplex 27 architecture, call level interfaces, data layout, features and contains 28 several bug fixes. There is now complete support for semi-continuous 29 variables and SOS constructions. In the process, a complete API 30 was added. The MPS parser has been amended to support this. 31 Sensitivity analysis and variouse bug fixes was provided by Peter 32 Notebaert in 4.0 sub-releases. Peter also wrote a complete 33 documentation of the API and contributed a VB interface, both of which 34 significantly enhanced the accessibility of lp_solve. 35 36 Version 5.0 is a major rewrite and code cleanup. The main additions that 37 drove forward this cleanup were the modular inversion logic with optimal 38 column ordering, addition of primal phase 1 and dual phase 2 logic for 39 full flexibility in the selection of primal and dual simplex modes, 40 DEVEX and steepest edge pivot selection, along with dynamic cycling 41 detection and prevention. This cleanup made it possible to harmonize the 42 internal rounding principles, contributing to increased numerical stability. 43 44 Version 5.1 rearranges the matrix storage model by enabling both legacy 45 element record-based storage and split vector storage. In addition the 46 lprec structure is optimized and additional routines are added, mainly for 47 sparse vector additions and enhanced XLI functionality. Support for XML- 48 based models was added on the basis of the LPFML schema via xli_LPFML. 49 50 Version 5.2 removes the objective function from the constraint matrix, 51 adds a number of presolve options and speed them up. Degeneracy handling 52 is significantly improved. Support for XLI_ZIMPL was added. 53 Multiple and partial pricing has been enhanced and activated. 54 55 -------------------------------------------------------------------------- */ 56 /* Define user program feature option switches */ 57 /* ------------------------------------------------------------------------- */ 58 59 #if !defined _WINDOWS && !defined _WIN32 && !defined WIN32 60 # define _isnan(x) FALSE 61 #endif 62 63 /* Utility/system settings */ 64 /* ------------------------------------------------------------------------- */ 65 /*#define INTEGERTIME */ /* Set use of lower-resolution timer */ 66 67 68 /* New v5.0+ simplex/optimization features and settings */ 69 /* ------------------------------------------------------------------------- */ 70 /*#define NoRowScaleOF */ /* Optionally skip row-scaling of the OF */ 71 #define DoMatrixRounding /* Round A matrix elements to precision */ 72 #define DoBorderRounding /* Round RHS, bounds and ranges to precision */ 73 #define Phase1EliminateRedundant /* Remove rows of redundant artificials */ 74 #define FixViolatedOptimal 75 #define ImproveSolutionPrecision /* Round optimal solution values */ 76 /*#define IncreasePivotOnReducedAccuracy */ /* Increase epspivot on instability */ 77 /*#define FixInaccurateDualMinit */ /* Reinvert on inaccuracy in dual minits */ 78 /*#define EnforcePositiveTheta */ /* Ensure that the theta range is valid */ 79 #define ResetMinitOnReinvert 80 /*#define UsePrimalReducedCostUpdate */ /* Not tested */ 81 /*#define UseDualReducedCostUpdate */ /* Seems Ok, but slower than expected */ 82 /*#ifdef UseLegacyExtrad */ /* Use v3.2- style Extrad method */ 83 #define UseMilpExpandedRCF /* Non-ints in reduced cost bound tightening */ 84 /*#define UseMilpSlacksRCF */ /* Slacks in reduced cost bound tightening (degen 85 prone); requires !SlackInitMinusInf */ 86 #define LegacySlackDefinition /* Slack as the "value of the constraint" */ 87 88 89 /* Development features (change at own risk) */ 90 /* ------------------------------------------------------------------------- */ 91 /*#define MIPboundWithOF */ /* Enable to detect OF constraint for use during B&B */ 92 /*#define SlackInitMinusInf */ /* Slacks have 0 LB if this is not defined */ 93 #define FULLYBOUNDEDSIMPLEX FALSE /* WARNING: Activate at your own risk! */ 94 95 96 /* Specify use of the basic linear algebra subroutine library */ 97 /* ------------------------------------------------------------------------- */ 98 #define libBLAS 2 /* 0: No, 1: Internal, 2: External */ 99 #define libnameBLAS "myBLAS" 100 101 102 /* Active inverse logic (default is optimized original etaPFI) */ 103 /* ------------------------------------------------------------------------- */ 104 #if !defined LoadInverseLib 105 # define LoadInverseLib TRUE /* Enable alternate inverse libraries */ 106 #endif 107 /*#define ExcludeNativeInverse */ /* Disable INVERSE_ACTIVE inverse engine */ 108 109 #define DEF_OBJINBASIS TRUE /* Additional rows inserted at the top (1 => OF) */ 110 111 #define INVERSE_NONE -1 112 #define INVERSE_LEGACY 0 113 #define INVERSE_ETAPFI 1 114 #define INVERSE_LUMOD 2 115 #define INVERSE_LUSOL 3 116 #define INVERSE_GLPKLU 4 117 118 #ifndef RoleIsExternalInvEngine /* Defined in inverse DLL drivers */ 119 #ifdef ExcludeNativeInverse 120 #define INVERSE_ACTIVE INVERSE_NONE /* Disable native engine */ 121 #else 122 #define INVERSE_ACTIVE INVERSE_LEGACY /* User or DLL-selected */ 123 #endif 124 #endif 125 126 127 /* Active external language interface logic (default is none) */ 128 /* ------------------------------------------------------------------------- */ 129 #if !defined LoadLanguageLib 130 # define LoadLanguageLib TRUE /* Enable alternate language libraries */ 131 #endif 132 #define ExcludeNativeLanguage /* Disable LANGUAGE_ACTIVE XLI */ 133 134 #define LANGUAGE_NONE -1 135 #define LANGUAGE_LEGACYLP 0 136 #define LANGUAGE_CPLEXLP 1 137 #define LANGUAGE_MPSX 2 138 #define LANGUAGE_LPFML 3 139 #define LANGUAGE_MATHPROG 4 140 #define LANGUAGE_AMPL 5 141 #define LANGUAGE_GAMS 6 142 #define LANGUAGE_ZIMPL 7 143 #define LANGUAGE_S 8 144 #define LANGUAGE_R 9 145 #define LANGUAGE_MATLAB 10 146 #define LANGUAGE_OMATRIX 11 147 #define LANGUAGE_SCILAB 12 148 #define LANGUAGE_OCTAVE 13 149 #define LANGUAGE_EMPS 14 150 151 #ifndef RoleIsExternalLanguageEngine /* Defined in XLI driver libraries */ 152 #ifdef ExcludeNativeLanguage 153 #define LANGUAGE_ACTIVE LANGUAGE_NONE /* Disable native engine */ 154 #else 155 #define LANGUAGE_ACTIVE LANGUAGE_CPLEXLP /* User or DLL-selected */ 156 #endif 157 #endif 158 159 160 /* Default parameters and tolerances */ 161 /* ------------------------------------------------------------------------- */ 162 #define OriginalPARAM 0 163 #define ProductionPARAM 1 164 #define ChvatalPARAM 2 165 #define LoosePARAM 3 166 #if 1 167 #define ActivePARAM ProductionPARAM 168 #else 169 #define ActivePARAM LoosePARAM 170 #endif 171 172 173 /* Miscellaneous settings */ 174 /* ------------------------------------------------------------------------- */ 175 #ifndef Paranoia 176 #ifdef _DEBUG 177 #define Paranoia 178 #endif 179 #endif 180 181 182 /* Program version data */ 183 /* ------------------------------------------------------------------------- */ 184 #define MAJORVERSION 5 185 #define MINORVERSION 5 186 #define RELEASE 0 187 #define BUILD 7 188 #define BFPVERSION 12 /* Checked against bfp_compatible() */ 189 #define XLIVERSION 12 /* Checked against xli_compatible() */ 190 /* Note that both BFPVERSION and XLIVERSION typically have to be incremented 191 in the case that the lprec structure changes. */ 192 193 194 /* Include/header files */ 195 /* ------------------------------------------------------------------------- */ 196 #include <sys/types.h> 197 #include <stdlib.h> 198 #include <string.h> 199 #include <math.h> 200 #include <stdio.h> 201 202 #include "lp_types.h" 203 #include "lp_utils.h" 204 205 #if (LoadInverseLib == TRUE) || (LoadLanguageLib == TRUE) 206 #ifdef WIN32 207 #include <windows.h> 208 #else 209 #include <dlfcn.h> 210 #endif 211 #endif 212 213 #ifndef BFP_CALLMODEL 214 #ifdef WIN32 215 #define BFP_CALLMODEL __stdcall /* "Standard" call model */ 216 #else 217 #define BFP_CALLMODEL 218 #endif 219 #endif 220 #ifndef XLI_CALLMODEL 221 #define XLI_CALLMODEL BFP_CALLMODEL 222 #endif 223 224 #define REGISTER register /* Speed up certain operations */ 225 226 227 /* Definition of program constrants */ 228 /* ------------------------------------------------------------------------- */ 229 #define SIMPLEX_UNDEFINED 0 230 #define SIMPLEX_Phase1_PRIMAL 1 231 #define SIMPLEX_Phase1_DUAL 2 232 #define SIMPLEX_Phase2_PRIMAL 4 233 #define SIMPLEX_Phase2_DUAL 8 234 #define SIMPLEX_DYNAMIC 16 235 #define SIMPLEX_AUTODUALIZE 32 236 237 #define SIMPLEX_PRIMAL_PRIMAL (SIMPLEX_Phase1_PRIMAL + SIMPLEX_Phase2_PRIMAL) 238 #define SIMPLEX_DUAL_PRIMAL (SIMPLEX_Phase1_DUAL + SIMPLEX_Phase2_PRIMAL) 239 #define SIMPLEX_PRIMAL_DUAL (SIMPLEX_Phase1_PRIMAL + SIMPLEX_Phase2_DUAL) 240 #define SIMPLEX_DUAL_DUAL (SIMPLEX_Phase1_DUAL + SIMPLEX_Phase2_DUAL) 241 #define SIMPLEX_DEFAULT (SIMPLEX_DUAL_PRIMAL) 242 243 /* Variable codes (internal) */ 244 #define ISREAL 0 245 #define ISINTEGER 1 246 #define ISSEMI 2 247 #define ISSOS 4 248 #define ISSOSTEMPINT 8 249 #define ISGUB 16 250 251 /* Presolve defines */ 252 #define PRESOLVE_NONE 0 253 #define PRESOLVE_ROWS 1 254 #define PRESOLVE_COLS 2 255 #define PRESOLVE_LINDEP 4 256 #define PRESOLVE_AGGREGATE 8 /* Not implemented */ 257 #define PRESOLVE_SPARSER 16 /* Not implemented */ 258 #define PRESOLVE_SOS 32 259 #define PRESOLVE_REDUCEMIP 64 260 #define PRESOLVE_KNAPSACK 128 /* Implementation not tested completely */ 261 #define PRESOLVE_ELIMEQ2 256 262 #define PRESOLVE_IMPLIEDFREE 512 263 #define PRESOLVE_REDUCEGCD 1024 264 #define PRESOLVE_PROBEFIX 2048 265 #define PRESOLVE_PROBEREDUCE 4096 266 #define PRESOLVE_ROWDOMINATE 8192 267 #define PRESOLVE_COLDOMINATE 16384 /* Reduced functionality, should be expanded */ 268 #define PRESOLVE_MERGEROWS 32768 269 #define PRESOLVE_IMPLIEDSLK 65536 270 #define PRESOLVE_COLFIXDUAL 131072 271 #define PRESOLVE_BOUNDS 262144 272 #define PRESOLVE_LASTMASKMODE (PRESOLVE_DUALS - 1) 273 #define PRESOLVE_DUALS 524288 274 #define PRESOLVE_SENSDUALS 1048576 275 276 /* Basis crash options */ 277 #define CRASH_NONE 0 278 #define CRASH_NONBASICBOUNDS 1 279 #define CRASH_MOSTFEASIBLE 2 280 #define CRASH_LEASTDEGENERATE 3 281 282 /* Solution recomputation options (internal) */ 283 #define INITSOL_SHIFTZERO 0 284 #define INITSOL_USEZERO 1 285 #define INITSOL_ORIGINAL 2 286 287 /* Strategy codes to avoid or recover from degenerate pivots, 288 infeasibility or numeric errors via randomized bound relaxation */ 289 #define ANTIDEGEN_NONE 0 290 #define ANTIDEGEN_FIXEDVARS 1 291 #define ANTIDEGEN_COLUMNCHECK 2 292 #define ANTIDEGEN_STALLING 4 293 #define ANTIDEGEN_NUMFAILURE 8 294 #define ANTIDEGEN_LOSTFEAS 16 295 #define ANTIDEGEN_INFEASIBLE 32 296 #define ANTIDEGEN_DYNAMIC 64 297 #define ANTIDEGEN_DURINGBB 128 298 #define ANTIDEGEN_RHSPERTURB 256 299 #define ANTIDEGEN_BOUNDFLIP 512 300 #define ANTIDEGEN_DEFAULT (ANTIDEGEN_FIXEDVARS | ANTIDEGEN_STALLING /* | ANTIDEGEN_INFEASIBLE */) 301 302 /* REPORT defines */ 303 #define NEUTRAL 0 304 #define CRITICAL 1 305 #define SEVERE 2 306 #define IMPORTANT 3 307 #define NORMAL 4 308 #define DETAILED 5 309 #define FULL 6 310 311 /* MESSAGE defines */ 312 #define MSG_NONE 0 313 #define MSG_PRESOLVE 1 314 #define MSG_ITERATION 2 315 #define MSG_INVERT 4 316 #define MSG_LPFEASIBLE 8 317 #define MSG_LPOPTIMAL 16 318 #define MSG_LPEQUAL 32 319 #define MSG_LPBETTER 64 320 #define MSG_MILPFEASIBLE 128 321 #define MSG_MILPEQUAL 256 322 #define MSG_MILPBETTER 512 323 #define MSG_MILPSTRATEGY 1024 324 #define MSG_MILPOPTIMAL 2048 325 #define MSG_PERFORMANCE 4096 326 #define MSG_INITPSEUDOCOST 8192 327 328 /* MPS defines (internal) */ 329 #define MPSUNDEF -4 330 #define MPSNAME -3 331 #define MPSOBJSENSE -2 332 #define MPSOBJNAME -1 333 #define MPSROWS 0 334 #define MPSCOLUMNS 1 335 #define MPSRHS 2 336 #define MPSBOUNDS 3 337 #define MPSRANGES 4 338 #define MPSSOS 5 339 340 #define MPSVARMASK "%-8s" 341 #define MPSVALUEMASK "%12g" 342 343 /* Constraint type codes (internal) */ 344 #define ROWTYPE_EMPTY 0 345 #define ROWTYPE_LE 1 346 #define ROWTYPE_GE 2 347 #define ROWTYPE_EQ 3 348 #define ROWTYPE_CONSTRAINT ROWTYPE_EQ /* This is the mask for modes */ 349 #define ROWTYPE_OF 4 350 #define ROWTYPE_INACTIVE 8 351 #define ROWTYPE_RELAX 16 352 #define ROWTYPE_GUB 32 353 #define ROWTYPE_OFMAX (ROWTYPE_OF + ROWTYPE_GE) 354 #define ROWTYPE_OFMIN (ROWTYPE_OF + ROWTYPE_LE) 355 #define ROWTYPE_CHSIGN ROWTYPE_GE 356 357 /* Public constraint codes */ 358 #define FR ROWTYPE_EMPTY 359 #define LE ROWTYPE_LE 360 #define GE ROWTYPE_GE 361 #define EQ ROWTYPE_EQ 362 #define OF ROWTYPE_OF 363 364 /* MIP constraint classes */ 365 #define ROWCLASS_Unknown 0 /* Undefined/unknown */ 366 #define ROWCLASS_Objective 1 /* The objective function */ 367 #define ROWCLASS_GeneralREAL 2 /* General real-values constraint */ 368 #define ROWCLASS_GeneralMIP 3 /* General mixed integer/binary and real valued constraint */ 369 #define ROWCLASS_GeneralINT 4 /* General integer-only constraint */ 370 #define ROWCLASS_GeneralBIN 5 /* General binary-only constraint */ 371 #define ROWCLASS_KnapsackINT 6 /* Sum of positive integer times integer variables <= positive integer */ 372 #define ROWCLASS_KnapsackBIN 7 /* Sum of positive integer times binary variables <= positive integer */ 373 #define ROWCLASS_SetPacking 8 /* Sum of binary variables >= 1 */ 374 #define ROWCLASS_SetCover 9 /* Sum of binary variables <= 1 */ 375 #define ROWCLASS_GUB 10 /* Sum of binary variables = 1 */ 376 #define ROWCLASS_MAX ROWCLASS_GUB 377 378 /* Column subsets (internal) */ 379 #define SCAN_USERVARS 1 380 #define SCAN_SLACKVARS 2 381 #define SCAN_ARTIFICIALVARS 4 382 #define SCAN_PARTIALBLOCK 8 383 #define USE_BASICVARS 16 384 #define USE_NONBASICVARS 32 385 #define SCAN_NORMALVARS (SCAN_USERVARS + SCAN_ARTIFICIALVARS) 386 #define SCAN_ALLVARS (SCAN_SLACKVARS + SCAN_USERVARS + SCAN_ARTIFICIALVARS) 387 #define USE_ALLVARS (USE_BASICVARS + USE_NONBASICVARS) 388 #define OMIT_FIXED 64 389 #define OMIT_NONFIXED 128 390 391 /* Improvement defines */ 392 #define IMPROVE_NONE 0 393 #define IMPROVE_SOLUTION 1 394 #define IMPROVE_DUALFEAS 2 395 #define IMPROVE_THETAGAP 4 396 #define IMPROVE_BBSIMPLEX 8 397 #define IMPROVE_DEFAULT (IMPROVE_DUALFEAS + IMPROVE_THETAGAP) 398 #define IMPROVE_INVERSE (IMPROVE_SOLUTION + IMPROVE_THETAGAP) 399 400 /* Scaling types */ 401 #define SCALE_NONE 0 402 #define SCALE_EXTREME 1 403 #define SCALE_RANGE 2 404 #define SCALE_MEAN 3 405 #define SCALE_GEOMETRIC 4 406 #define SCALE_FUTURE1 5 407 #define SCALE_FUTURE2 6 408 #define SCALE_CURTISREID 7 /* Override to Curtis-Reid "optimal" scaling */ 409 410 /* Alternative scaling weights */ 411 #define SCALE_LINEAR 0 412 #define SCALE_QUADRATIC 8 413 #define SCALE_LOGARITHMIC 16 414 #define SCALE_USERWEIGHT 31 415 #define SCALE_MAXTYPE (SCALE_QUADRATIC-1) 416 417 /* Scaling modes */ 418 #define SCALE_POWER2 32 /* As is or rounded to power of 2 */ 419 #define SCALE_EQUILIBRATE 64 /* Make sure that no scaled number is above 1 */ 420 #define SCALE_INTEGERS 128 /* Apply to integer columns/variables */ 421 #define SCALE_DYNUPDATE 256 /* Apply incrementally every solve() */ 422 #define SCALE_ROWSONLY 512 /* Override any scaling to only scale the rows */ 423 #define SCALE_COLSONLY 1024 /* Override any scaling to only scale the rows */ 424 425 /* Standard defines for typical scaling models (no Lagrangeans) */ 426 #define SCALEMODEL_EQUILIBRATED (SCALE_LINEAR+SCALE_EXTREME+SCALE_INTEGERS) 427 #define SCALEMODEL_GEOMETRIC (SCALE_LINEAR+SCALE_GEOMETRIC+SCALE_INTEGERS) 428 #define SCALEMODEL_ARITHMETIC (SCALE_LINEAR+SCALE_MEAN+SCALE_INTEGERS) 429 #define SCALEMODEL_DYNAMIC (SCALEMODEL_GEOMETRIC+SCALE_EQUILIBRATE) 430 #define SCALEMODEL_CURTISREID (SCALE_CURTISREID+SCALE_INTEGERS+SCALE_POWER2) 431 432 /* Iteration status and strategies (internal) */ 433 #define ITERATE_MAJORMAJOR 0 434 #define ITERATE_MINORMAJOR 1 435 #define ITERATE_MINORRETRY 2 436 437 /* Pricing methods */ 438 #define PRICER_FIRSTINDEX 0 439 #define PRICER_DANTZIG 1 440 #define PRICER_DEVEX 2 441 #define PRICER_STEEPESTEDGE 3 442 #define PRICER_LASTOPTION PRICER_STEEPESTEDGE 443 444 /* Additional settings for pricers (internal) */ 445 #define PRICER_RANDFACT 0.1 446 #define DEVEX_RESTARTLIMIT 1.0e+09 /* Reset the norms if any value exceeds this limit */ 447 #define DEVEX_MINVALUE 0.000 /* Minimum weight [0..1] for entering variable, consider 0.01 */ 448 449 /* Pricing strategies */ 450 #define PRICE_PRIMALFALLBACK 4 /* In case of Steepest Edge, fall back to DEVEX in primal */ 451 #define PRICE_MULTIPLE 8 /* Enable multiple pricing (primal simplex) */ 452 #define PRICE_PARTIAL 16 /* Enable partial pricing */ 453 #define PRICE_ADAPTIVE 32 /* Temporarily use alternative strategy if cycling is detected */ 454 #define PRICE_HYBRID 64 /* NOT IMPLEMENTED */ 455 #define PRICE_RANDOMIZE 128 /* Adds a small randomization effect to the selected pricer */ 456 #define PRICE_AUTOPARTIAL 256 /* Detect and use data on the block structure of the model (primal) */ 457 #define PRICE_AUTOMULTIPLE 512 /* Automatically select multiple pricing (primal simplex) */ 458 #define PRICE_LOOPLEFT 1024 /* Scan entering/leaving columns left rather than right */ 459 #define PRICE_LOOPALTERNATE 2048 /* Scan entering/leaving columns alternatingly left/right */ 460 #define PRICE_HARRISTWOPASS 4096 /* Use Harris' primal pivot logic rather than the default */ 461 #define PRICE_FORCEFULL 8192 /* Non-user option to force full pricing */ 462 #define PRICE_TRUENORMINIT 16384 /* Use true norms for Devex and Steepest Edge initializations */ 463 464 #define PRICE_STRATEGYMASK (PRICE_PRIMALFALLBACK + \ 465 PRICE_MULTIPLE + PRICE_PARTIAL + \ 466 PRICE_ADAPTIVE + PRICE_HYBRID + \ 467 PRICE_RANDOMIZE + PRICE_AUTOPARTIAL + PRICE_AUTOMULTIPLE + \ 468 PRICE_LOOPLEFT + PRICE_LOOPALTERNATE + \ 469 PRICE_HARRISTWOPASS + \ 470 PRICE_FORCEFULL + PRICE_TRUENORMINIT) 471 472 /* B&B active variable codes (internal) */ 473 #define BB_REAL 0 474 #define BB_INT 1 475 #define BB_SC 2 476 #define BB_SOS 3 477 #define BB_GUB 4 478 479 /* B&B strategies */ 480 #define NODE_FIRSTSELECT 0 481 #define NODE_GAPSELECT 1 482 #define NODE_RANGESELECT 2 483 #define NODE_FRACTIONSELECT 3 484 #define NODE_PSEUDOCOSTSELECT 4 485 #define NODE_PSEUDONONINTSELECT 5 /* Kjell Eikland #1 - Minimize B&B depth */ 486 #define NODE_PSEUDOFEASSELECT (NODE_PSEUDONONINTSELECT+NODE_WEIGHTREVERSEMODE) 487 #define NODE_PSEUDORATIOSELECT 6 /* Kjell Eikland #2 - Minimize a "cost/benefit" ratio */ 488 #define NODE_USERSELECT 7 489 #define NODE_STRATEGYMASK (NODE_WEIGHTREVERSEMODE-1) /* Mask for B&B strategies */ 490 #define NODE_WEIGHTREVERSEMODE 8 491 #define NODE_BRANCHREVERSEMODE 16 492 #define NODE_GREEDYMODE 32 493 #define NODE_PSEUDOCOSTMODE 64 494 #define NODE_DEPTHFIRSTMODE 128 495 #define NODE_RANDOMIZEMODE 256 496 #define NODE_GUBMODE 512 497 #define NODE_DYNAMICMODE 1024 498 #define NODE_RESTARTMODE 2048 499 #define NODE_BREADTHFIRSTMODE 4096 500 #define NODE_AUTOORDER 8192 501 #define NODE_RCOSTFIXING 16384 502 #define NODE_STRONGINIT 32768 503 504 #define BRANCH_CEILING 0 505 #define BRANCH_FLOOR 1 506 #define BRANCH_AUTOMATIC 2 507 #define BRANCH_DEFAULT 3 508 509 /* Action constants for simplex and B&B (internal) */ 510 #define ACTION_NONE 0 511 #define ACTION_ACTIVE 1 512 #define ACTION_REBASE 2 513 #define ACTION_RECOMPUTE 4 514 #define ACTION_REPRICE 8 515 #define ACTION_REINVERT 16 516 #define ACTION_TIMEDREINVERT 32 517 #define ACTION_ITERATE 64 518 #define ACTION_RESTART 255 519 520 /* Solver status values */ 521 #define UNKNOWNERROR -5 522 #define DATAIGNORED -4 523 #define NOBFP -3 524 #define NOMEMORY -2 525 #define NOTRUN -1 526 #define OPTIMAL 0 527 #define SUBOPTIMAL 1 528 #define INFEASIBLE 2 529 #define UNBOUNDED 3 530 #define DEGENERATE 4 531 #define NUMFAILURE 5 532 #define USERABORT 6 533 #define TIMEOUT 7 534 #define RUNNING 8 535 #define PRESOLVED 9 536 537 /* Branch & Bound and Lagrangean extra status values (internal) */ 538 #define PROCFAIL 10 539 #define PROCBREAK 11 540 #define FEASFOUND 12 541 #define NOFEASFOUND 13 542 #define FATHOMED 14 543 544 /* Status values internal to the solver (internal) */ 545 #define SWITCH_TO_PRIMAL 20 546 #define SWITCH_TO_DUAL 21 547 #define SINGULAR_BASIS 22 548 #define LOSTFEAS 23 549 #define MATRIXERROR 24 550 551 /* Objective testing options for "bb_better" (internal) */ 552 #define OF_RELAXED 0 553 #define OF_INCUMBENT 1 554 #define OF_WORKING 2 555 #define OF_USERBREAK 3 556 #define OF_HEURISTIC 4 557 #define OF_DUALLIMIT 5 558 #define OF_DELTA 8 /* Mode */ 559 #define OF_PROJECTED 16 /* Mode - future, not active */ 560 561 #define OF_TEST_BT 1 562 #define OF_TEST_BE 2 563 #define OF_TEST_NE 3 564 #define OF_TEST_WE 4 565 #define OF_TEST_WT 5 566 #define OF_TEST_RELGAP 8 /* Mode */ 567 568 569 /* Name list and sparse matrix storage parameters (internal) */ 570 #define MAT_START_SIZE 10000 571 #define DELTACOLALLOC 100 572 #define DELTAROWALLOC 100 573 #define RESIZEFACTOR 4 /* Fractional increase in selected memory allocations */ 574 575 /* Default solver parameters and tolerances (internal) */ 576 #define DEF_PARTIALBLOCKS 10 /* The default number of blocks for partial pricing */ 577 #define DEF_MAXRELAX 7 /* Maximum number of non-BB relaxations in MILP */ 578 #define DEF_MAXPIVOTRETRY 10 /* Maximum number of times to retry a div-0 situation */ 579 #define DEF_MAXSINGULARITIES 10 /* Maximum number of singularities in refactorization */ 580 #define MAX_MINITUPDATES 60 /* Maximum number of bound swaps between refactorizations 581 without recomputing the whole vector - contain errors */ 582 #define MIN_REFACTFREQUENCY 5 /* Refactorization frequency indicating an inherent 583 numerical instability of the basis */ 584 #define LAG_SINGULARLIMIT 5 /* Number of times the objective does not change 585 before it is assumed that the Lagrangean constraints 586 are non-binding, and therefore impossible to converge; 587 upper iteration limit is divided by this threshold */ 588 #define MIN_TIMEPIVOT 5.0e-02 /* Minimum time per pivot for reinversion optimization 589 purposes; use active monitoring only if a pivot 590 takes more than MINTIMEPIVOT seconds. 5.0e-2 is 591 roughly suitable for a 1GHz system. */ 592 #define MAX_STALLCOUNT 12 /* The absolute upper limit to the number of stalling or 593 cycling iterations before switching rule */ 594 #define MAX_RULESWITCH 5 /* The maximum number of times to try an alternate pricing rule 595 to recover from stalling; set negative for no limit. */ 596 #define DEF_TIMEDREFACT AUTOMATIC /* Default for timed refactorization in BFPs; 597 can be FALSE, TRUE or AUTOMATIC (dynamic) */ 598 599 #define DEF_SCALINGLIMIT 5 /* The default maximum number of scaling iterations */ 600 601 #define DEF_NEGRANGE -1.0e+06 /* Downward limit for expanded variable range before the 602 variable is split into positive and negative components */ 603 #define DEF_BB_LIMITLEVEL -50 /* Relative B&B limit to protect against very deep, 604 memory-consuming trees */ 605 606 #define MAX_FRACSCALE 6 /* The maximum decimal scan range for simulated integers */ 607 #define RANDSCALE 100 /* Randomization scaling range */ 608 #define DOUBLEROUND 0.0e-02 /* Extra rounding scalar used in btran/ftran calculations; the 609 rationale for 0.0 is that prod_xA() uses rounding as well */ 610 #define DEF_EPSMACHINE 2.22e-16 /* Machine relative precision (doubles) */ 611 #define MIN_STABLEPIVOT 5.0 /* Minimum pivot magnitude assumed to be numerically stable */ 612 613 614 /* Precision macros */ 615 /* -------------------------------------------------------------------------------------- */ 616 #define PREC_REDUCEDCOST lp->epsvalue 617 #define PREC_IMPROVEGAP lp->epsdual 618 #define PREC_SUBSTFEASGAP lp->epsprimal 619 #if 1 620 #define PREC_BASICSOLUTION lp->epsvalue /* Zero-rounding of RHS/basic solution vector */ 621 #else 622 #define PREC_BASICSOLUTION lp->epsmachine /* Zero-rounding of RHS/basic solution vector */ 623 #endif 624 #define LIMIT_ABS_REL 10.0 /* Limit for testing using relative metric */ 625 626 627 /* Parameters constants for short-cut setting of tolerances */ 628 /* -------------------------------------------------------------------------------------- */ 629 #define EPS_TIGHT 0 630 #define EPS_MEDIUM 1 631 #define EPS_LOOSE 2 632 #define EPS_BAGGY 3 633 #define EPS_DEFAULT EPS_TIGHT 634 635 636 #if ActivePARAM==ProductionPARAM /* PARAMETER SET FOR PRODUCTION */ 637 /* -------------------------------------------------------------------------------------- */ 638 #define DEF_INFINITE 1.0e+30 /* Limit for dynamic range */ 639 #define DEF_EPSVALUE 1.0e-12 /* High accuracy and feasibility preserving tolerance */ 640 #define DEF_EPSPRIMAL 1.0e-10 /* For rounding primal/RHS values to 0 */ 641 #define DEF_EPSDUAL 1.0e-09 /* For rounding reduced costs to 0 */ 642 #define DEF_EPSPIVOT 2.0e-07 /* Pivot reject threshold */ 643 #define DEF_PERTURB 1.0e-05 /* Perturbation scalar for degenerate problems; 644 must at least be RANDSCALE greater than EPSPRIMAL */ 645 #define DEF_EPSSOLUTION 1.0e-05 /* Margin of error for solution bounds */ 646 #define DEF_EPSINT 1.0e-07 /* Accuracy for considering a float value as integer */ 647 648 #elif ActivePARAM==OriginalPARAM /* PARAMETER SET FOR LEGACY VERSIONS */ 649 /* -------------------------------------------------------------------------------------- */ 650 #define DEF_INFINITE 1.0e+24 /* Limit for dynamic range */ 651 #define DEF_EPSVALUE 1.0e-08 /* High accuracy and feasibility preserving tolerance */ 652 #define DEF_EPSPRIMAL 5.01e-07 /* For rounding primal/RHS values to 0, infeasibility */ 653 #define DEF_EPSDUAL 1.0e-06 /* For rounding reduced costs to 0 */ 654 #define DEF_EPSPIVOT 1.0e-04 /* Pivot reject threshold */ 655 #define DEF_PERTURB 1.0e-05 /* Perturbation scalar for degenerate problems; 656 must at least be RANDSCALE greater than EPSPRIMAL */ 657 #define DEF_EPSSOLUTION 1.0e-02 /* Margin of error for solution bounds */ 658 #define DEF_EPSINT 1.0e-03 /* Accuracy for considering a float value as integer */ 659 660 #elif ActivePARAM==ChvatalPARAM /* PARAMETER SET EXAMPLES FROM Vacek Chvatal */ 661 /* -------------------------------------------------------------------------------------- */ 662 #define DEF_INFINITE 1.0e+30 /* Limit for dynamic range */ 663 #define DEF_EPSVALUE 1.0e-10 /* High accuracy and feasibility preserving tolerance */ 664 #define DEF_EPSPRIMAL 10e-07 /* For rounding primal/RHS values to 0 */ 665 #define DEF_EPSDUAL 10e-05 /* For rounding reduced costs to 0 */ 666 #define DEF_EPSPIVOT 10e-05 /* Pivot reject threshold */ 667 #define DEF_PERTURB 10e-03 /* Perturbation scalar for degenerate problems; 668 must at least be RANDSCALE greater than EPSPRIMAL */ 669 #define DEF_EPSSOLUTION 1.0e-05 /* Margin of error for solution bounds */ 670 #define DEF_EPSINT 5.0e-03 /* Accuracy for considering a float value as integer */ 671 672 #elif ActivePARAM==LoosePARAM /* PARAMETER SET FOR LOOSE TOLERANCES */ 673 /* -------------------------------------------------------------------------------------- */ 674 #define DEF_INFINITE 1.0e+30 /* Limit for dynamic range */ 675 #define DEF_EPSVALUE 1.0e-10 /* High accuracy and feasibility preserving tolerance */ 676 #define DEF_EPSPRIMAL 5.01e-08 /* For rounding primal/RHS values to 0 */ 677 #define DEF_EPSDUAL 1.0e-07 /* For rounding reduced costs to 0 */ 678 #define DEF_EPSPIVOT 1.0e-05 /* Pivot reject threshold */ 679 #define DEF_PERTURB 1.0e-05 /* Perturbation scalar for degenerate problems; 680 must at least be RANDSCALE greater than EPSPRIMAL */ 681 #define DEF_EPSSOLUTION 1.0e-05 /* Margin of error for solution bounds */ 682 #define DEF_EPSINT 1.0e-04 /* Accuracy for considering a float value as integer */ 683 684 #endif 685 686 687 #define DEF_MIP_GAP 1.0e-11 /* The default absolute and relative MIP gap */ 688 #define SCALEDINTFIXRANGE 1.6 /* Epsilon range multiplier < 2 for collapsing bounds to fix */ 689 690 #define MIN_SCALAR 1.0e-10 /* Smallest allowed scaling adjustment */ 691 #define MAX_SCALAR 1.0e+10 /* Largest allowed scaling adjustment */ 692 #define DEF_SCALINGEPS 1.0e-02 /* Relative scaling convergence criterion for auto_scale */ 693 694 #define DEF_LAGACCEPT 1.0e-03 /* Default Lagrangean convergence acceptance criterion */ 695 #define DEF_LAGCONTRACT 0.90 /* The contraction parameter for Lagrangean iterations */ 696 #define DEF_LAGMAXITERATIONS 100 /* The maximum number of Lagrangean iterations */ 697 698 #define DEF_PSEUDOCOSTUPDATES 7 /* The default number of times pseudo-costs are recalculated; 699 experiments indicate that costs tend to stabilize */ 700 #define DEF_PSEUDOCOSTRESTART 0.15 /* The fraction of price updates required for B&B restart 701 when the mode is NODE_RESTARTMODE */ 702 #define DEF_MAXPRESOLVELOOPS 0 /* Upper limit to the number of loops during presolve, 703 <= 0 for no limit. */ 704 705 706 /* Hashing prototypes and function headers */ 707 /* ------------------------------------------------------------------------- */ 708 #include "lp_Hash.h" 709 710 711 /* Sparse matrix prototypes */ 712 /* ------------------------------------------------------------------------- */ 713 #include "lp_matrix.h" 714 715 716 /* Basis storage (mainly for B&B) */ 717 typedef struct _basisrec 718 { 719 int level; 720 int *var_basic; 721 MYBOOL *is_basic; 722 MYBOOL *is_lower; 723 int pivots; 724 struct _basisrec *previous; 725 } basisrec; 726 727 /* Presolve undo data storage */ 728 typedef struct _presolveundorec 729 { 730 lprec *lp; 731 int orig_rows; 732 int orig_columns; 733 int orig_sum; 734 int *var_to_orig; /* sum_alloc+1 : Mapping of variables from solution to 735 best_solution to account for removed variables and 736 rows during presolve; a non-positive value indicates 737 that the constraint or variable was removed */ 738 int *orig_to_var; /* sum_alloc+1 : Mapping from original variable index to 739 current / working index number */ 740 REAL *fixed_rhs; /* rows_alloc+1 : Storage of values of presolved fixed colums */ 741 REAL *fixed_obj; /* columns_alloc+1: Storage of values of presolved fixed rows */ 742 DeltaVrec *deletedA; /* A matrix of eliminated data from matA */ 743 DeltaVrec *primalundo; /* Affine translation vectors for eliminated primal variables */ 744 DeltaVrec *dualundo; /* Affine translation vectors for eliminated dual variables */ 745 MYBOOL OFcolsdeleted; 746 } presolveundorec; 747 748 /* Pseudo-cost arrays used during B&B */ 749 typedef struct _BBPSrec 750 { 751 lprec *lp; 752 int pseodotype; 753 int updatelimit; 754 int updatesfinished; 755 REAL restartlimit; 756 MATitem *UPcost; 757 MATitem *LOcost; 758 struct _BBPSrec *secondary; 759 } BBPSrec; 760 761 #include "lp_mipbb.h" 762 763 764 /* Partial pricing block data */ 765 typedef struct _partialrec { 766 lprec *lp; 767 int blockcount; /* ## The number of logical blocks or stages in the model */ 768 int blocknow; /* The currently active block */ 769 int *blockend; /* Array of column indeces giving the start of each block */ 770 int *blockpos; /* Array of column indeces giving the start scan position */ 771 MYBOOL isrow; 772 } partialrec; 773 774 775 /* Specially Ordered Sets (SOS) prototypes and settings */ 776 /* ------------------------------------------------------------------------- */ 777 /* SOS storage structure (LINEARSEARCH is typically in the 0-10 range) */ 778 #ifndef LINEARSEARCH 779 #define LINEARSEARCH 0 780 #endif 781 782 #include "lp_SOS.h" 783 784 785 /* Prototypes for user call-back functions */ 786 /* ------------------------------------------------------------------------- */ 787 typedef int (__WINAPI lphandle_intfunc)(lprec *lp, void *userhandle); 788 typedef void (__WINAPI lphandlestr_func)(lprec *lp, void *userhandle, char *buf); 789 typedef void (__WINAPI lphandleint_func)(lprec *lp, void *userhandle, int message); 790 typedef int (__WINAPI lphandleint_intfunc)(lprec *lp, void *userhandle, int message); 791 792 793 /* API typedef definitions */ 794 /* ------------------------------------------------------------------------- */ 795 typedef MYBOOL (__WINAPI add_column_func)(lprec *lp, REAL *column); 796 typedef MYBOOL (__WINAPI add_columnex_func)(lprec *lp, int count, REAL *column, int *rowno); 797 typedef MYBOOL (__WINAPI add_constraint_func)(lprec *lp, REAL *row, int constr_type, REAL rh); 798 typedef MYBOOL (__WINAPI add_constraintex_func)(lprec *lp, int count, REAL *row, int *colno, int constr_type, REAL rh); 799 typedef MYBOOL (__WINAPI add_lag_con_func)(lprec *lp, REAL *row, int con_type, REAL rhs); 800 typedef int (__WINAPI add_SOS_func)(lprec *lp, char *name, int sostype, int priority, int count, int *sosvars, REAL *weights); 801 typedef int (__WINAPI column_in_lp_func)(lprec *lp, REAL *column); 802 typedef lprec * (__WINAPI copy_lp_func)(lprec *lp); 803 typedef void (__WINAPI default_basis_func)(lprec *lp); 804 typedef MYBOOL (__WINAPI del_column_func)(lprec *lp, int colnr); 805 typedef MYBOOL (__WINAPI del_constraint_func)(lprec *lp, int rownr); 806 typedef void (__WINAPI delete_lp_func)(lprec *lp); 807 typedef MYBOOL (__WINAPI dualize_lp_func)(lprec *lp); 808 typedef void (__WINAPI free_lp_func)(lprec **plp); 809 typedef int (__WINAPI get_anti_degen_func)(lprec *lp); 810 typedef MYBOOL (__WINAPI get_basis_func)(lprec *lp, int *bascolumn, MYBOOL nonbasic); 811 typedef int (__WINAPI get_basiscrash_func)(lprec *lp); 812 typedef int (__WINAPI get_bb_depthlimit_func)(lprec *lp); 813 typedef int (__WINAPI get_bb_floorfirst_func)(lprec *lp); 814 typedef int (__WINAPI get_bb_rule_func)(lprec *lp); 815 typedef MYBOOL (__WINAPI get_bounds_tighter_func)(lprec *lp); 816 typedef REAL (__WINAPI get_break_at_value_func)(lprec *lp); 817 typedef char * (__WINAPI get_col_name_func)(lprec *lp, int colnr); 818 typedef MYBOOL (__WINAPI get_column_func)(lprec *lp, int colnr, REAL *column); 819 typedef int (__WINAPI get_columnex_func)(lprec *lp, int colnr, REAL *column, int *nzrow); 820 typedef int (__WINAPI get_constr_type_func)(lprec *lp, int rownr); 821 typedef REAL (__WINAPI get_constr_value_func)(lprec *lp, int rownr, int count, REAL *primsolution, int *nzindex); 822 typedef MYBOOL (__WINAPI get_constraints_func)(lprec *lp, REAL *constr); 823 typedef MYBOOL (__WINAPI get_dual_solution_func)(lprec *lp, REAL *rc); 824 typedef REAL (__WINAPI get_epsb_func)(lprec *lp); 825 typedef REAL (__WINAPI get_epsd_func)(lprec *lp); 826 typedef REAL (__WINAPI get_epsel_func)(lprec *lp); 827 typedef REAL (__WINAPI get_epsint_func)(lprec *lp); 828 typedef REAL (__WINAPI get_epsperturb_func)(lprec *lp); 829 typedef REAL (__WINAPI get_epspivot_func)(lprec *lp); 830 typedef int (__WINAPI get_improve_func)(lprec *lp); 831 typedef REAL (__WINAPI get_infinite_func)(lprec *lp); 832 typedef MYBOOL (__WINAPI get_lambda_func)(lprec *lp, REAL *lambda); 833 typedef REAL (__WINAPI get_lowbo_func)(lprec *lp, int colnr); 834 typedef int (__WINAPI get_lp_index_func)(lprec *lp, int orig_index); 835 typedef char * (__WINAPI get_lp_name_func)(lprec *lp); 836 typedef int (__WINAPI get_Lrows_func)(lprec *lp); 837 typedef REAL (__WINAPI get_mat_func)(lprec *lp, int rownr, int colnr); 838 typedef REAL (__WINAPI get_mat_byindex_func)(lprec *lp, int matindex, MYBOOL isrow, MYBOOL adjustsign); 839 typedef int (__WINAPI get_max_level_func)(lprec *lp); 840 typedef int (__WINAPI get_maxpivot_func)(lprec *lp); 841 typedef REAL (__WINAPI get_mip_gap_func)(lprec *lp, MYBOOL absolute); 842 typedef int (__WINAPI get_multiprice_func)(lprec *lp, MYBOOL getabssize); 843 typedef MYBOOL (__WINAPI is_use_names_func)(lprec *lp, MYBOOL isrow); 844 typedef void (__WINAPI set_use_names_func)(lprec *lp, MYBOOL isrow, MYBOOL use_names); 845 typedef int (__WINAPI get_nameindex_func)(lprec *lp, char *varname, MYBOOL isrow); 846 typedef int (__WINAPI get_Ncolumns_func)(lprec *lp); 847 typedef REAL (__WINAPI get_negrange_func)(lprec *lp); 848 typedef int (__WINAPI get_nz_func)(lprec *lp); 849 typedef int (__WINAPI get_Norig_columns_func)(lprec *lp); 850 typedef int (__WINAPI get_Norig_rows_func)(lprec *lp); 851 typedef int (__WINAPI get_Nrows_func)(lprec *lp); 852 typedef REAL (__WINAPI get_obj_bound_func)(lprec *lp); 853 typedef REAL (__WINAPI get_objective_func)(lprec *lp); 854 typedef int (__WINAPI get_orig_index_func)(lprec *lp, int lp_index); 855 typedef char * (__WINAPI get_origcol_name_func)(lprec *lp, int colnr); 856 typedef char * (__WINAPI get_origrow_name_func)(lprec *lp, int rownr); 857 typedef void (__WINAPI get_partialprice_func)(lprec *lp, int *blockcount, int *blockstart, MYBOOL isrow); 858 typedef int (__WINAPI get_pivoting_func)(lprec *lp); 859 typedef int (__WINAPI get_presolve_func)(lprec *lp); 860 typedef int (__WINAPI get_presolveloops_func)(lprec *lp); 861 typedef MYBOOL (__WINAPI get_primal_solution_func)(lprec *lp, REAL *pv); 862 typedef int (__WINAPI get_print_sol_func)(lprec *lp); 863 typedef MYBOOL (__WINAPI get_pseudocosts_func)(lprec *lp, REAL *clower, REAL *cupper, int *updatelimit); 864 typedef MYBOOL (__WINAPI get_ptr_constraints_func)(lprec *lp, REAL **constr); 865 typedef MYBOOL (__WINAPI get_ptr_dual_solution_func)(lprec *lp, REAL **rc); 866 typedef MYBOOL (__WINAPI get_ptr_lambda_func)(lprec *lp, REAL **lambda); 867 typedef MYBOOL (__WINAPI get_ptr_primal_solution_func)(lprec *lp, REAL **pv); 868 typedef MYBOOL (__WINAPI get_ptr_sensitivity_obj_func)(lprec *lp, REAL **objfrom, REAL **objtill); 869 typedef MYBOOL (__WINAPI get_ptr_sensitivity_objex_func)(lprec *lp, REAL **objfrom, REAL **objtill, REAL **objfromvalue, REAL **objtillvalue); 870 typedef MYBOOL (__WINAPI get_ptr_sensitivity_rhs_func)(lprec *lp, REAL **duals, REAL **dualsfrom, REAL **dualstill); 871 typedef MYBOOL (__WINAPI get_ptr_variables_func)(lprec *lp, REAL **var); 872 typedef REAL (__WINAPI get_rh_func)(lprec *lp, int rownr); 873 typedef REAL (__WINAPI get_rh_range_func)(lprec *lp, int rownr); 874 typedef int (__WINAPI get_rowex_func)(lprec *lp, int rownr, REAL *row, int *colno); 875 typedef MYBOOL (__WINAPI get_row_func)(lprec *lp, int rownr, REAL *row); 876 typedef char * (__WINAPI get_row_name_func)(lprec *lp, int rownr); 877 typedef REAL (__WINAPI get_scalelimit_func)(lprec *lp); 878 typedef int (__WINAPI get_scaling_func)(lprec *lp); 879 typedef MYBOOL (__WINAPI get_sensitivity_obj_func)(lprec *lp, REAL *objfrom, REAL *objtill); 880 typedef MYBOOL (__WINAPI get_sensitivity_objex_func)(lprec *lp, REAL *objfrom, REAL *objtill, REAL *objfromvalue, REAL *objtillvalue); 881 typedef MYBOOL (__WINAPI get_sensitivity_rhs_func)(lprec *lp, REAL *duals, REAL *dualsfrom, REAL *dualstill); 882 typedef int (__WINAPI get_simplextype_func)(lprec *lp); 883 typedef int (__WINAPI get_solutioncount_func)(lprec *lp); 884 typedef int (__WINAPI get_solutionlimit_func)(lprec *lp); 885 typedef int (__WINAPI get_status_func)(lprec *lp); 886 typedef char * (__WINAPI get_statustext_func)(lprec *lp, int statuscode); 887 typedef long (__WINAPI get_timeout_func)(lprec *lp); 888 typedef COUNTER (__WINAPI get_total_iter_func)(lprec *lp); 889 typedef COUNTER (__WINAPI get_total_nodes_func)(lprec *lp); 890 typedef REAL (__WINAPI get_upbo_func)(lprec *lp, int colnr); 891 typedef int (__WINAPI get_var_branch_func)(lprec *lp, int colnr); 892 typedef REAL (__WINAPI get_var_dualresult_func)(lprec *lp, int index); 893 typedef REAL (__WINAPI get_var_primalresult_func)(lprec *lp, int index); 894 typedef int (__WINAPI get_var_priority_func)(lprec *lp, int colnr); 895 typedef MYBOOL (__WINAPI get_variables_func)(lprec *lp, REAL *var); 896 typedef int (__WINAPI get_verbose_func)(lprec *lp); 897 typedef REAL (__WINAPI get_working_objective_func)(lprec *lp); 898 typedef MYBOOL (__WINAPI has_BFP_func)(lprec *lp); 899 typedef MYBOOL (__WINAPI has_XLI_func)(lprec *lp); 900 typedef MYBOOL (__WINAPI is_add_rowmode_func)(lprec *lp); 901 typedef MYBOOL (__WINAPI is_anti_degen_func)(lprec *lp, int testmask); 902 typedef MYBOOL (__WINAPI is_binary_func)(lprec *lp, int colnr); 903 typedef MYBOOL (__WINAPI is_break_at_first_func)(lprec *lp); 904 typedef MYBOOL (__WINAPI is_constr_type_func)(lprec *lp, int rownr, int mask); 905 typedef MYBOOL (__WINAPI is_debug_func)(lprec *lp); 906 typedef MYBOOL (__WINAPI is_feasible_func)(lprec *lp, REAL *values, REAL threshold); 907 typedef MYBOOL (__WINAPI is_unbounded_func)(lprec *lp, int colnr); 908 typedef MYBOOL (__WINAPI is_infinite_func)(lprec *lp, REAL value); 909 typedef MYBOOL (__WINAPI is_int_func)(lprec *lp, int column); 910 typedef MYBOOL (__WINAPI is_integerscaling_func)(lprec *lp); 911 typedef MYBOOL (__WINAPI is_lag_trace_func)(lprec *lp); 912 typedef MYBOOL (__WINAPI is_maxim_func)(lprec *lp); 913 typedef MYBOOL (__WINAPI is_nativeBFP_func)(lprec *lp); 914 typedef MYBOOL (__WINAPI is_nativeXLI_func)(lprec *lp); 915 typedef MYBOOL (__WINAPI is_negative_func)(lprec *lp, int colnr); 916 typedef MYBOOL (__WINAPI is_obj_in_basis_func)(lprec *lp); 917 typedef MYBOOL (__WINAPI is_piv_mode_func)(lprec *lp, int testmask); 918 typedef MYBOOL (__WINAPI is_piv_rule_func)(lprec *lp, int rule); 919 typedef MYBOOL (__WINAPI is_presolve_func)(lprec *lp, int testmask); 920 typedef MYBOOL (__WINAPI is_scalemode_func)(lprec *lp, int testmask); 921 typedef MYBOOL (__WINAPI is_scaletype_func)(lprec *lp, int scaletype); 922 typedef MYBOOL (__WINAPI is_semicont_func)(lprec *lp, int colnr); 923 typedef MYBOOL (__WINAPI is_SOS_var_func)(lprec *lp, int colnr); 924 typedef MYBOOL (__WINAPI is_trace_func)(lprec *lp); 925 typedef void (__WINAPI lp_solve_version_func)(int *majorversion, int *minorversion, int *release, int *build); 926 typedef lprec * (__WINAPI make_lp_func)(int rows, int columns); 927 typedef void (__WINAPI print_constraints_func)(lprec *lp, int columns); 928 typedef MYBOOL (__WINAPI print_debugdump_func)(lprec *lp, char *filename); 929 typedef void (__WINAPI print_duals_func)(lprec *lp); 930 typedef void (__WINAPI print_lp_func)(lprec *lp); 931 typedef void (__WINAPI print_objective_func)(lprec *lp); 932 typedef void (__WINAPI print_scales_func)(lprec *lp); 933 typedef void (__WINAPI print_solution_func)(lprec *lp, int columns); 934 typedef void (__WINAPI print_str_func)(lprec *lp, char *str); 935 typedef void (__WINAPI print_tableau_func)(lprec *lp); 936 typedef void (__WINAPI put_abortfunc_func)(lprec *lp, lphandle_intfunc newctrlc, void *ctrlchandle); 937 typedef void (__WINAPI put_bb_nodefunc_func)(lprec *lp, lphandleint_intfunc newnode, void *bbnodehandle); 938 typedef void (__WINAPI put_bb_branchfunc_func)(lprec *lp, lphandleint_intfunc newbranch, void *bbbranchhandle); 939 typedef void (__WINAPI put_logfunc_func)(lprec *lp, lphandlestr_func newlog, void *loghandle); 940 typedef void (__WINAPI put_msgfunc_func)(lprec *lp, lphandleint_func newmsg, void *msghandle, int mask); 941 typedef MYBOOL (__WINAPI read_LPhandle_func)(lprec **lp, FILE *filehandle, int verbose, char *lp_name); 942 typedef MYBOOL (__WINAPI read_MPShandle_func)(lprec **lp, FILE *filehandle, int typeMPS, int verbose); 943 typedef lprec * (__WINAPI read_XLI_func)(char *xliname, char *modelname, char *dataname, char *options, int verbose); 944 typedef MYBOOL (__WINAPI read_basis_func)(lprec *lp, char *filename, char *info); 945 typedef void (__WINAPI reset_basis_func)(lprec *lp); 946 typedef MYBOOL (__WINAPI read_params_func)(lprec *lp, char *filename, char *options); 947 typedef void (__WINAPI reset_params_func)(lprec *lp); 948 typedef MYBOOL (__WINAPI resize_lp_func)(lprec *lp, int rows, int columns); 949 typedef MYBOOL (__WINAPI set_add_rowmode_func)(lprec *lp, MYBOOL turnon); 950 typedef void (__WINAPI set_anti_degen_func)(lprec *lp, int anti_degen); 951 typedef int (__WINAPI set_basisvar_func)(lprec *lp, int basisPos, int enteringCol); 952 typedef MYBOOL (__WINAPI set_basis_func)(lprec *lp, int *bascolumn, MYBOOL nonbasic); 953 typedef void (__WINAPI set_basiscrash_func)(lprec *lp, int mode); 954 typedef void (__WINAPI set_bb_depthlimit_func)(lprec *lp, int bb_maxlevel); 955 typedef void (__WINAPI set_bb_floorfirst_func)(lprec *lp, int bb_floorfirst); 956 typedef void (__WINAPI set_bb_rule_func)(lprec *lp, int bb_rule); 957 typedef MYBOOL (__WINAPI set_BFP_func)(lprec *lp, char *filename); 958 typedef MYBOOL (__WINAPI set_binary_func)(lprec *lp, int colnr, MYBOOL must_be_bin); 959 typedef MYBOOL (__WINAPI set_bounds_func)(lprec *lp, int colnr, REAL lower, REAL upper); 960 typedef void (__WINAPI set_bounds_tighter_func)(lprec *lp, MYBOOL tighten); 961 typedef void (__WINAPI set_break_at_first_func)(lprec *lp, MYBOOL break_at_first); 962 typedef void (__WINAPI set_break_at_value_func)(lprec *lp, REAL break_at_value); 963 typedef MYBOOL (__WINAPI set_column_func)(lprec *lp, int colnr, REAL *column); 964 typedef MYBOOL (__WINAPI set_columnex_func)(lprec *lp, int colnr, int count, REAL *column, int *rowno); 965 typedef MYBOOL (__WINAPI set_col_name_func)(lprec *lp, int colnr, char *new_name); 966 typedef MYBOOL (__WINAPI set_constr_type_func)(lprec *lp, int rownr, int con_type); 967 typedef void (__WINAPI set_debug_func)(lprec *lp, MYBOOL debug); 968 typedef void (__WINAPI set_epsb_func)(lprec *lp, REAL epsb); 969 typedef void (__WINAPI set_epsd_func)(lprec *lp, REAL epsd); 970 typedef void (__WINAPI set_epsel_func)(lprec *lp, REAL epsel); 971 typedef void (__WINAPI set_epsint_func)(lprec *lp, REAL epsint); 972 typedef MYBOOL (__WINAPI set_epslevel_func)(lprec *lp, int epslevel); 973 typedef void (__WINAPI set_epsperturb_func)(lprec *lp, REAL epsperturb); 974 typedef void (__WINAPI set_epspivot_func)(lprec *lp, REAL epspivot); 975 typedef MYBOOL (__WINAPI set_unbounded_func)(lprec *lp, int colnr); 976 typedef void (__WINAPI set_improve_func)(lprec *lp, int improve); 977 typedef void (__WINAPI set_infinite_func)(lprec *lp, REAL infinite); 978 typedef MYBOOL (__WINAPI set_int_func)(lprec *lp, int colnr, MYBOOL must_be_int); 979 typedef void (__WINAPI set_lag_trace_func)(lprec *lp, MYBOOL lag_trace); 980 typedef MYBOOL (__WINAPI set_lowbo_func)(lprec *lp, int colnr, REAL value); 981 typedef MYBOOL (__WINAPI set_lp_name_func)(lprec *lp, char *lpname); 982 typedef MYBOOL (__WINAPI set_mat_func)(lprec *lp, int row, int column, REAL value); 983 typedef void (__WINAPI set_maxim_func)(lprec *lp); 984 typedef void (__WINAPI set_maxpivot_func)(lprec *lp, int max_num_inv); 985 typedef void (__WINAPI set_minim_func)(lprec *lp); 986 typedef void (__WINAPI set_mip_gap_func)(lprec *lp, MYBOOL absolute, REAL mip_gap); 987 typedef MYBOOL (__WINAPI set_multiprice_func)(lprec *lp, int multiblockdiv); 988 typedef void (__WINAPI set_negrange_func)(lprec *lp, REAL negrange); 989 typedef MYBOOL (__WINAPI set_obj_func)(lprec *lp, int colnr, REAL value); 990 typedef void (__WINAPI set_obj_bound_func)(lprec *lp, REAL obj_bound); 991 typedef MYBOOL (__WINAPI set_obj_fn_func)(lprec *lp, REAL *row); 992 typedef MYBOOL (__WINAPI set_obj_fnex_func)(lprec *lp, int count, REAL *row, int *colno); 993 typedef void (__WINAPI set_obj_in_basis_func)(lprec *lp, MYBOOL obj_in_basis); 994 typedef MYBOOL (__WINAPI set_outputfile_func)(lprec *lp, char *filename); 995 typedef void (__WINAPI set_outputstream_func)(lprec *lp, FILE *stream); 996 typedef MYBOOL (__WINAPI set_partialprice_func)(lprec *lp, int blockcount, int *blockstart, MYBOOL isrow); 997 typedef void (__WINAPI set_pivoting_func)(lprec *lp, int piv_rule); 998 typedef void (__WINAPI set_preferdual_func)(lprec *lp, MYBOOL dodual); 999 typedef void (__WINAPI set_presolve_func)(lprec *lp, int presolvemode, int maxloops); 1000 typedef void (__WINAPI set_print_sol_func)(lprec *lp, int print_sol); 1001 typedef MYBOOL (__WINAPI set_pseudocosts_func)(lprec *lp, REAL *clower, REAL *cupper, int *updatelimit); 1002 typedef MYBOOL (__WINAPI set_rh_func)(lprec *lp, int rownr, REAL value); 1003 typedef MYBOOL (__WINAPI set_rh_range_func)(lprec *lp, int rownr, REAL deltavalue); 1004 typedef void (__WINAPI set_rh_vec_func)(lprec *lp, REAL *rh); 1005 typedef MYBOOL (__WINAPI set_row_func)(lprec *lp, int rownr, REAL *row); 1006 typedef MYBOOL (__WINAPI set_rowex_func)(lprec *lp, int rownr, int count, REAL *row, int *colno); 1007 typedef MYBOOL (__WINAPI set_row_name_func)(lprec *lp, int rownr, char *new_name); 1008 typedef void (__WINAPI set_scalelimit_func)(lprec *lp, REAL scalelimit); 1009 typedef void (__WINAPI set_scaling_func)(lprec *lp, int scalemode); 1010 typedef MYBOOL (__WINAPI set_semicont_func)(lprec *lp, int colnr, MYBOOL must_be_sc); 1011 typedef void (__WINAPI set_sense_func)(lprec *lp, MYBOOL maximize); 1012 typedef void (__WINAPI set_simplextype_func)(lprec *lp, int simplextype); 1013 typedef void (__WINAPI set_solutionlimit_func)(lprec *lp, int limit); 1014 typedef void (__WINAPI set_timeout_func)(lprec *lp, long sectimeout); 1015 typedef void (__WINAPI set_trace_func)(lprec *lp, MYBOOL trace); 1016 typedef MYBOOL (__WINAPI set_upbo_func)(lprec *lp, int colnr, REAL value); 1017 typedef MYBOOL (__WINAPI set_var_branch_func)(lprec *lp, int colnr, int branch_mode); 1018 typedef MYBOOL (__WINAPI set_var_weights_func)(lprec *lp, REAL *weights); 1019 typedef void (__WINAPI set_verbose_func)(lprec *lp, int verbose); 1020 typedef MYBOOL (__WINAPI set_XLI_func)(lprec *lp, char *filename); 1021 typedef int (__WINAPI solve_func)(lprec *lp); 1022 typedef MYBOOL (__WINAPI str_add_column_func)(lprec *lp, char *col_string); 1023 typedef MYBOOL (__WINAPI str_add_constraint_func)(lprec *lp, char *row_string ,int constr_type, REAL rh); 1024 typedef MYBOOL (__WINAPI str_add_lag_con_func)(lprec *lp, char *row_string, int con_type, REAL rhs); 1025 typedef MYBOOL (__WINAPI str_set_obj_fn_func)(lprec *lp, char *row_string); 1026 typedef MYBOOL (__WINAPI str_set_rh_vec_func)(lprec *lp, char *rh_string); 1027 typedef REAL (__WINAPI time_elapsed_func)(lprec *lp); 1028 typedef void (__WINAPI unscale_func)(lprec *lp); 1029 typedef MYBOOL (__WINAPI write_lp_func)(lprec *lp, char *filename); 1030 typedef MYBOOL (__WINAPI write_LP_func)(lprec *lp, FILE *output); 1031 typedef MYBOOL (__WINAPI write_mps_func)(lprec *lp, char *filename); 1032 typedef MYBOOL (__WINAPI write_MPS_func)(lprec *lp, FILE *output); 1033 typedef MYBOOL (__WINAPI write_freemps_func)(lprec *lp, char *filename); 1034 typedef MYBOOL (__WINAPI write_freeMPS_func)(lprec *lp, FILE *output); 1035 typedef MYBOOL (__WINAPI write_XLI_func)(lprec *lp, char *filename, char *options, MYBOOL results); 1036 typedef MYBOOL (__WINAPI write_basis_func)(lprec *lp, char *filename); 1037 typedef MYBOOL (__WINAPI write_params_func)(lprec *lp, char *filename, char *options); 1038 1039 1040 /* Prototypes for callbacks from basis inverse/factorization libraries */ 1041 /* ------------------------------------------------------------------------- */ 1042 typedef MYBOOL (__WINAPI userabortfunc)(lprec *lp, int level); 1043 typedef void (__VACALL reportfunc)(lprec *lp, int level, char *format, ...); 1044 typedef char * (__VACALL explainfunc)(lprec *lp, char *format, ...); 1045 typedef int (__WINAPI getvectorfunc)(lprec *lp, int varin, REAL *pcol, int *nzlist, int *maxabs); 1046 typedef int (__WINAPI getpackedfunc)(lprec *lp, int j, int rn[], double bj[]); 1047 typedef REAL (__WINAPI get_OF_activefunc)(lprec *lp, int varnr, REAL mult); 1048 typedef int (__WINAPI getMDOfunc)(lprec *lp, MYBOOL *usedpos, int *colorder, int *size, MYBOOL symmetric); 1049 typedef MYBOOL (__WINAPI invertfunc)(lprec *lp, MYBOOL shiftbounds, MYBOOL final); 1050 typedef void (__WINAPI set_actionfunc)(int *actionvar, int actionmask); 1051 typedef MYBOOL (__WINAPI is_actionfunc)(int actionvar, int testmask); 1052 typedef void (__WINAPI clear_actionfunc)(int *actionvar, int actionmask); 1053 1054 1055 /* Prototypes for basis inverse/factorization libraries */ 1056 /* ------------------------------------------------------------------------- */ 1057 typedef char *(BFP_CALLMODEL BFPchar)(void); 1058 typedef void (BFP_CALLMODEL BFP_lp)(lprec *lp); 1059 typedef void (BFP_CALLMODEL BFP_lpint)(lprec *lp, int newsize); 1060 typedef int (BFP_CALLMODEL BFPint_lp)(lprec *lp); 1061 typedef int (BFP_CALLMODEL BFPint_lpint)(lprec *lp, int kind); 1062 typedef REAL (BFP_CALLMODEL BFPreal_lp)(lprec *lp); 1063 typedef REAL *(BFP_CALLMODEL BFPrealp_lp)(lprec *lp); 1064 typedef void (BFP_CALLMODEL BFP_lpbool)(lprec *lp, MYBOOL maximum); 1065 typedef int (BFP_CALLMODEL BFPint_lpbool)(lprec *lp, MYBOOL maximum); 1066 typedef int (BFP_CALLMODEL BFPint_lpintintboolbool)(lprec *lp, int uservars, int Bsize, MYBOOL *usedpos, MYBOOL final); 1067 typedef void (BFP_CALLMODEL BFP_lprealint)(lprec *lp, REAL *pcol, int *nzidx); 1068 typedef void (BFP_CALLMODEL BFP_lprealintrealint)(lprec *lp, REAL *prow, int *pnzidx, REAL *drow, int *dnzidx); 1069 typedef MYBOOL (BFP_CALLMODEL BFPbool_lp)(lprec *lp); 1070 typedef MYBOOL (BFP_CALLMODEL BFPbool_lpbool)(lprec *lp, MYBOOL changesign); 1071 typedef MYBOOL (BFP_CALLMODEL BFPbool_lpint)(lprec *lp, int size); 1072 typedef MYBOOL (BFP_CALLMODEL BFPbool_lpintintchar)(lprec *lp, int size, int deltasize, char *options); 1073 typedef MYBOOL (BFP_CALLMODEL BFPbool_lpintintint)(lprec *lp, int size, int deltasize, int sizeofvar); 1074 typedef LREAL (BFP_CALLMODEL BFPlreal_lpintintreal)(lprec *lp, int row_nr, int col_nr, REAL *pcol); 1075 typedef REAL (BFP_CALLMODEL BFPreal_lplrealreal)(lprec *lp, LREAL theta, REAL *pcol); 1076 1077 typedef int (BFP_CALLMODEL getcolumnex_func)(lprec *lp, int colnr, REAL *nzvalues, int *nzrows, int *mapin); 1078 typedef int (BFP_CALLMODEL BFPint_lpintrealcbintint)(lprec *lp, int items, getcolumnex_func cb, int *maprow, int*mapcol); 1079 1080 /* Prototypes for external language libraries */ 1081 /* ------------------------------------------------------------------------- */ 1082 typedef char *(XLI_CALLMODEL XLIchar)(void); 1083 typedef MYBOOL (XLI_CALLMODEL XLIbool_lpintintint)(lprec* lp, int size, int deltasize, int sizevar); 1084 typedef MYBOOL (XLI_CALLMODEL XLIbool_lpcharcharcharint)(lprec *lp, char *modelname, char *dataname, char *options, int verbose); 1085 typedef MYBOOL (XLI_CALLMODEL XLIbool_lpcharcharbool)(lprec *lp, char *filename, char *options, MYBOOL results); 1086 1087 1088 /* Main lp_solve prototypes and function definitions */ 1089 /* ------------------------------------------------------------------------- */ 1090 struct _lprec 1091 { 1092 /* Full list of exported functions made available in a quasi object-oriented fashion */ 1093 add_column_func *add_column; 1094 add_columnex_func *add_columnex; 1095 add_constraint_func *add_constraint; 1096 add_constraintex_func *add_constraintex; 1097 add_lag_con_func *add_lag_con; 1098 add_SOS_func *add_SOS; 1099 column_in_lp_func *column_in_lp; 1100 copy_lp_func *copy_lp; 1101 default_basis_func *default_basis; 1102 del_column_func *del_column; 1103 del_constraint_func *del_constraint; 1104 delete_lp_func *delete_lp; 1105 dualize_lp_func *dualize_lp; 1106 free_lp_func *free_lp; 1107 get_anti_degen_func *get_anti_degen; 1108 get_basis_func *get_basis; 1109 get_basiscrash_func *get_basiscrash; 1110 get_bb_depthlimit_func *get_bb_depthlimit; 1111 get_bb_floorfirst_func *get_bb_floorfirst; 1112 get_bb_rule_func *get_bb_rule; 1113 get_bounds_tighter_func *get_bounds_tighter; 1114 get_break_at_value_func *get_break_at_value; 1115 get_col_name_func *get_col_name; 1116 get_columnex_func *get_columnex; 1117 get_constr_type_func *get_constr_type; 1118 get_constr_value_func *get_constr_value; 1119 get_constraints_func *get_constraints; 1120 get_dual_solution_func *get_dual_solution; 1121 get_epsb_func *get_epsb; 1122 get_epsd_func *get_epsd; 1123 get_epsel_func *get_epsel; 1124 get_epsint_func *get_epsint; 1125 get_epsperturb_func *get_epsperturb; 1126 get_epspivot_func *get_epspivot; 1127 get_improve_func *get_improve; 1128 get_infinite_func *get_infinite; 1129 get_lambda_func *get_lambda; 1130 get_lowbo_func *get_lowbo; 1131 get_lp_index_func *get_lp_index; 1132 get_lp_name_func *get_lp_name; 1133 get_Lrows_func *get_Lrows; 1134 get_mat_func *get_mat; 1135 get_mat_byindex_func *get_mat_byindex; 1136 get_max_level_func *get_max_level; 1137 get_maxpivot_func *get_maxpivot; 1138 get_mip_gap_func *get_mip_gap; 1139 get_multiprice_func *get_multiprice; 1140 get_nameindex_func *get_nameindex; 1141 get_Ncolumns_func *get_Ncolumns; 1142 get_negrange_func *get_negrange; 1143 get_nz_func *get_nonzeros; 1144 get_Norig_columns_func *get_Norig_columns; 1145 get_Norig_rows_func *get_Norig_rows; 1146 get_Nrows_func *get_Nrows; 1147 get_obj_bound_func *get_obj_bound; 1148 get_objective_func *get_objective; 1149 get_orig_index_func *get_orig_index; 1150 get_origcol_name_func *get_origcol_name; 1151 get_origrow_name_func *get_origrow_name; 1152 get_partialprice_func *get_partialprice; 1153 get_pivoting_func *get_pivoting; 1154 get_presolve_func *get_presolve; 1155 get_presolveloops_func *get_presolveloops; 1156 get_primal_solution_func *get_primal_solution; 1157 get_print_sol_func *get_print_sol; 1158 get_pseudocosts_func *get_pseudocosts; 1159 get_ptr_constraints_func *get_ptr_constraints; 1160 get_ptr_dual_solution_func *get_ptr_dual_solution; 1161 get_ptr_lambda_func *get_ptr_lambda; 1162 get_ptr_primal_solution_func *get_ptr_primal_solution; 1163 get_ptr_sensitivity_obj_func *get_ptr_sensitivity_obj; 1164 get_ptr_sensitivity_objex_func *get_ptr_sensitivity_objex; 1165 get_ptr_sensitivity_rhs_func *get_ptr_sensitivity_rhs; 1166 get_ptr_variables_func *get_ptr_variables; 1167 get_rh_func *get_rh; 1168 get_rh_range_func *get_rh_range; 1169 get_row_func *get_row; 1170 get_rowex_func *get_rowex; 1171 get_row_name_func *get_row_name; 1172 get_scalelimit_func *get_scalelimit; 1173 get_scaling_func *get_scaling; 1174 get_sensitivity_obj_func *get_sensitivity_obj; 1175 get_sensitivity_objex_func *get_sensitivity_objex; 1176 get_sensitivity_rhs_func *get_sensitivity_rhs; 1177 get_simplextype_func *get_simplextype; 1178 get_solutioncount_func *get_solutioncount; 1179 get_solutionlimit_func *get_solutionlimit; 1180 get_status_func *get_status; 1181 get_statustext_func *get_statustext; 1182 get_timeout_func *get_timeout; 1183 get_total_iter_func *get_total_iter; 1184 get_total_nodes_func *get_total_nodes; 1185 get_upbo_func *get_upbo; 1186 get_var_branch_func *get_var_branch; 1187 get_var_dualresult_func *get_var_dualresult; 1188 get_var_primalresult_func *get_var_primalresult; 1189 get_var_priority_func *get_var_priority; 1190 get_variables_func *get_variables; 1191 get_verbose_func *get_verbose; 1192 get_working_objective_func *get_working_objective; 1193 has_BFP_func *has_BFP; 1194 has_XLI_func *has_XLI; 1195 is_add_rowmode_func *is_add_rowmode; 1196 is_anti_degen_func *is_anti_degen; 1197 is_binary_func *is_binary; 1198 is_break_at_first_func *is_break_at_first; 1199 is_constr_type_func *is_constr_type; 1200 is_debug_func *is_debug; 1201 is_feasible_func *is_feasible; 1202 is_infinite_func *is_infinite; 1203 is_int_func *is_int; 1204 is_integerscaling_func *is_integerscaling; 1205 is_lag_trace_func *is_lag_trace; 1206 is_maxim_func *is_maxim; 1207 is_nativeBFP_func *is_nativeBFP; 1208 is_nativeXLI_func *is_nativeXLI; 1209 is_negative_func *is_negative; 1210 is_obj_in_basis_func *is_obj_in_basis; 1211 is_piv_mode_func *is_piv_mode; 1212 is_piv_rule_func *is_piv_rule; 1213 is_presolve_func *is_presolve; 1214 is_scalemode_func *is_scalemode; 1215 is_scaletype_func *is_scaletype; 1216 is_semicont_func *is_semicont; 1217 is_SOS_var_func *is_SOS_var; 1218 is_trace_func *is_trace; 1219 is_unbounded_func *is_unbounded; 1220 is_use_names_func *is_use_names; 1221 lp_solve_version_func *lp_solve_version; 1222 make_lp_func *make_lp; 1223 print_constraints_func *print_constraints; 1224 print_debugdump_func *print_debugdump; 1225 print_duals_func *print_duals; 1226 print_lp_func *print_lp; 1227 print_objective_func *print_objective; 1228 print_scales_func *print_scales; 1229 print_solution_func *print_solution; 1230 print_str_func *print_str; 1231 print_tableau_func *print_tableau; 1232 put_abortfunc_func *put_abortfunc; 1233 put_bb_nodefunc_func *put_bb_nodefunc; 1234 put_bb_branchfunc_func *put_bb_branchfunc; 1235 put_logfunc_func *put_logfunc; 1236 put_msgfunc_func *put_msgfunc; 1237 read_LPhandle_func *read_LPhandle; 1238 read_MPShandle_func *read_MPShandle; 1239 read_XLI_func *read_XLI; 1240 read_params_func *read_params; 1241 read_basis_func *read_basis; 1242 reset_basis_func *reset_basis; 1243 reset_params_func *reset_params; 1244 resize_lp_func *resize_lp; 1245 set_add_rowmode_func *set_add_rowmode; 1246 set_anti_degen_func *set_anti_degen; 1247 set_basisvar_func *set_basisvar; 1248 set_basis_func *set_basis; 1249 set_basiscrash_func *set_basiscrash; 1250 set_bb_depthlimit_func *set_bb_depthlimit; 1251 set_bb_floorfirst_func *set_bb_floorfirst; 1252 set_bb_rule_func *set_bb_rule; 1253 set_BFP_func *set_BFP; 1254 set_binary_func *set_binary; 1255 set_bounds_func *set_bounds; 1256 set_bounds_tighter_func *set_bounds_tighter; 1257 set_break_at_first_func *set_break_at_first; 1258 set_break_at_value_func *set_break_at_value; 1259 set_column_func *set_column; 1260 set_columnex_func *set_columnex; 1261 set_col_name_func *set_col_name; 1262 set_constr_type_func *set_constr_type; 1263 set_debug_func *set_debug; 1264 set_epsb_func *set_epsb; 1265 set_epsd_func *set_epsd; 1266 set_epsel_func *set_epsel; 1267 set_epsint_func *set_epsint; 1268 set_epslevel_func *set_epslevel; 1269 set_epsperturb_func *set_epsperturb; 1270 set_epspivot_func *set_epspivot; 1271 set_unbounded_func *set_unbounded; 1272 set_improve_func *set_improve; 1273 set_infinite_func *set_infinite; 1274 set_int_func *set_int; 1275 set_lag_trace_func *set_lag_trace; 1276 set_lowbo_func *set_lowbo; 1277 set_lp_name_func *set_lp_name; 1278 set_mat_func *set_mat; 1279 set_maxim_func *set_maxim; 1280 set_maxpivot_func *set_maxpivot; 1281 set_minim_func *set_minim; 1282 set_mip_gap_func *set_mip_gap; 1283 set_multiprice_func *set_multiprice; 1284 set_negrange_func *set_negrange; 1285 set_obj_bound_func *set_obj_bound; 1286 set_obj_fn_func *set_obj_fn; 1287 set_obj_fnex_func *set_obj_fnex; 1288 set_obj_func *set_obj; 1289 set_obj_in_basis_func *set_obj_in_basis; 1290 set_outputfile_func *set_outputfile; 1291 set_outputstream_func *set_outputstream; 1292 set_partialprice_func *set_partialprice; 1293 set_pivoting_func *set_pivoting; 1294 set_preferdual_func *set_preferdual; 1295 set_presolve_func *set_presolve; 1296 set_print_sol_func *set_print_sol; 1297 set_pseudocosts_func *set_pseudocosts; 1298 set_rh_func *set_rh; 1299 set_rh_range_func *set_rh_range; 1300 set_rh_vec_func *set_rh_vec; 1301 set_row_func *set_row; 1302 set_rowex_func *set_rowex; 1303 set_row_name_func *set_row_name; 1304 set_scalelimit_func *set_scalelimit; 1305 set_scaling_func *set_scaling; 1306 set_semicont_func *set_semicont; 1307 set_sense_func *set_sense; 1308 set_simplextype_func *set_simplextype; 1309 set_solutionlimit_func *set_solutionlimit; 1310 set_timeout_func *set_timeout; 1311 set_trace_func *set_trace; 1312 set_upbo_func *set_upbo; 1313 set_use_names_func *set_use_names; 1314 set_var_branch_func *set_var_branch; 1315 set_var_weights_func *set_var_weights; 1316 set_verbose_func *set_verbose; 1317 set_XLI_func *set_XLI; 1318 solve_func *solve; 1319 str_add_column_func *str_add_column; 1320 str_add_constraint_func *str_add_constraint; 1321 str_add_lag_con_func *str_add_lag_con; 1322 str_set_obj_fn_func *str_set_obj_fn; 1323 str_set_rh_vec_func *str_set_rh_vec; 1324 time_elapsed_func *time_elapsed; 1325 unscale_func *unscale; 1326 write_lp_func *write_lp; 1327 write_LP_func *write_LP; 1328 write_mps_func *write_mps; 1329 write_MPS_func *write_MPS; 1330 write_freemps_func *write_freemps; 1331 write_freeMPS_func *write_freeMPS; 1332 write_XLI_func *write_XLI; 1333 write_basis_func *write_basis; 1334 write_params_func *write_params; 1335 1336 /* Spacer */ 1337 int *alignmentspacer; 1338 1339 /* Problem description */ 1340 char *lp_name; /* The name of the model */ 1341 1342 /* Problem sizes */ 1343 int sum; /* The total number of variables, including slacks */ 1344 int rows; 1345 int columns; 1346 int equalities; /* No of non-Lagrangean equality constraints in the problem */ 1347 int boundedvars; /* Count of bounded variables */ 1348 int INTfuture1; 1349 1350 /* Memory allocation sizes */ 1351 int sum_alloc; /* The allocated memory for row+column-sized data */ 1352 int rows_alloc; /* The allocated memory for row-sized data */ 1353 int columns_alloc; /* The allocated memory for column-sized data */ 1354 1355 /* Model status and solver result variables */ 1356 MYBOOL source_is_file; /* The base model was read from a file */ 1357 MYBOOL model_is_pure; /* The model has been built entirely from row and column additions */ 1358 MYBOOL model_is_valid; /* Has this lp pased the 'test' */ 1359 MYBOOL tighten_on_set; /* Specify if bounds will be tightened or overriden at bound setting */ 1360 MYBOOL names_used; /* Flag to indicate if names for rows and columns are used */ 1361 MYBOOL use_row_names; /* Flag to indicate if names for rows are used */ 1362 MYBOOL use_col_names; /* Flag to indicate if names for columns are used */ 1363 1364 MYBOOL lag_trace; /* Print information on Lagrange progression */ 1365 MYBOOL spx_trace; /* Print information on simplex progression */ 1366 MYBOOL bb_trace; /* TRUE to print extra debug information */ 1367 MYBOOL streamowned; /* TRUE if the handle should be closed at delete_lp() */ 1368 MYBOOL obj_in_basis; /* TRUE if the objective function is in the basis matrix */ 1369 1370 int spx_status; /* Simplex solver feasibility/mode code */ 1371 int lag_status; /* Extra status variable for lag_solve */ 1372 int solutioncount; /* number of equal-valued solutions found (up to solutionlimit) */ 1373 int solutionlimit; /* upper number of equal-valued solutions kept track of */ 1374 1375 REAL real_solution; /* Optimal non-MIP solution base */ 1376 REAL *solution; /* sum_alloc+1 : Solution array of the next to optimal LP, 1377 Index 0 : Objective function value, 1378 Indeces 1..rows : Slack variable values, 1379 Indeced rows+1..sum : Variable values */ 1380 REAL *best_solution; /* sum_alloc+1 : Solution array of optimal 'Integer' LP, 1381 structured as the solution array above */ 1382 REAL *full_solution; /* sum_alloc+1 : Final solution array expanded for deleted variables */ 1383 REAL *edgeVector; /* Array of reduced cost scaling norms (DEVEX and Steepest Edge) */ 1384 1385 REAL *drow; /* sum+1: Reduced costs of the last simplex */ 1386 int *nzdrow; /* sum+1: Indeces of non-zero reduced costs of the last simplex */ 1387 REAL *duals; /* rows_alloc+1 : The dual variables of the last LP */ 1388 REAL *full_duals; /* sum_alloc+1: Final duals array expanded for deleted variables */ 1389 REAL *dualsfrom; /* sum_alloc+1 :The sensitivity on dual variables/reduced costs 1390 of the last LP */ 1391 REAL *dualstill; /* sum_alloc+1 :The sensitivity on dual variables/reduced costs 1392 of the last LP */ 1393 REAL *objfrom; /* columns_alloc+1 :The sensitivity on objective function 1394 of the last LP */ 1395 REAL *objtill; /* columns_alloc+1 :The sensitivity on objective function 1396 of the last LP */ 1397 REAL *objfromvalue; /* columns_alloc+1 :The value of the variables when objective value 1398 is at its from value of the last LP */ 1399 REAL *orig_obj; /* Unused pointer - Placeholder for OF not part of B */ 1400 REAL *obj; /* Special vector used to temporarily change the OF vector */ 1401 1402 COUNTER current_iter; /* Number of iterations in the current/last simplex */ 1403 COUNTER total_iter; /* Number of iterations over all B&B steps */ 1404 COUNTER current_bswap; /* Number of bound swaps in the current/last simplex */ 1405 COUNTER total_bswap; /* Number of bount swaps over all B&B steps */ 1406 int solvecount; /* The number of solve() performed in this model */ 1407 int max_pivots; /* Number of pivots between refactorizations of the basis */ 1408 1409 /* Various execution parameters */ 1410 int simplex_strategy; /* Set desired combination of primal and dual simplex algorithms */ 1411 int simplex_mode; /* Specifies the current simplex mode during solve; see simplex_strategy */ 1412 int verbose; /* Set amount of run-time messages and results */ 1413 int print_sol; /* TRUE to print optimal solution; AUTOMATIC skips zeros */ 1414 FILE *outstream; /* Output stream, initialized to STDOUT */ 1415 1416 /* Main Branch and Bound settings */ 1417 MYBOOL *bb_varbranch; /* Determines branching strategy at the individual variable level; 1418 the setting here overrides the bb_floorfirst setting */ 1419 int piv_strategy; /* Strategy for selecting row and column entering/leaving */ 1420 int _piv_rule_; /* Internal working rule-part of piv_strategy above */ 1421 int bb_rule; /* Rule for selecting B&B variables */ 1422 MYBOOL bb_floorfirst; /* Set BRANCH_FLOOR for B&B to set variables to floor bound first; 1423 conversely with BRANCH_CEILING, the ceiling value is set first */ 1424 MYBOOL bb_breakfirst; /* TRUE to stop at first feasible solution */ 1425 MYBOOL _piv_left_; /* Internal variable indicating active pricing loop order */ 1426 MYBOOL BOOLfuture1; 1427 1428 REAL scalelimit; /* Relative convergence criterion for iterated scaling */ 1429 int scalemode; /* OR-ed codes for data scaling */ 1430 int improve; /* Set to non-zero for iterative improvement */ 1431 int anti_degen; /* Anti-degen strategy (or none) TRUE to avoid cycling */ 1432 int do_presolve; /* PRESOLVE_ parameters for LP presolving */ 1433 int presolveloops; /* Maximum number of presolve loops */ 1434 1435 int perturb_count; /* The number of bound relaxation retries performed */ 1436 1437 /* Row and column names storage variables */ 1438 hashelem **row_name; /* rows_alloc+1 */ 1439 hashelem **col_name; /* columns_alloc+1 */ 1440 hashtable *rowname_hashtab; /* hash table to store row names */ 1441 hashtable *colname_hashtab; /* hash table to store column names */ 1442 1443 /* Optionally specify continuous rows/column blocks for partial pricing */ 1444 partialrec *rowblocks; 1445 partialrec *colblocks; 1446 1447 /* Row and column type codes */ 1448 MYBOOL *var_type; /* sum_alloc+1 : TRUE if variable must be integer */ 1449 1450 /* Data for multiple pricing */ 1451 multirec *multivars; 1452 int multiblockdiv; /* The divisor used to set or augment pricing block */ 1453 1454 /* Variable (column) parameters */ 1455 int fixedvars; /* The current number of basic fixed variables in the model */ 1456 int int_vars; /* Number of variables required to be integer */ 1457 1458 int sc_vars; /* Number of semi-continuous variables */ 1459 REAL *sc_lobound; /* sum_columns+1 : TRUE if variable is semi-continuous; 1460 value replaced by conventional lower bound during solve */ 1461 int *var_is_free; /* columns+1: Index of twin variable if variable is free */ 1462 int *var_priority; /* columns: Priority-mapping of variables */ 1463 1464 SOSgroup *GUB; /* Pointer to record containing GUBs */ 1465 1466 int sos_vars; /* Number of variables in the sos_priority list */ 1467 int sos_ints; /* Number of integers in SOS'es above */ 1468 SOSgroup *SOS; /* Pointer to record containing all SOS'es */ 1469 int *sos_priority; /* Priority-sorted list of variables (no duplicates) */ 1470 1471 /* Optionally specify list of active rows/columns used in multiple pricing */ 1472 REAL *bsolveVal; /* rows+1: bsolved solution vector for reduced costs */ 1473 int *bsolveIdx; /* rows+1: Non-zero indeces of bsolveVal */ 1474 1475 /* RHS storage */ 1476 REAL *orig_rhs; /* rows_alloc+1 : The RHS after scaling and sign 1477 changing, but before 'Bound transformation' */ 1478 LREAL *rhs; /* rows_alloc+1 : The RHS of the current simplex tableau */ 1479 1480 /* Row (constraint) parameters */ 1481 int *row_type; /* rows_alloc+1 : Row/constraint type coding */ 1482 1483 /* Optionally specify data for dual long-step */ 1484 multirec *longsteps; 1485 1486 /* Original and working row and variable bounds */ 1487 REAL *orig_upbo; /* sum_alloc+1 : Bound before transformations */ 1488 REAL *upbo; /* " " : Upper bound after transformation and B&B work */ 1489 REAL *orig_lowbo; /* " " */ 1490 REAL *lowbo; /* " " : Lower bound after transformation and B&B work */ 1491 1492 /* User data and basis factorization matrices (ETA or LU, product form) */ 1493 MATrec *matA; 1494 INVrec *invB; 1495 1496 /* Basis and bounds */ 1497 BBrec *bb_bounds; /* The linked list of B&B bounds */ 1498 BBrec *rootbounds; /* The bounds at the lowest B&B level */ 1499 basisrec *bb_basis; /* The linked list of B&B bases */ 1500 basisrec *rootbasis; 1501 OBJmonrec *monitor; /* Objective monitoring record for stalling/degeneracy handling */ 1502 1503 /* Scaling parameters */ 1504 REAL *scalars; /* sum_alloc+1:0..Rows the scaling of the rows, 1505 Rows+1..Sum the scaling of the columns */ 1506 MYBOOL scaling_used; /* TRUE if scaling is used */ 1507 MYBOOL columns_scaled; /* TRUE if the columns are scaled too */ 1508 MYBOOL varmap_locked; /* Determines whether the var_to_orig and orig_to_var are fixed */ 1509 1510 /* Variable state information */ 1511 MYBOOL basis_valid; /* TRUE is the basis is still valid */ 1512 int crashmode; /* Basis crashing mode (or none) */ 1513 int *var_basic; /* rows_alloc+1: The list of columns in the basis */ 1514 REAL *val_nonbasic; /* Array to store current values of non-basic variables */ 1515 MYBOOL *is_basic; /* sum_alloc+1: TRUE if the column is in the basis */ 1516 MYBOOL *is_lower; /* " " : TRUE if the variable is at its 1517 lower bound (or in the basis), FALSE otherwise */ 1518 1519 /* Simplex basis indicators */ 1520 int *rejectpivot; /* List of unacceptable pivot choices due to division-by-zero */ 1521 BBPSrec *bb_PseudoCost; /* Data structure for costing of node branchings */ 1522 int bb_PseudoUpdates; /* Maximum number of updates for pseudo-costs */ 1523 int bb_strongbranches; /* The number of strong B&B branches performed */ 1524 int is_strongbranch; /* Are we currently in a strong branch mode? */ 1525 int bb_improvements; /* The number of discrete B&B objective improvement steps */ 1526 1527 /* Solver working variables */ 1528 REAL rhsmax; /* The maximum |value| of the rhs vector at any iteration */ 1529 REAL suminfeas; /* The working sum of primal and dual infeasibilities */ 1530 REAL bigM; /* Original objective weighting in primal phase 1 */ 1531 REAL P1extraVal; /* Phase 1 OF/RHS offset for feasibility */ 1532 int P1extraDim; /* Phase 1 additional columns/rows for feasibility */ 1533 int spx_action; /* ACTION_ variables for the simplex routine */ 1534 MYBOOL spx_perturbed; /* The variable bounds were relaxed/perturbed into this simplex */ 1535 MYBOOL bb_break; /* Solver working variable; signals break of the B&B */ 1536 MYBOOL wasPreprocessed; /* The solve preprocessing was performed */ 1537 MYBOOL wasPresolved; /* The solve presolver was invoked */ 1538 int INTfuture2; 1539 1540 /* Lagragean solver storage and parameters */ 1541 MATrec *matL; 1542 REAL *lag_rhs; /* Array of Lagrangean rhs vector */ 1543 int *lag_con_type; /* Array of GT, LT or EQ */ 1544 REAL *lambda; /* Lambda values (Lagrangean multipliers) */ 1545 REAL lag_bound; /* The Lagrangian lower OF bound */ 1546 REAL lag_accept; /* The Lagrangian convergence criterion */ 1547 1548 /* Solver thresholds */ 1549 REAL infinite; /* Limit for dynamic range */ 1550 REAL negrange; /* Limit for negative variable range */ 1551 REAL epsmachine; /* Default machine accuracy */ 1552 REAL epsvalue; /* Input data precision / rounding of data values to 0 */ 1553 REAL epsprimal; /* For rounding RHS values to 0/infeasibility */ 1554 REAL epsdual; /* For rounding reduced costs to zero */ 1555 REAL epspivot; /* Pivot reject tolerance */ 1556 REAL epsperturb; /* Perturbation scalar */ 1557 REAL epssolution; /* The solution tolerance for final validation */ 1558 1559 /* Branch & Bound working parameters */ 1560 int bb_status; /* Indicator that the last solvelp() gave an improved B&B solution */ 1561 int bb_level; /* Solver B&B working variable (recursion depth) */ 1562 int bb_maxlevel; /* The deepest B&B level of the last solution */ 1563 int bb_limitlevel; /* The maximum B&B level allowed */ 1564 COUNTER bb_totalnodes; /* Total number of nodes processed in B&B */ 1565 int bb_solutionlevel; /* The B&B level of the last / best solution */ 1566 int bb_cutpoolsize; /* Size of the B&B cut pool */ 1567 int bb_cutpoolused; /* Currently used cut pool */ 1568 int bb_constraintOF; /* General purpose B&B parameter (typically for testing) */ 1569 int *bb_cuttype; /* The type of the currently used cuts */ 1570 int *bb_varactive; /* The B&B state of the variable; 0 means inactive */ 1571 DeltaVrec *bb_upperchange; /* Changes to upper bounds during the B&B phase */ 1572 DeltaVrec *bb_lowerchange; /* Changes to lower bounds during the B&B phase */ 1573 1574 REAL bb_deltaOF; /* Minimum OF step value; computed at beginning of solve() */ 1575 1576 REAL bb_breakOF; /* User-settable value for the objective function deemed 1577 to be sufficiently good in an integer problem */ 1578 REAL bb_limitOF; /* "Dual" bound / limit to final optimal MIP solution */ 1579 REAL bb_heuristicOF; /* Set initial "at least better than" guess for objective function 1580 (can significantly speed up B&B iterations) */ 1581 REAL bb_parentOF; /* The OF value of the previous BB simplex */ 1582 REAL bb_workOF; /* The unadjusted OF value for the current best solution */ 1583 1584 /* Internal work arrays allocated as required */ 1585 presolveundorec *presolve_undo; 1586 workarraysrec *workarrays; 1587 1588 /* MIP parameters */ 1589 REAL epsint; /* Margin of error in determining if a float value is integer */ 1590 REAL mip_absgap; /* Absolute MIP gap */ 1591 REAL mip_relgap; /* Relative MIP gap */ 1592 1593 /* Time/timer variables and extended status text */ 1594 double timecreate; 1595 double timestart; 1596 double timeheuristic; 1597 double timepresolved; 1598 double timeend; 1599 long sectimeout; 1600 1601 /* Extended status message text set via explain() */ 1602 char *ex_status; 1603 1604 /* Refactorization engine interface routines (for dynamic DLL/SO BFPs) */ 1605 #if LoadInverseLib == TRUE 1606 #ifdef WIN32 1607 HINSTANCE hBFP; 1608 #else 1609 void *hBFP; 1610 #endif 1611 #endif 1612 BFPchar *bfp_name; 1613 BFPbool_lpintintint *bfp_compatible; 1614 BFPbool_lpintintchar *bfp_init; 1615 BFP_lp *bfp_free; 1616 BFPbool_lpint *bfp_resize; 1617 BFPint_lp *bfp_memallocated; 1618 BFPbool_lp *bfp_restart; 1619 BFPbool_lp *bfp_mustrefactorize; 1620 BFPint_lp *bfp_preparefactorization; 1621 BFPint_lpintintboolbool *bfp_factorize; 1622 BFP_lp *bfp_finishfactorization; 1623 BFP_lp *bfp_updaterefactstats; 1624 BFPlreal_lpintintreal *bfp_prepareupdate; 1625 BFPreal_lplrealreal *bfp_pivotRHS; 1626 BFPbool_lpbool *bfp_finishupdate; 1627 BFP_lprealint *bfp_ftran_prepare; 1628 BFP_lprealint *bfp_ftran_normal; 1629 BFP_lprealint *bfp_btran_normal; 1630 BFP_lprealintrealint *bfp_btran_double; 1631 BFPint_lp *bfp_status; 1632 BFPint_lpbool *bfp_nonzeros; 1633 BFPbool_lp *bfp_implicitslack; 1634 BFPint_lp *bfp_indexbase; 1635 BFPint_lp *bfp_rowoffset; 1636 BFPint_lp *bfp_pivotmax; 1637 BFPbool_lpint *bfp_pivotalloc; 1638 BFPint_lp *bfp_colcount; 1639 BFPbool_lp *bfp_canresetbasis; 1640 BFPreal_lp *bfp_efficiency; 1641 BFPrealp_lp *bfp_pivotvector; 1642 BFPint_lp *bfp_pivotcount; 1643 BFPint_lpint *bfp_refactcount; 1644 BFPbool_lp *bfp_isSetI; 1645 BFPint_lpintrealcbintint *bfp_findredundant; 1646 1647 /* External language interface routines (for dynamic DLL/SO XLIs) */ 1648 #if LoadLanguageLib == TRUE 1649 #ifdef WIN32 1650 HINSTANCE hXLI; 1651 #else 1652 void *hXLI; 1653 #endif 1654 #endif 1655 XLIchar *xli_name; 1656 XLIbool_lpintintint *xli_compatible; 1657 XLIbool_lpcharcharcharint *xli_readmodel; 1658 XLIbool_lpcharcharbool *xli_writemodel; 1659 1660 /* Miscellaneous internal functions made available externally */ 1661 userabortfunc *userabort; 1662 reportfunc *report; 1663 explainfunc *explain; 1664 getvectorfunc *get_lpcolumn; 1665 getpackedfunc *get_basiscolumn; 1666 get_OF_activefunc *get_OF_active; 1667 getMDOfunc *getMDO; 1668 invertfunc *invert; 1669 set_actionfunc *set_action; 1670 is_actionfunc *is_action; 1671 clear_actionfunc *clear_action; 1672 1673 /* User program interface callbacks */ 1674 lphandle_intfunc *ctrlc; 1675 void *ctrlchandle; /* User-specified "owner process ID" */ 1676 lphandlestr_func *writelog; 1677 void *loghandle; /* User-specified "owner process ID" */ 1678 lphandlestr_func *debuginfo; 1679 lphandleint_func *usermessage; 1680 int msgmask; 1681 void *msghandle; /* User-specified "owner process ID" */ 1682 lphandleint_intfunc *bb_usenode; 1683 void *bb_nodehandle; /* User-specified "owner process ID" */ 1684 lphandleint_intfunc *bb_usebranch; 1685 void *bb_branchhandle; /* User-specified "owner process ID" */ 1686 1687 }; 1688 1689 1690 #ifdef __cplusplus 1691 __EXTERN_C { 1692 #endif 1693 1694 1695 /* User and system function interfaces */ 1696 /* ------------------------------------------------------------------------- */ 1697 1698 void __EXPORT_TYPE __WINAPI lp_solve_version(int *majorversion, int *minorversion, int *release, int *build); 1699 1700 lprec __EXPORT_TYPE * __WINAPI make_lp(int rows, int columns); 1701 MYBOOL __EXPORT_TYPE __WINAPI resize_lp(lprec *lp, int rows, int columns); 1702 int __EXPORT_TYPE __WINAPI get_status(lprec *lp); 1703 char __EXPORT_TYPE * __WINAPI get_statustext(lprec *lp, int statuscode); 1704 MYBOOL __EXPORT_TYPE __WINAPI is_obj_in_basis(lprec *lp); 1705 void __EXPORT_TYPE __WINAPI set_obj_in_basis(lprec *lp, MYBOOL obj_in_basis); 1706 /* Create and initialise a lprec structure defaults */ 1707 1708 lprec __EXPORT_TYPE * __WINAPI copy_lp(lprec *lp); 1709 MYBOOL __EXPORT_TYPE __WINAPI dualize_lp(lprec *lp); 1710 STATIC MYBOOL memopt_lp(lprec *lp, int rowextra, int colextra, int nzextra); 1711 /* Copy or dualize the lp */ 1712 1713 void __EXPORT_TYPE __WINAPI delete_lp(lprec *lp); 1714 void __EXPORT_TYPE __WINAPI free_lp(lprec **plp); 1715 /* Remove problem from memory */ 1716 1717 MYBOOL __EXPORT_TYPE __WINAPI set_lp_name(lprec *lp, char *lpname); 1718 char __EXPORT_TYPE * __WINAPI get_lp_name(lprec *lp); 1719 /* Set and get the problem name */ 1720 1721 MYBOOL __EXPORT_TYPE __WINAPI has_BFP(lprec *lp); 1722 MYBOOL __EXPORT_TYPE __WINAPI is_nativeBFP(lprec *lp); 1723 MYBOOL __EXPORT_TYPE __WINAPI set_BFP(lprec *lp, char *filename); 1724 /* Set basis factorization engine */ 1725 1726 lprec __EXPORT_TYPE * __WINAPI read_XLI(char *xliname, char *modelname, char *dataname, char *options, int verbose); 1727 MYBOOL __EXPORT_TYPE __WINAPI write_XLI(lprec *lp, char *filename, char *options, MYBOOL results); 1728 MYBOOL __EXPORT_TYPE __WINAPI has_XLI(lprec *lp); 1729 MYBOOL __EXPORT_TYPE __WINAPI is_nativeXLI(lprec *lp); 1730 MYBOOL __EXPORT_TYPE __WINAPI set_XLI(lprec *lp, char *filename); 1731 /* Set external language interface */ 1732 1733 MYBOOL __EXPORT_TYPE __WINAPI set_obj(lprec *lp, int colnr, REAL value); 1734 MYBOOL __EXPORT_TYPE __WINAPI set_obj_fn(lprec *lp, REAL *row); 1735 MYBOOL __EXPORT_TYPE __WINAPI set_obj_fnex(lprec *lp, int count, REAL *row, int *colno); 1736 /* set the objective function (Row 0) of the matrix */ 1737 MYBOOL __EXPORT_TYPE __WINAPI str_set_obj_fn(lprec *lp, char *row_string); 1738 /* The same, but with string input */ 1739 void __EXPORT_TYPE __WINAPI set_sense(lprec *lp, MYBOOL maximize); 1740 void __EXPORT_TYPE __WINAPI set_maxim(lprec *lp); 1741 void __EXPORT_TYPE __WINAPI set_minim(lprec *lp); 1742 MYBOOL __EXPORT_TYPE __WINAPI is_maxim(lprec *lp); 1743 /* Set optimization direction for the objective function */ 1744 1745 MYBOOL __EXPORT_TYPE __WINAPI add_constraint(lprec *lp, REAL *row, int constr_type, REAL rh); 1746 MYBOOL __EXPORT_TYPE __WINAPI add_constraintex(lprec *lp, int count, REAL *row, int *colno, int constr_type, REAL rh); 1747 MYBOOL __EXPORT_TYPE __WINAPI set_add_rowmode(lprec *lp, MYBOOL turnon); 1748 MYBOOL __EXPORT_TYPE __WINAPI is_add_rowmode(lprec *lp); 1749 /* Add a constraint to the problem, row is the constraint row, rh is the right hand side, 1750 constr_type is the type of constraint (LE (<=), GE(>=), EQ(=)) */ 1751 MYBOOL __EXPORT_TYPE __WINAPI str_add_constraint(lprec *lp, char *row_string, int constr_type, REAL rh); 1752 /* The same, but with string input */ 1753 1754 MYBOOL __EXPORT_TYPE __WINAPI set_row(lprec *lp, int rownr, REAL *row); 1755 MYBOOL __EXPORT_TYPE __WINAPI set_rowex(lprec *lp, int rownr, int count, REAL *row, int *colno); 1756 MYBOOL __EXPORT_TYPE __WINAPI get_row(lprec *lp, int rownr, REAL *row); 1757 int __EXPORT_TYPE __WINAPI get_rowex(lprec *lp, int rownr, REAL *row, int *colno); 1758 /* Fill row with the row row_nr from the problem */ 1759 1760 MYBOOL __EXPORT_TYPE __WINAPI del_constraint(lprec *lp, int rownr); 1761 STATIC MYBOOL del_constraintex(lprec *lp, LLrec *rowmap); 1762 /* Remove constrain nr del_row from the problem */ 1763 1764 MYBOOL __EXPORT_TYPE __WINAPI add_lag_con(lprec *lp, REAL *row, int con_type, REAL rhs); 1765 /* add a Lagrangian constraint of form Row' x contype Rhs */ 1766 MYBOOL __EXPORT_TYPE __WINAPI str_add_lag_con(lprec *lp, char *row_string, int con_type, REAL rhs); 1767 /* The same, but with string input */ 1768 void __EXPORT_TYPE __WINAPI set_lag_trace(lprec *lp, MYBOOL lag_trace); 1769 MYBOOL __EXPORT_TYPE __WINAPI is_lag_trace(lprec *lp); 1770 /* Set debugging/tracing mode of the Lagrangean solver */ 1771 1772 MYBOOL __EXPORT_TYPE __WINAPI set_constr_type(lprec *lp, int rownr, int con_type); 1773 int __EXPORT_TYPE __WINAPI get_constr_type(lprec *lp, int rownr); 1774 REAL __EXPORT_TYPE __WINAPI get_constr_value(lprec *lp, int rownr, int count, REAL *primsolution, int *nzindex); 1775 MYBOOL __EXPORT_TYPE __WINAPI is_constr_type(lprec *lp, int rownr, int mask); 1776 STATIC char *get_str_constr_type(lprec *lp, int con_type); 1777 STATIC int get_constr_class(lprec *lp, int rownr); 1778 STATIC char *get_str_constr_class(lprec *lp, int con_class); 1779 /* Set the type of constraint in row Row (LE, GE, EQ) */ 1780 1781 MYBOOL __EXPORT_TYPE __WINAPI set_rh(lprec *lp, int rownr, REAL value); 1782 REAL __EXPORT_TYPE __WINAPI get_rh(lprec *lp, int rownr); 1783 /* Set and get the right hand side of a constraint row */ 1784 MYBOOL __EXPORT_TYPE __WINAPI set_rh_range(lprec *lp, int rownr, REAL deltavalue); 1785 REAL __EXPORT_TYPE __WINAPI get_rh_range(lprec *lp, int rownr); 1786 /* Set the RHS range; i.e. the lower and upper bounds of a constraint row */ 1787 void __EXPORT_TYPE __WINAPI set_rh_vec(lprec *lp, REAL *rh); 1788 /* Set the right hand side vector */ 1789 MYBOOL __EXPORT_TYPE __WINAPI str_set_rh_vec(lprec *lp, char *rh_string); 1790 /* The same, but with string input */ 1791 1792 MYBOOL __EXPORT_TYPE __WINAPI add_column(lprec *lp, REAL *column); 1793 MYBOOL __EXPORT_TYPE __WINAPI add_columnex(lprec *lp, int count, REAL *column, int *rowno); 1794 MYBOOL __EXPORT_TYPE __WINAPI str_add_column(lprec *lp, char *col_string); 1795 /* Add a column to the problem */ 1796 1797 MYBOOL __EXPORT_TYPE __WINAPI set_column(lprec *lp, int colnr, REAL *column); 1798 MYBOOL __EXPORT_TYPE __WINAPI set_columnex(lprec *lp, int colnr, int count, REAL *column, int *rowno); 1799 /* Overwrite existing column data */ 1800 1801 int __EXPORT_TYPE __WINAPI column_in_lp(lprec *lp, REAL *column); 1802 /* Returns the column index if column is already present in lp, otherwise 0. 1803 (Does not look at bounds and types, only looks at matrix values */ 1804 1805 int __EXPORT_TYPE __WINAPI get_columnex(lprec *lp, int colnr, REAL *column, int *nzrow); 1806 MYBOOL __EXPORT_TYPE __WINAPI get_column(lprec *lp, int colnr, REAL *column); 1807 /* Fill column with the column col_nr from the problem */ 1808 1809 MYBOOL __EXPORT_TYPE __WINAPI del_column(lprec *lp, int colnr); 1810 STATIC MYBOOL del_columnex(lprec *lp, LLrec *colmap); 1811 /* Delete a column */ 1812 1813 MYBOOL __EXPORT_TYPE __WINAPI set_mat(lprec *lp, int rownr, int colnr, REAL value); 1814 /* Fill in element (Row,Column) of the matrix 1815 Row in [0..Rows] and Column in [1..Columns] */ 1816 REAL __EXPORT_TYPE __WINAPI get_mat(lprec *lp, int rownr, int colnr); 1817 REAL __EXPORT_TYPE __WINAPI get_mat_byindex(lprec *lp, int matindex, MYBOOL isrow, MYBOOL adjustsign); 1818 int __EXPORT_TYPE __WINAPI get_nonzeros(lprec *lp); 1819 /* get a single element from the matrix */ /* Name changed from "mat_elm" by KE */ 1820 1821 void __EXPORT_TYPE __WINAPI set_bounds_tighter(lprec *lp, MYBOOL tighten); 1822 MYBOOL get_bounds(lprec *lp, int column, REAL *lower, REAL *upper); 1823 MYBOOL __EXPORT_TYPE __WINAPI get_bounds_tighter(lprec *lp); 1824 MYBOOL __EXPORT_TYPE __WINAPI set_upbo(lprec *lp, int colnr, REAL value); 1825 REAL __EXPORT_TYPE __WINAPI get_upbo(lprec *lp, int colnr); 1826 MYBOOL __EXPORT_TYPE __WINAPI set_lowbo(lprec *lp, int colnr, REAL value); 1827 REAL __EXPORT_TYPE __WINAPI get_lowbo(lprec *lp, int colnr); 1828 MYBOOL __EXPORT_TYPE __WINAPI set_bounds(lprec *lp, int colnr, REAL lower, REAL upper); 1829 MYBOOL __EXPORT_TYPE __WINAPI set_unbounded(lprec *lp, int colnr); 1830 MYBOOL __EXPORT_TYPE __WINAPI is_unbounded(lprec *lp, int colnr); 1831 /* Set the upper and lower bounds of a variable */ 1832 1833 MYBOOL __EXPORT_TYPE __WINAPI set_int(lprec *lp, int colnr, MYBOOL must_be_int); 1834 MYBOOL __EXPORT_TYPE __WINAPI is_int(lprec *lp, int colnr); 1835 MYBOOL __EXPORT_TYPE __WINAPI set_binary(lprec *lp, int colnr, MYBOOL must_be_bin); 1836 MYBOOL __EXPORT_TYPE __WINAPI is_binary(lprec *lp, int colnr); 1837 MYBOOL __EXPORT_TYPE __WINAPI set_semicont(lprec *lp, int colnr, MYBOOL must_be_sc); 1838 MYBOOL __EXPORT_TYPE __WINAPI is_semicont(lprec *lp, int colnr); 1839 MYBOOL __EXPORT_TYPE __WINAPI is_negative(lprec *lp, int colnr); 1840 MYBOOL __EXPORT_TYPE __WINAPI set_var_weights(lprec *lp, REAL *weights); 1841 int __EXPORT_TYPE __WINAPI get_var_priority(lprec *lp, int colnr); 1842 /* Set the type of variable */ 1843 1844 MYBOOL __EXPORT_TYPE __WINAPI set_pseudocosts(lprec *lp, REAL *clower, REAL *cupper, int *updatelimit); 1845 MYBOOL __EXPORT_TYPE __WINAPI get_pseudocosts(lprec *lp, REAL *clower, REAL *cupper, int *updatelimit); 1846 /* Set initial values for, or get computed pseudocost vectors; 1847 note that setting of pseudocosts can only happen in response to a 1848 call-back function optionally requesting this */ 1849 1850 int __EXPORT_TYPE __WINAPI add_SOS(lprec *lp, char *name, int sostype, int priority, int count, int *sosvars, REAL *weights); 1851 MYBOOL __EXPORT_TYPE __WINAPI is_SOS_var(lprec *lp, int colnr); 1852 /* Add SOS constraints */ 1853 1854 MYBOOL __EXPORT_TYPE __WINAPI set_row_name(lprec *lp, int rownr, char *new_name); 1855 char __EXPORT_TYPE * __WINAPI get_row_name(lprec *lp, int rownr); 1856 char __EXPORT_TYPE * __WINAPI get_origrow_name(lprec *lp, int rownr); 1857 /* Set/Get the name of a constraint row */ /* Get added by KE */ 1858 1859 MYBOOL __EXPORT_TYPE __WINAPI set_col_name(lprec *lp, int colnr, char *new_name); 1860 char __EXPORT_TYPE * __WINAPI get_col_name(lprec *lp, int colnr); 1861 char __EXPORT_TYPE * __WINAPI get_origcol_name(lprec *lp, int colnr); 1862 /* Set/Get the name of a variable column */ /* Get added by KE */ 1863 1864 void __EXPORT_TYPE __WINAPI unscale(lprec *lp); 1865 /* Undo previous scaling of the problem */ 1866 1867 void __EXPORT_TYPE __WINAPI set_preferdual(lprec *lp, MYBOOL dodual); 1868 void __EXPORT_TYPE __WINAPI set_simplextype(lprec *lp, int simplextype); 1869 int __EXPORT_TYPE __WINAPI get_simplextype(lprec *lp); 1870 /* Set/Get if lp_solve should prefer the dual simplex over the primal -- added by KE */ 1871 1872 void __EXPORT_TYPE __WINAPI default_basis(lprec *lp); 1873 void __EXPORT_TYPE __WINAPI set_basiscrash(lprec *lp, int mode); 1874 int __EXPORT_TYPE __WINAPI get_basiscrash(lprec *lp); 1875 int __EXPORT_TYPE __WINAPI set_basisvar(lprec *lp, int basisPos, int enteringCol); 1876 MYBOOL __EXPORT_TYPE __WINAPI set_basis(lprec *lp, int *bascolumn, MYBOOL nonbasic); 1877 MYBOOL __EXPORT_TYPE __WINAPI get_basis(lprec *lp, int *bascolumn, MYBOOL nonbasic); 1878 void __EXPORT_TYPE __WINAPI reset_basis(lprec *lp); 1879 /* Set/Get basis for a re-solved system */ /* Added by KE */ 1880 1881 MYBOOL __EXPORT_TYPE __WINAPI is_feasible(lprec *lp, REAL *values, REAL threshold); 1882 /* returns TRUE if the vector in values is a feasible solution to the lp */ 1883 1884 int __EXPORT_TYPE __WINAPI solve(lprec *lp); 1885 /* Solve the problem */ 1886 1887 REAL __EXPORT_TYPE __WINAPI time_elapsed(lprec *lp); 1888 /* Return the number of seconds since start of solution process */ 1889 1890 void __EXPORT_TYPE __WINAPI put_bb_nodefunc(lprec *lp, lphandleint_intfunc newnode, void *bbnodehandle); 1891 void __EXPORT_TYPE __WINAPI put_bb_branchfunc(lprec *lp, lphandleint_intfunc newbranch, void *bbbranchhandle); 1892 /* Allow the user to override B&B node and branching decisions */ 1893 1894 void __EXPORT_TYPE __WINAPI put_abortfunc(lprec *lp, lphandle_intfunc newctrlc, void *ctrlchandle); 1895 /* Allow the user to define an interruption callback function */ 1896 1897 void __EXPORT_TYPE __WINAPI put_logfunc(lprec *lp, lphandlestr_func newlog, void *loghandle); 1898 /* Allow the user to define a logging function */ 1899 1900 void __EXPORT_TYPE __WINAPI put_msgfunc(lprec *lp, lphandleint_func newmsg, void *msghandle, int mask); 1901 /* Allow the user to define an event-driven message/reporting */ 1902 1903 MYBOOL __EXPORT_TYPE __WINAPI get_primal_solution(lprec *lp, REAL *pv); 1904 MYBOOL __EXPORT_TYPE __WINAPI get_ptr_primal_solution(lprec *lp, REAL **pv); 1905 MYBOOL __EXPORT_TYPE __WINAPI get_dual_solution(lprec *lp, REAL *rc); 1906 MYBOOL __EXPORT_TYPE __WINAPI get_ptr_dual_solution(lprec *lp, REAL **rc); 1907 MYBOOL __EXPORT_TYPE __WINAPI get_lambda(lprec *lp, REAL *lambda); 1908 MYBOOL __EXPORT_TYPE __WINAPI get_ptr_lambda(lprec *lp, REAL **lambda); 1909 /* Get the primal, dual/reduced costs and Lambda vectors */ 1910 1911 /* Read an MPS file */ 1912 lprec __EXPORT_TYPE * __WINAPI read_MPS(char *filename, int verbose); 1913 lprec __EXPORT_TYPE * __WINAPI read_mps(FILE *filename, int verbose); 1914 lprec __EXPORT_TYPE * __WINAPI read_freeMPS(char *filename, int verbose); 1915 lprec __EXPORT_TYPE * __WINAPI read_freemps(FILE *filename, int verbose); 1916 1917 /* Write a MPS file to output */ 1918 MYBOOL __EXPORT_TYPE __WINAPI write_mps(lprec *lp, char *filename); 1919 MYBOOL __EXPORT_TYPE __WINAPI write_MPS(lprec *lp, FILE *output); 1920 MYBOOL __EXPORT_TYPE __WINAPI write_freemps(lprec *lp, char *filename); 1921 MYBOOL __EXPORT_TYPE __WINAPI write_freeMPS(lprec *lp, FILE *output); 1922 1923 MYBOOL __EXPORT_TYPE __WINAPI write_lp(lprec *lp, char *filename); 1924 MYBOOL __EXPORT_TYPE __WINAPI write_LP(lprec *lp, FILE *output); 1925 /* Write a LP file to output */ 1926 1927 MYBOOL __WINAPI LP_readhandle(lprec **lp, FILE *filename, int verbose, char *lp_name); 1928 lprec __EXPORT_TYPE * __WINAPI read_lp(FILE *filename, int verbose, char *lp_name); 1929 lprec __EXPORT_TYPE * __WINAPI read_LP(char *filename, int verbose, char *lp_name); 1930 /* Old-style lp format file parser */ 1931 1932 MYBOOL __EXPORT_TYPE __WINAPI write_basis(lprec *lp, char *filename); 1933 MYBOOL __EXPORT_TYPE __WINAPI read_basis(lprec *lp, char *filename, char *info); 1934 /* Read and write basis from/to file in CPLEX BAS format */ 1935 1936 MYBOOL __EXPORT_TYPE __WINAPI write_params(lprec *lp, char *filename, char *options); 1937 MYBOOL __EXPORT_TYPE __WINAPI read_params(lprec *lp, char *filename, char *options); 1938 void __EXPORT_TYPE __WINAPI reset_params(lprec *lp); 1939 /* Read and write parameter file */ 1940 1941 void __EXPORT_TYPE __WINAPI print_lp(lprec *lp); 1942 void __EXPORT_TYPE __WINAPI print_tableau(lprec *lp); 1943 /* Print the current problem, only useful in very small (test) problems */ 1944 1945 void __EXPORT_TYPE __WINAPI print_objective(lprec *lp); 1946 void __EXPORT_TYPE __WINAPI print_solution(lprec *lp, int columns); 1947 void __EXPORT_TYPE __WINAPI print_constraints(lprec *lp, int columns); 1948 /* Print the solution to stdout */ 1949 1950 void __EXPORT_TYPE __WINAPI print_duals(lprec *lp); 1951 /* Print the dual variables of the solution */ 1952 1953 void __EXPORT_TYPE __WINAPI print_scales(lprec *lp); 1954 /* If scaling is used, print the scaling factors */ 1955 1956 void __EXPORT_TYPE __WINAPI print_str(lprec *lp, char *str); 1957 1958 void __EXPORT_TYPE __WINAPI set_outputstream(lprec *lp, FILE *stream); 1959 MYBOOL __EXPORT_TYPE __WINAPI set_outputfile(lprec *lp, char *filename); 1960 1961 void __EXPORT_TYPE __WINAPI set_verbose(lprec *lp, int verbose); 1962 int __EXPORT_TYPE __WINAPI get_verbose(lprec *lp); 1963 1964 void __EXPORT_TYPE __WINAPI set_timeout(lprec *lp, long sectimeout); 1965 long __EXPORT_TYPE __WINAPI get_timeout(lprec *lp); 1966 1967 void __EXPORT_TYPE __WINAPI set_print_sol(lprec *lp, int print_sol); 1968 int __EXPORT_TYPE __WINAPI get_print_sol(lprec *lp); 1969 1970 void __EXPORT_TYPE __WINAPI set_debug(lprec *lp, MYBOOL debug); 1971 MYBOOL __EXPORT_TYPE __WINAPI is_debug(lprec *lp); 1972 1973 void __EXPORT_TYPE __WINAPI set_trace(lprec *lp, MYBOOL trace); 1974 MYBOOL __EXPORT_TYPE __WINAPI is_trace(lprec *lp); 1975 1976 MYBOOL __EXPORT_TYPE __WINAPI print_debugdump(lprec *lp, char *filename); 1977 1978 void __EXPORT_TYPE __WINAPI set_anti_degen(lprec *lp, int anti_degen); 1979 int __EXPORT_TYPE __WINAPI get_anti_degen(lprec *lp); 1980 MYBOOL __EXPORT_TYPE __WINAPI is_anti_degen(lprec *lp, int testmask); 1981 1982 void __EXPORT_TYPE __WINAPI set_presolve(lprec *lp, int presolvemode, int maxloops); 1983 int __EXPORT_TYPE __WINAPI get_presolve(lprec *lp); 1984 int __EXPORT_TYPE __WINAPI get_presolveloops(lprec *lp); 1985 MYBOOL __EXPORT_TYPE __WINAPI is_presolve(lprec *lp, int testmask); 1986 1987 int __EXPORT_TYPE __WINAPI get_orig_index(lprec *lp, int lp_index); 1988 int __EXPORT_TYPE __WINAPI get_lp_index(lprec *lp, int orig_index); 1989 1990 void __EXPORT_TYPE __WINAPI set_maxpivot(lprec *lp, int max_num_inv); 1991 int __EXPORT_TYPE __WINAPI get_maxpivot(lprec *lp); 1992 1993 void __EXPORT_TYPE __WINAPI set_obj_bound(lprec *lp, REAL obj_bound); 1994 REAL __EXPORT_TYPE __WINAPI get_obj_bound(lprec *lp); 1995 1996 void __EXPORT_TYPE __WINAPI set_mip_gap(lprec *lp, MYBOOL absolute, REAL mip_gap); 1997 REAL __EXPORT_TYPE __WINAPI get_mip_gap(lprec *lp, MYBOOL absolute); 1998 1999 void __EXPORT_TYPE __WINAPI set_bb_rule(lprec *lp, int bb_rule); 2000 int __EXPORT_TYPE __WINAPI get_bb_rule(lprec *lp); 2001 2002 MYBOOL __EXPORT_TYPE __WINAPI set_var_branch(lprec *lp, int colnr, int branch_mode); 2003 int __EXPORT_TYPE __WINAPI get_var_branch(lprec *lp, int colnr); 2004 2005 MYBOOL __EXPORT_TYPE __WINAPI is_infinite(lprec *lp, REAL value); 2006 void __EXPORT_TYPE __WINAPI set_infinite(lprec *lp, REAL infinite); 2007 REAL __EXPORT_TYPE __WINAPI get_infinite(lprec *lp); 2008 2009 void __EXPORT_TYPE __WINAPI set_epsint(lprec *lp, REAL epsint); 2010 REAL __EXPORT_TYPE __WINAPI get_epsint(lprec *lp); 2011 2012 void __EXPORT_TYPE __WINAPI set_epsb(lprec *lp, REAL epsb); 2013 REAL __EXPORT_TYPE __WINAPI get_epsb(lprec *lp); 2014 2015 void __EXPORT_TYPE __WINAPI set_epsd(lprec *lp, REAL epsd); 2016 REAL __EXPORT_TYPE __WINAPI get_epsd(lprec *lp); 2017 2018 void __EXPORT_TYPE __WINAPI set_epsel(lprec *lp, REAL epsel); 2019 REAL __EXPORT_TYPE __WINAPI get_epsel(lprec *lp); 2020 2021 MYBOOL __EXPORT_TYPE __WINAPI set_epslevel(lprec *lp, int epslevel); 2022 2023 void __EXPORT_TYPE __WINAPI set_scaling(lprec *lp, int scalemode); 2024 int __EXPORT_TYPE __WINAPI get_scaling(lprec *lp); 2025 MYBOOL __EXPORT_TYPE __WINAPI is_scalemode(lprec *lp, int testmask); 2026 MYBOOL __EXPORT_TYPE __WINAPI is_scaletype(lprec *lp, int scaletype); 2027 MYBOOL __EXPORT_TYPE __WINAPI is_integerscaling(lprec *lp); 2028 void __EXPORT_TYPE __WINAPI set_scalelimit(lprec *lp, REAL scalelimit); 2029 REAL __EXPORT_TYPE __WINAPI get_scalelimit(lprec *lp); 2030 2031 void __EXPORT_TYPE __WINAPI set_improve(lprec *lp, int improve); 2032 int __EXPORT_TYPE __WINAPI get_improve(lprec *lp); 2033 2034 void __EXPORT_TYPE __WINAPI set_pivoting(lprec *lp, int piv_rule); 2035 int __EXPORT_TYPE __WINAPI get_pivoting(lprec *lp); 2036 MYBOOL __EXPORT_TYPE __WINAPI set_partialprice(lprec *lp, int blockcount, int *blockstart, MYBOOL isrow); 2037 void __EXPORT_TYPE __WINAPI get_partialprice(lprec *lp, int *blockcount, int *blockstart, MYBOOL isrow); 2038 2039 MYBOOL __EXPORT_TYPE __WINAPI set_multiprice(lprec *lp, int multiblockdiv); 2040 int __EXPORT_TYPE __WINAPI get_multiprice(lprec *lp, MYBOOL getabssize); 2041 2042 MYBOOL __WINAPI is_use_names(lprec *lp, MYBOOL isrow); 2043 void __WINAPI set_use_names(lprec *lp, MYBOOL isrow, MYBOOL use_names); 2044 2045 int __EXPORT_TYPE __WINAPI get_nameindex(lprec *lp, char *varname, MYBOOL isrow); 2046 2047 MYBOOL __EXPORT_TYPE __WINAPI is_piv_mode(lprec *lp, int testmask); 2048 MYBOOL __EXPORT_TYPE __WINAPI is_piv_rule(lprec *lp, int rule); 2049 2050 void __EXPORT_TYPE __WINAPI set_break_at_first(lprec *lp, MYBOOL break_at_first); 2051 MYBOOL __EXPORT_TYPE __WINAPI is_break_at_first(lprec *lp); 2052 2053 void __EXPORT_TYPE __WINAPI set_bb_floorfirst(lprec *lp, int bb_floorfirst); 2054 int __EXPORT_TYPE __WINAPI get_bb_floorfirst(lprec *lp); 2055 2056 void __EXPORT_TYPE __WINAPI set_bb_depthlimit(lprec *lp, int bb_maxlevel); 2057 int __EXPORT_TYPE __WINAPI get_bb_depthlimit(lprec *lp); 2058 2059 void __EXPORT_TYPE __WINAPI set_break_at_value(lprec *lp, REAL break_at_value); 2060 REAL __EXPORT_TYPE __WINAPI get_break_at_value(lprec *lp); 2061 2062 void __EXPORT_TYPE __WINAPI set_negrange(lprec *lp, REAL negrange); 2063 REAL __EXPORT_TYPE __WINAPI get_negrange(lprec *lp); 2064 2065 void __EXPORT_TYPE __WINAPI set_epsperturb(lprec *lp, REAL epsperturb); 2066 REAL __EXPORT_TYPE __WINAPI get_epsperturb(lprec *lp); 2067 2068 void __EXPORT_TYPE __WINAPI set_epspivot(lprec *lp, REAL epspivot); 2069 REAL __EXPORT_TYPE __WINAPI get_epspivot(lprec *lp); 2070 2071 int __EXPORT_TYPE __WINAPI get_max_level(lprec *lp); 2072 COUNTER __EXPORT_TYPE __WINAPI get_total_nodes(lprec *lp); 2073 COUNTER __EXPORT_TYPE __WINAPI get_total_iter(lprec *lp); 2074 2075 REAL __EXPORT_TYPE __WINAPI get_objective(lprec *lp); 2076 REAL __EXPORT_TYPE __WINAPI get_working_objective(lprec *lp); 2077 2078 REAL __EXPORT_TYPE __WINAPI get_var_primalresult(lprec *lp, int index); 2079 REAL __EXPORT_TYPE __WINAPI get_var_dualresult(lprec *lp, int index); 2080 2081 MYBOOL __EXPORT_TYPE __WINAPI get_variables(lprec *lp, REAL *var); 2082 MYBOOL __EXPORT_TYPE __WINAPI get_ptr_variables(lprec *lp, REAL **var); 2083 2084 MYBOOL __EXPORT_TYPE __WINAPI get_constraints(lprec *lp, REAL *constr); 2085 MYBOOL __EXPORT_TYPE __WINAPI get_ptr_constraints(lprec *lp, REAL **constr); 2086 2087 MYBOOL __EXPORT_TYPE __WINAPI get_sensitivity_rhs(lprec *lp, REAL *duals, REAL *dualsfrom, REAL *dualstill); 2088 MYBOOL __EXPORT_TYPE __WINAPI get_ptr_sensitivity_rhs(lprec *lp, REAL **duals, REAL **dualsfrom, REAL **dualstill); 2089 2090 MYBOOL __EXPORT_TYPE __WINAPI get_sensitivity_obj(lprec *lp, REAL *objfrom, REAL *objtill); 2091 MYBOOL __EXPORT_TYPE __WINAPI get_sensitivity_objex(lprec *lp, REAL *objfrom, REAL *objtill, REAL *objfromvalue, REAL *objtillvalue); 2092 MYBOOL __EXPORT_TYPE __WINAPI get_ptr_sensitivity_obj(lprec *lp, REAL **objfrom, REAL **objtill); 2093 MYBOOL __EXPORT_TYPE __WINAPI get_ptr_sensitivity_objex(lprec *lp, REAL **objfrom, REAL **objtill, REAL **objfromvalue, REAL **objtillvalue); 2094 2095 void __EXPORT_TYPE __WINAPI set_solutionlimit(lprec *lp, int limit); 2096 int __EXPORT_TYPE __WINAPI get_solutionlimit(lprec *lp); 2097 int __EXPORT_TYPE __WINAPI get_solutioncount(lprec *lp); 2098 2099 int __EXPORT_TYPE __WINAPI get_Norig_rows(lprec *lp); 2100 int __EXPORT_TYPE __WINAPI get_Nrows(lprec *lp); 2101 int __EXPORT_TYPE __WINAPI get_Lrows(lprec *lp); 2102 2103 int __EXPORT_TYPE __WINAPI get_Norig_columns(lprec *lp); 2104 int __EXPORT_TYPE __WINAPI get_Ncolumns(lprec *lp); 2105 2106 2107 #ifdef __cplusplus 2108 } 2109 #endif 2110 2111 2112 /* Forward definitions of functions used internaly by the lp toolkit */ 2113 MYBOOL set_callbacks(lprec *lp); 2114 STATIC int yieldformessages(lprec *lp); 2115 MYBOOL __WINAPI userabort(lprec *lp, int message); 2116 /*char * __VACALL explain(lprec *lp, char *format, ...); 2117 void __VACALL report(lprec *lp, int level, char *format, ...);*/ 2118 2119 /* Memory management routines */ 2120 STATIC MYBOOL append_rows(lprec *lp, int deltarows); 2121 STATIC MYBOOL append_columns(lprec *lp, int deltacolumns); 2122 STATIC void inc_rows(lprec *lp, int delta); 2123 STATIC void inc_columns(lprec *lp, int delta); 2124 STATIC MYBOOL init_rowcol_names(lprec *lp); 2125 STATIC MYBOOL inc_row_space(lprec *lp, int deltarows); 2126 STATIC MYBOOL inc_col_space(lprec *lp, int deltacols); 2127 STATIC MYBOOL shift_rowcoldata(lprec *lp, int base, int delta, LLrec *usedmap, MYBOOL isrow); 2128 STATIC MYBOOL shift_basis(lprec *lp, int base, int delta, LLrec *usedmap, MYBOOL isrow); 2129 STATIC MYBOOL shift_rowdata(lprec *lp, int base, int delta, LLrec *usedmap); 2130 STATIC MYBOOL shift_coldata(lprec *lp, int base, int delta, LLrec *usedmap); 2131 2132 /* INLINE */ MYBOOL is_chsign(lprec *lp, int rownr); 2133 2134 STATIC MYBOOL inc_lag_space(lprec *lp, int deltarows, MYBOOL ignoreMAT); 2135 lprec *make_lag(lprec *server); 2136 2137 REAL get_rh_upper(lprec *lp, int rownr); 2138 REAL get_rh_lower(lprec *lp, int rownr); 2139 MYBOOL set_rh_upper(lprec *lp, int rownr, REAL value); 2140 MYBOOL set_rh_lower(lprec *lp, int rownr, REAL value); 2141 STATIC int bin_count(lprec *lp, MYBOOL working); 2142 STATIC int MIP_count(lprec *lp); 2143 STATIC int SOS_count(lprec *lp); 2144 STATIC int GUB_count(lprec *lp); 2145 STATIC int identify_GUB(lprec *lp, MYBOOL mark); 2146 STATIC int prepare_GUB(lprec *lp); 2147 2148 STATIC MYBOOL refactRecent(lprec *lp); 2149 STATIC MYBOOL check_if_less(lprec *lp, REAL x, REAL y, int variable); 2150 STATIC MYBOOL feasiblePhase1(lprec *lp, REAL epsvalue); 2151 STATIC void free_duals(lprec *lp); 2152 STATIC void initialize_solution(lprec *lp, MYBOOL shiftbounds); 2153 STATIC void recompute_solution(lprec *lp, MYBOOL shiftbounds); 2154 STATIC int verify_solution(lprec *lp, MYBOOL reinvert, char *info); 2155 STATIC int check_solution(lprec *lp, int lastcolumn, REAL *solution, 2156 REAL *upbo, REAL *lowbo, REAL tolerance); 2157 /* INLINE */ MYBOOL is_fixedvar(lprec *lp, int variable); 2158 /* INLINE */ MYBOOL is_splitvar(lprec *lp, int colnr); 2159 2160 #if 0 2161 MYBOOL is_fixedvar(lprec *lp, int variable) 2162 { 2163 if((lp->bb_bounds != NULL && lp->bb_bounds->UBzerobased) || (variable <= lp->rows)) 2164 return( (MYBOOL) (lp->upbo[variable] < lp->epsprimal) ); 2165 else 2166 return( (MYBOOL) (lp->upbo[variable]-lp->lowbo[variable] < lp->epsprimal) ); 2167 } /* is_fixedvar */ 2168 #endif 2169 2170 void __WINAPI set_action(int *actionvar, int actionmask); 2171 void __WINAPI clear_action(int *actionvar, int actionmask); 2172 MYBOOL __WINAPI is_action(int actionvar, int testmask); 2173 2174 #if 0 2175 INLINE MYBOOL is_bb_rule(lprec *lp, int bb_rule); 2176 #endif 2177 /* INLINE */ MYBOOL is_bb_mode(lprec *lp, int bb_mask); 2178 /* INLINE */ int get_piv_rule(lprec *lp); 2179 STATIC char *get_str_piv_rule(int rule); 2180 STATIC MYBOOL __WINAPI set_var_priority(lprec *lp); 2181 STATIC int find_sc_bbvar(lprec *lp, int *count); 2182 STATIC int find_sos_bbvar(lprec *lp, int *count, MYBOOL intsos); 2183 STATIC int find_int_bbvar(lprec *lp, int *count, BBrec *BB, MYBOOL *isfeasible); 2184 2185 /* Solution-related functions */ 2186 STATIC REAL compute_dualslacks(lprec *lp, int target, REAL **dvalues, int **nzdvalues, MYBOOL dosum); 2187 STATIC MYBOOL solution_is_int(lprec *lp, int index, MYBOOL checkfixed); 2188 STATIC MYBOOL bb_better(lprec *lp, int target, int mode); 2189 STATIC void construct_solution(lprec *lp, REAL *target); 2190 STATIC void transfer_solution_var(lprec *lp, int uservar); 2191 STATIC MYBOOL construct_duals(lprec *lp); 2192 STATIC MYBOOL construct_sensitivity_duals(lprec *lp); 2193 STATIC MYBOOL construct_sensitivity_obj(lprec *lp); 2194 2195 STATIC int add_GUB(lprec *lp, char *name, int priority, int count, int *sosvars); 2196 STATIC basisrec *push_basis(lprec *lp, int *basisvar, MYBOOL *isbasic, MYBOOL *islower); 2197 STATIC MYBOOL compare_basis(lprec *lp); 2198 STATIC MYBOOL restore_basis(lprec *lp); 2199 STATIC MYBOOL pop_basis(lprec *lp, MYBOOL restore); 2200 STATIC MYBOOL is_BasisReady(lprec *lp); 2201 STATIC MYBOOL is_slackbasis(lprec *lp); 2202 STATIC MYBOOL verify_basis(lprec *lp); 2203 STATIC int unload_basis(lprec *lp, MYBOOL restorelast); 2204 2205 STATIC int perturb_bounds(lprec *lp, BBrec *perturbed, MYBOOL doRows, MYBOOL doCols, MYBOOL includeFIXED); 2206 STATIC MYBOOL validate_bounds(lprec *lp, REAL *upbo, REAL *lowbo); 2207 STATIC MYBOOL impose_bounds(lprec *lp, REAL * upbo, REAL *lowbo); 2208 STATIC int unload_BB(lprec *lp); 2209 2210 STATIC REAL feasibilityOffset(lprec *lp, MYBOOL isdual); 2211 STATIC MYBOOL isP1extra(lprec *lp); 2212 STATIC REAL get_refactfrequency(lprec *lp, MYBOOL final); 2213 STATIC int findBasicFixedvar(lprec *lp, int afternr, MYBOOL slacksonly); 2214 STATIC MYBOOL isBasisVarFeasible(lprec *lp, REAL tol, int basis_row); 2215 STATIC MYBOOL isPrimalFeasible(lprec *lp, REAL tol, int infeasibles[], REAL *feasibilitygap); 2216 STATIC MYBOOL isDualFeasible(lprec *lp, REAL tol, int *boundflips, int infeasibles[], REAL *feasibilitygap); 2217 2218 /* Main simplex driver routines */ 2219 STATIC int preprocess(lprec *lp); 2220 STATIC void postprocess(lprec *lp); 2221 STATIC MYBOOL performiteration(lprec *lp, int rownr, int varin, LREAL theta, MYBOOL primal, MYBOOL allowminit, REAL *prow, int *nzprow, REAL *pcol, int *nzpcol, int *boundswaps); 2222 STATIC void transfer_solution_var(lprec *lp, int uservar); 2223 STATIC void transfer_solution(lprec *lp, MYBOOL dofinal); 2224 2225 /* Scaling utilities */ 2226 STATIC REAL scaled_floor(lprec *lp, int colnr, REAL value, REAL epsscale); 2227 STATIC REAL scaled_ceil(lprec *lp, int colnr, REAL value, REAL epsscale); 2228 2229 /* Variable mapping utility routines */ 2230 STATIC void varmap_lock(lprec *lp); 2231 STATIC void varmap_clear(lprec *lp); 2232 STATIC MYBOOL varmap_canunlock(lprec *lp); 2233 STATIC void varmap_addconstraint(lprec *lp); 2234 STATIC void varmap_addcolumn(lprec *lp); 2235 STATIC void varmap_delete(lprec *lp, int base, int delta, LLrec *varmap); 2236 STATIC void varmap_compact(lprec *lp, int prev_rows, int prev_cols); 2237 STATIC MYBOOL varmap_validate(lprec *lp, int varno); 2238 STATIC MYBOOL del_varnameex(lprec *lp, hashelem **namelist, hashtable *ht, int varnr, LLrec *varmap); 2239 2240 /* Pseudo-cost routines (internal) */ 2241 STATIC BBPSrec *init_pseudocost(lprec *lp, int pseudotype); 2242 STATIC void free_pseudocost(lprec *lp); 2243 STATIC REAL get_pseudorange(BBPSrec *pc, int mipvar, int varcode); 2244 STATIC void update_pseudocost(BBPSrec *pc, int mipvar, int varcode, MYBOOL capupper, REAL varsol); 2245 STATIC REAL get_pseudobranchcost(BBPSrec *pc, int mipvar, MYBOOL dofloor); 2246 STATIC REAL get_pseudonodecost(BBPSrec *pc, int mipvar, int vartype, REAL varsol); 2247 2248 /* Matrix access and equation solving routines */ 2249 STATIC void set_OF_override(lprec *lp, REAL *ofVector); 2250 STATIC void set_OF_p1extra(lprec *lp, REAL p1extra); 2251 STATIC void unset_OF_p1extra(lprec *lp); 2252 MYBOOL modifyOF1(lprec *lp, int index, REAL *ofValue, REAL mult); 2253 REAL __WINAPI get_OF_active(lprec *lp, int varnr, REAL mult); 2254 STATIC MYBOOL is_OF_nz(lprec *lp, int colnr); 2255 2256 STATIC int get_basisOF(lprec *lp, int coltarget[], REAL crow[], int colno[]); 2257 int __WINAPI get_basiscolumn(lprec *lp, int j, int rn[], double bj[]); 2258 int __WINAPI obtain_column(lprec *lp, int varin, REAL *pcol, int *nzlist, int *maxabs); 2259 STATIC int compute_theta(lprec *lp, int rownr, LREAL *theta, int isupbound, REAL HarrisScalar, MYBOOL primal); 2260 2261 /* Pivot utility routines */ 2262 STATIC int findBasisPos(lprec *lp, int notint, int *var_basic); 2263 STATIC MYBOOL check_degeneracy(lprec *lp, REAL *pcol, int *degencount); 2264 2265 typedef int (__WINAPI read_modeldata_func)(void *userhandle, char *buf, int max_size); 2266 typedef int (__WINAPI write_modeldata_func)(void *userhandle, char *buf); 2267 MYBOOL __WINAPI MPS_readex(lprec **newlp, void *userhandle, read_modeldata_func read_modeldata, int typeMPS, int verbose); 2268 #if defined develop 2269 lprec __EXPORT_TYPE * __WINAPI read_lpex(void *userhandle, read_modeldata_func read_modeldata, int verbose, char *lp_name); 2270 MYBOOL __EXPORT_TYPE __WINAPI write_lpex(lprec *lp, void *userhandle, write_modeldata_func write_modeldata); 2271 2272 lprec __EXPORT_TYPE * __WINAPI read_mpsex(void *userhandle, read_modeldata_func read_modeldata, int verbose); 2273 lprec __EXPORT_TYPE * __WINAPI read_freempsex(void *userhandle, read_modeldata_func read_modeldata, int verbose); 2274 2275 MYBOOL MPS_writefileex(lprec *lp, int typeMPS, void *userhandle, write_modeldata_func write_modeldata); 2276 #endif 2277 2278 #endif /* HEADER_lp_lib */ 2279