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