Changeset 2019
 Timestamp:
 Mar 11, 2014 5:10:15 PM (5 years ago)
 Location:
 trunk/Cbc
 Files:

 3 edited
Legend:
 Unmodified
 Added
 Removed

trunk/Cbc/src/Cbc_C_Interface.cpp
r2016 r2019 26 26 #define CBC_EXTERN_C 27 27 #include "Coin_C_defines.h" 28 29 #define CbcGetProperty(T,prop) \ 30 COINLIBAPI T COINLINKAGE \ 31 Cbc_ ## prop (Cbc_Model *m) \ 32 { \ 33 return m>model_>prop(); \ 34 } 28 35 29 36 const int VERBOSE = 0; … … 227 234 if (VERBOSE > 0) printf("%s begin\n", prefix); 228 235 229 Cbc_Model * model = new Cbc_Model ;236 Cbc_Model * model = new Cbc_Model(); 230 237 OsiClpSolverInterface solver1; 231 238 model>solver_ = &solver1; … … 234 241 CbcMain0(*model>model_); 235 242 model>handler_ = NULL; 236 model>information_ = NULL;237 243 238 244 if (VERBOSE > 0) printf("%s return\n", prefix); … … 255 261 fflush(stdout); 256 262 delete model>handler_; 257 258 if (VERBOSE > 1) printf("%s free model>information_\n", prefix);259 fflush(stdout);260 if (model>information_) free(model>information_);261 263 262 264 if (VERBOSE > 1) printf("%s delete model\n", prefix); … … 344 346 if (VERBOSE > 1) printf("%s filename = '%s'\n", prefix, filename); 345 347 346 model>model_>solver()>writeMps(filename, "mps", Cbc_ optimizationDirection(model));348 model>model_>solver()>writeMps(filename, "mps", Cbc_getObjSense(model)); 347 349 348 350 if (VERBOSE > 0) printf("%s return\n", prefix); 349 351 return; 350 352 } 351 /* Integer information */ 352 COINLIBAPI char * COINLINKAGE 353 Cbc_integerInformation(Cbc_Model * model) 354 { 355 const char prefix[] = "Cbc_C_Interface::Cbc_integerInformation(): "; 356 // const int VERBOSE = 1; 357 if (VERBOSE > 0) printf("%s begin\n", prefix); 358 359 int col; 360 int numcols = Cbc_getNumCols(model); 361 362 // allocate model>information_ if null 363 // this is freed in Cbc_deleteModel() if not null 364 if (!model>information_) 365 model>information_ = (char *) malloc(numcols * sizeof(char)); 366 367 for (col = 0; col < numcols; col++) 368 if (model>model_>solver()>isContinuous(col)) 369 model>information_[col] = 0; 370 else 371 model>information_[col] = 1; 372 373 char * result = model>information_; 374 375 if (VERBOSE > 0) printf("%s return %p\n", prefix, result); 376 return result; 377 } 378 /* Copy in integer information */ 379 COINLIBAPI void COINLINKAGE 380 Cbc_copyInIntegerInformation(Cbc_Model * model, const char * information) 381 { 382 const char prefix[] = "Cbc_C_Interface::Cbc_copyInIntegerInformation(): "; 383 // const int VERBOSE = 1; 384 if (VERBOSE > 0) printf("%s begin\n", prefix); 385 386 int col; 387 int numcols = Cbc_getNumCols(model); 388 for (col = 0; col < numcols; col++) 389 if (information[col]) 390 model>model_>solver()>setInteger(col); 391 else 392 model>model_>solver()>setContinuous(col); 393 394 if (VERBOSE > 0) printf("%s return\n", prefix); 395 } 396 /* Drop integer informations */ 397 COINLIBAPI void COINLINKAGE 398 Cbc_deleteIntegerInformation(Cbc_Model * /*model*/) 399 { 400 const char prefix[] = "Cbc_C_Interface::Cbc_deleteIntegerInformation(): "; 401 // const int VERBOSE = 1; 402 if (VERBOSE > 0) printf("%s begin\n", prefix); 403 404 // available through 405 // OsiClpSolverInterface::setContinuous 406 //tbd model>model_>deleteIntegerInformation(); 407 if (VERBOSE > 0) printf("%s WARNING: NOT IMPLEMENTED\n", prefix); 408 409 if (VERBOSE > 0) printf("%s return\n", prefix); 410 } 411 /* Resizes rim part of model */ 412 COINLIBAPI void COINLINKAGE 413 Cbc_resize (Cbc_Model * /*model*/, int /*newNumberRows*/, 414 int /*newNumberColumns*/) 415 { 416 const char prefix[] = "Cbc_C_Interface::Cbc_resize(): "; 417 // const int VERBOSE = 1; 418 if (VERBOSE > 0) printf("%s begin\n", prefix); 419 420 // cannot find this in Cbc, Osi, or OsiClp 421 //tbd model>model_>solver()>resize(newNumberRows,newNumberColumns); 422 if (VERBOSE > 0) printf("%s WARNING: NOT IMPLEMENTED\n", prefix); 423 424 if (VERBOSE > 0) printf("%s return\n", prefix); 425 } 353 426 354 /* Deletes rows */ 427 355 COINLIBAPI void COINLINKAGE … … 429 357 { 430 358 const char prefix[] = "Cbc_C_Interface::Cbc_deleteRows(): "; 431 // const int VERBOSE = 1;432 359 if (VERBOSE > 0) printf("%s begin\n", prefix); 433 360 … … 446 373 { 447 374 const char prefix[] = "Cbc_C_Interface::Cbc_addRows(): "; 448 // const int VERBOSE = 1;449 375 if (VERBOSE > 0) printf("%s begin\n", prefix); 450 376 … … 535 461 } 536 462 537 /* Number of rows */538 COINLIBAPI int COINLINKAGE539 Cbc_numberRows(Cbc_Model * model)540 {541 const char prefix[] = "Cbc_C_Interface::Cbc_numberRows(): ";542 // const int VERBOSE = 1;543 if (VERBOSE > 0) printf("%s begin\n", prefix);544 545 int result = 0;546 result = model>model_>getNumRows();547 548 if (VERBOSE > 0) printf("%s return %i\n", prefix, result);549 return result;550 }551 /* Number of columns */552 COINLIBAPI int COINLINKAGE553 Cbc_numberColumns(Cbc_Model * model)554 {555 const char prefix[] = "Cbc_C_Interface::Cbc_numberColumns(): ";556 // const int VERBOSE = 1;557 if (VERBOSE > 0) printf("%s begin\n", prefix);558 559 int result = 0;560 result = model>model_>getNumCols();561 562 if (VERBOSE > 0) printf("%s return %i\n", prefix, result);563 return result;564 }565 /* Primal tolerance to use */566 COINLIBAPI double COINLINKAGE567 Cbc_primalTolerance(Cbc_Model * model)568 {569 const char prefix[] = "Cbc_C_Interface::Cbc_primalTolerance(): ";570 // const int VERBOSE = 1;571 if (VERBOSE > 0) printf("%s begin\n", prefix);572 573 double result = 0.0;574 model>model_>solver()>getDblParam(OsiPrimalTolerance, result) ;575 576 if (VERBOSE > 0) printf("%s return %g\n", prefix, result);577 return result;578 }579 COINLIBAPI void COINLINKAGE580 Cbc_setPrimalTolerance(Cbc_Model * model, double value)581 {582 const char prefix[] = "Cbc_C_Interface::Cbc_setPrimalTolerance(): ";583 // const int VERBOSE = 1;584 if (VERBOSE > 0) printf("%s begin\n", prefix);585 586 model>model_>solver()>setDblParam(OsiPrimalTolerance, value) ;587 588 if (VERBOSE > 0) printf("%s return\n", prefix);589 }590 /* Dual tolerance to use */591 COINLIBAPI double COINLINKAGE592 Cbc_dualTolerance(Cbc_Model * model)593 {594 const char prefix[] = "Cbc_C_Interface::Cbc_dualTolerance(): ";595 // const int VERBOSE = 1;596 if (VERBOSE > 0) printf("%s begin\n", prefix);597 598 double result = 0.0;599 model>model_>solver()>getDblParam(OsiDualTolerance, result) ;600 601 if (VERBOSE > 0) printf("%s return %g\n", prefix, result);602 return result;603 }604 COINLIBAPI void COINLINKAGE605 Cbc_setDualTolerance(Cbc_Model * model, double value)606 {607 const char prefix[] = "Cbc_C_Interface::Cbc_setDualTolerance(): ";608 // const int VERBOSE = 1;609 if (VERBOSE > 0) printf("%s begin\n", prefix);610 611 model>model_>solver()>setDblParam(OsiDualTolerance, value) ;612 613 if (VERBOSE > 0) printf("%s return\n", prefix);614 }615 /* Integer tolerance to use */616 COINLIBAPI double COINLINKAGE617 Cbc_integerTolerance(Cbc_Model * model)618 {619 const char prefix[] = "Cbc_C_Interface::Cbc_primalTolerance(): ";620 // const int VERBOSE = 1;621 if (VERBOSE > 0) printf("%s begin\n", prefix);622 623 double result = 0.0;624 result = model>model_>getDblParam(CbcModel::CbcIntegerTolerance) ;625 626 if (VERBOSE > 0) printf("%s return %g\n", prefix, result);627 return result;628 }629 COINLIBAPI void COINLINKAGE630 Cbc_setIntegerTolerance(Cbc_Model * model, double value)631 {632 const char prefix[] = "Cbc_C_Interface::Cbc_setPrimalTolerance(): ";633 // const int VERBOSE = 1;634 if (VERBOSE > 0) printf("%s begin\n", prefix);635 636 model>model_>setDblParam(CbcModel::CbcIntegerTolerance, value) ;637 638 if (VERBOSE > 0) printf("%s return\n", prefix);639 }640 /* Dual objective limit */641 COINLIBAPI double COINLINKAGE642 Cbc_dualObjectiveLimit(Cbc_Model * model)643 {644 const char prefix[] = "Cbc_C_Interface::Cbc_dualObjectiveLimit(): ";645 // const int VERBOSE = 1;646 if (VERBOSE > 0) printf("%s begin\n", prefix);647 648 double result = 0.0;649 model>model_>solver()>getDblParam(OsiDualObjectiveLimit, result) ;650 651 if (VERBOSE > 0) printf("%s return %g\n", prefix, result);652 return result;653 }654 COINLIBAPI void COINLINKAGE655 Cbc_setDualObjectiveLimit(Cbc_Model * model, double value)656 {657 const char prefix[] = "Cbc_C_Interface::Cbc_setDualObjectiveLimit(): ";658 // const int VERBOSE = 1;659 if (VERBOSE > 0) printf("%s begin\n", prefix);660 661 model>model_>solver()>setDblParam(OsiDualObjectiveLimit, value) ;662 663 if (VERBOSE > 0) printf("%s return\n", prefix);664 }665 463 /* Objective offset */ 666 464 COINLIBAPI double COINLINKAGE … … 721 519 if (VERBOSE > 0) printf("%s return\n", prefix); 722 520 return (result) ? 1 : 0; 723 }724 /* Number of iterations */725 COINLIBAPI int COINLINKAGE726 Cbc_numberIterations(Cbc_Model * model)727 {728 const char prefix[] = "Cbc_C_Interface::Cbc_numberIterations(): ";729 // const int VERBOSE = 1;730 if (VERBOSE > 0) printf("%s begin\n", prefix);731 732 int result = 0;733 result = model>model_>getIterationCount();734 735 if (VERBOSE > 0) printf("%s return %i\n", prefix, result);736 return result;737 }738 COINLIBAPI void COINLINKAGE739 Cbc_setNumberIterations(Cbc_Model * /*model*/, int /*numberIterations*/)740 {741 const char prefix[] = "Cbc_C_Interface::Cbc_setNumberIterations(): ";742 // const int VERBOSE = 1;743 if (VERBOSE > 0) printf("%s begin\n", prefix);744 745 // cannot find this in Cbc, Osi, or OsiClp746 //tbd model>model_>setNumberIterations(numberIterations);747 if (VERBOSE > 0) printf("%s WARNING: NOT IMPLEMENTED\n", prefix);748 749 if (VERBOSE > 0) printf("%s return\n", prefix);750 return;751 }752 /* Maximum number of iterations */753 COINLIBAPI int COINLINKAGE754 Cbc_maximumIterations(Cbc_Model * /*model*/)755 {756 const char prefix[] = "Cbc_C_Interface::Cbc_maximumIterations(): ";757 // const int VERBOSE = 1;758 if (VERBOSE > 0) printf("%s begin\n", prefix);759 760 int result = 0;761 // cannot find this in Cbc, Osi, or OsiClp762 //tbd result = model>model_>solver()>maximumIterations();763 if (VERBOSE > 0) printf("%s WARNING: NOT IMPLEMENTED\n", prefix);764 765 if (VERBOSE > 0) printf("%s return %i\n", prefix, result);766 return result;767 }768 COINLIBAPI void COINLINKAGE769 Cbc_setMaximumIterations(Cbc_Model * /*model*/, int /*value*/)770 {771 const char prefix[] = "Cbc_C_Interface::Cbc_setMaximumIterations(): ";772 // const int VERBOSE = 1;773 if (VERBOSE > 0) printf("%s begin\n", prefix);774 775 // cannot find this in Cbc, Osi, or OsiClp776 //tbd model>model_>setMaximumIterations(value);777 if (VERBOSE > 0) printf("%s WARNING: NOT IMPLEMENTED\n", prefix);778 779 if (VERBOSE > 0) printf("%s return\n", prefix);780 }781 /* Maximum number of nodes */782 COINLIBAPI int COINLINKAGE783 Cbc_maxNumNode(Cbc_Model * model)784 {785 const char prefix[] = "Cbc_C_Interface::Cbc_maxNumNode(): ";786 // const int VERBOSE = 1;787 if (VERBOSE > 0) printf("%s begin\n", prefix);788 789 int result = 0;790 result = model>model_>getIntParam(CbcModel::CbcMaxNumNode);791 792 if (VERBOSE > 0) printf("%s return %i\n", prefix, result);793 return result;794 }795 COINLIBAPI void COINLINKAGE796 Cbc_setMaxNumNode(Cbc_Model * model, int value)797 {798 const char prefix[] = "Cbc_C_Interface::Cbc_setMaxNumNode(): ";799 // const int VERBOSE = 1;800 if (VERBOSE > 0) printf("%s begin\n", prefix);801 802 model>model_>setIntParam(CbcModel::CbcMaxNumNode, value);803 804 if (VERBOSE > 0) printf("%s return\n", prefix);805 }806 /* Maximum number of solutions */807 COINLIBAPI int COINLINKAGE808 Cbc_maxNumSol(Cbc_Model * model)809 {810 const char prefix[] = "Cbc_C_Interface::maxNumSol(): ";811 // const int VERBOSE = 1;812 if (VERBOSE > 0) printf("%s begin\n", prefix);813 814 int result = 0;815 result = model>model_>getIntParam(CbcModel::CbcMaxNumSol);816 817 if (VERBOSE > 0) printf("%s return %i\n", prefix, result);818 return result;819 }820 COINLIBAPI void COINLINKAGE821 Cbc_setMaxNumSol(Cbc_Model * model, int value)822 {823 const char prefix[] = "Cbc_C_Interface::Cbc_setMaxNumSol(): ";824 // const int VERBOSE = 1;825 if (VERBOSE > 0) printf("%s begin\n", prefix);826 827 model>model_>setIntParam(CbcModel::CbcMaxNumSol, value);828 829 if (VERBOSE > 0) printf("%s return\n", prefix);830 }831 /* Maximum time in seconds (from when set called) */832 COINLIBAPI double COINLINKAGE833 Cbc_maximumSeconds(Cbc_Model * model)834 {835 const char prefix[] = "Cbc_C_Interface::Cbc_maximumSeconds(): ";836 // const int VERBOSE = 1;837 if (VERBOSE > 0) printf("%s begin\n", prefix);838 839 double result = 0.0;840 result = model>model_>getDblParam(CbcModel::CbcMaximumSeconds);841 842 if (VERBOSE > 0) printf("%s return %g\n", prefix, result);843 return result;844 }845 COINLIBAPI void COINLINKAGE846 Cbc_setMaximumSeconds(Cbc_Model * model, double value)847 {848 const char prefix[] = "Cbc_C_Interface::Cbc_setMaximumSeconds(): ";849 // const int VERBOSE = 1;850 if (VERBOSE > 0) printf("%s begin\n", prefix);851 852 model>model_>setDblParam(CbcModel::CbcMaximumSeconds, value);853 854 if (VERBOSE > 0) printf("%s return\n", prefix);855 }856 /* Returns true if hit maximum iteratio`ns (or time) */857 COINLIBAPI int COINLINKAGE858 Cbc_hitMaximumIterations(Cbc_Model * /*model*/)859 {860 const char prefix[] = "Cbc_C_Interface::Cbc_hitMaximumIterations(): ";861 // const int VERBOSE = 1;862 if (VERBOSE > 0) printf("%s begin\n", prefix);863 864 int result = 0;865 // cannot find names in Cbc, Osi, or OsiClp866 //tbd result = model>model_>solver()>hitMaximumIterations() ? 1 : 0;867 if (VERBOSE > 0) printf("%s WARNING: NOT IMPLEMENTED\n", prefix);868 869 if (VERBOSE > 0) printf("%s return %i\n", prefix, result);870 return result;871 521 } 872 522 /* Status of problem: … … 877 527 4  stopped due to errors 878 528 */ 879 COINLIBAPI int COINLINKAGE 880 Cbc_status(Cbc_Model * model) 881 { 882 const char prefix[] = "Cbc_C_Interface::Cbc_status(): "; 883 // const int VERBOSE = 1; 884 if (VERBOSE > 0) printf("%s begin\n", prefix); 885 886 int result = 0; 887 result = model>model_>status(); 888 889 if (VERBOSE > 0) printf("%s return %i\n", prefix, result); 890 return result; 891 } 892 /* Set problem status */ 893 COINLIBAPI void COINLINKAGE 894 Cbc_setProblemStatus(Cbc_Model * /*model*/, int /*problemStatus*/) 895 { 896 const char prefix[] = "Cbc_C_Interface::Cbc_setProblemStatus(): "; 897 // const int VERBOSE = 1; 898 if (VERBOSE > 0) printf("%s begin\n", prefix); 899 900 // cannot find this in Cbc, Osi, or OsiClp 901 //tbd model>model_>setProblemStatus(problemStatus); 902 if (VERBOSE > 0) printf("%s WARNING: NOT IMPLEMENTED\n", prefix); 903 904 if (VERBOSE > 0) printf("%s return\n", prefix); 905 } 529 CbcGetProperty(int, status) 530 906 531 /* Secondary status of problem  may get extended 907 532 0  none … … 911 536 4  scaled problem optimal  unscaled has both dual and primal infeasibilities 912 537 */ 913 COINLIBAPI int COINLINKAGE 914 Cbc_secondaryStatus(Cbc_Model * model) 915 { 916 const char prefix[] = "Cbc_C_Interface::Cbc_secondaryStatus(): "; 917 // const int VERBOSE = 1; 918 if (VERBOSE > 0) printf("%s begin\n", prefix); 919 920 int result = 0; 921 // cannot find this in Cbc, Osi, or OsiClp 922 result = model>model_>secondaryStatus(); 923 if (VERBOSE > 0) printf("%s WARNING: NOT IMPLEMENTED\n", prefix); 924 925 if (VERBOSE > 0) printf("%s return %i\n", prefix, result); 926 return result; 927 } 538 CbcGetProperty(int, secondaryStatus) 539 928 540 COINLIBAPI void COINLINKAGE 929 541 Cbc_setSecondaryStatus(Cbc_Model * /*model*/, int /*status*/) … … 939 551 if (VERBOSE > 0) printf("%s return\n", prefix); 940 552 } 941 /* Direction of optimization (1  minimize, 1  maximize, 0  ignore */ 942 COINLIBAPI double COINLINKAGE 943 Cbc_optimizationDirection(Cbc_Model * model) 944 { 945 const char prefix[] = "Cbc_C_Interface::Cbc_optimizationDirection(): "; 946 // const int VERBOSE = 1; 947 if (VERBOSE > 0) printf("%s begin\n", prefix); 948 949 double result = 0.0; 950 result = model>model_>getObjSense(); 951 952 if (VERBOSE > 0) printf("%s return %g\n", prefix, result); 953 return result; 954 } 955 COINLIBAPI void COINLINKAGE 956 Cbc_setOptimizationDirection(Cbc_Model * model, double value) 957 { 958 const char prefix[] = "Cbc_C_Interface::Cbc_setOptimizationDirection(): "; 959 // const int VERBOSE = 1; 960 if (VERBOSE > 0) printf("%s begin, value = %g\n", prefix, value); 961 962 model>model_>setObjSense(value); 963 // model>model_>solver()>setObjSense(value); 964 965 if (VERBOSE > 0) printf("%s return\n", prefix); 966 } 967 /* Primal row solution */ 968 COINLIBAPI double * COINLINKAGE 969 Cbc_primalRowSolution(Cbc_Model * /*model*/) 970 { 971 const char prefix[] = "Cbc_C_Interface::Cbc_primalRowSolution(): "; 972 // const int VERBOSE = 1; 973 if (VERBOSE > 0) printf("%s begin\n", prefix); 974 975 double * result = NULL; 976 977 // cannot find this in Cbc, Osi, or OsiClp 978 // may have to make it somehow 979 //tbd return model>model_>primalRowSolution(); 980 if (VERBOSE > 0) printf("%s WARNING: NOT IMPLEMENTED\n", prefix); 981 982 if (VERBOSE > 0) printf("%s return %p\n", prefix, static_cast<void*>(result)); 983 return result; 984 } 985 /* Primal column solution */ 986 COINLIBAPI double * COINLINKAGE 987 Cbc_primalColumnSolution(Cbc_Model * /*model*/) 988 { 989 const char prefix[] = "Cbc_C_Interface::Cbc_primalColumnSolution(): "; 990 // const int VERBOSE = 1; 991 if (VERBOSE > 0) printf("%s begin\n", prefix); 992 993 double * result = NULL; 994 // cannot find this in Cbc, Osi, or OsiClp 995 // may have to make it somehow 996 // result = model>model_>getColSolution(); 997 if (VERBOSE > 0) printf("%s WARNING: NOT IMPLEMENTED\n", prefix); 998 999 if (VERBOSE > 0) printf("%s return %p\n", prefix, static_cast<void*>(result)); 1000 return result; 1001 } 1002 /* Dual row solution */ 1003 COINLIBAPI double * COINLINKAGE 1004 Cbc_dualRowSolution(Cbc_Model * /*model*/) 1005 { 1006 const char prefix[] = "Cbc_C_Interface::Cbc_dualRowSolution(): "; 1007 // const int VERBOSE = 1; 1008 if (VERBOSE > 0) printf("%s begin\n", prefix); 1009 1010 double * result = NULL; 1011 // cannot find this in Cbc, Osi, or OsiClp 1012 // may have to make it somehow 1013 //tbd return model>model_>dualRowSolution(); 1014 if (VERBOSE > 0) printf("%s WARNING: NOT IMPLEMENTED\n", prefix); 1015 1016 if (VERBOSE > 0) printf("%s return %p\n", prefix, static_cast<void*>(result)); 1017 return NULL; 1018 } 1019 /* Reduced costs */ 1020 COINLIBAPI double * COINLINKAGE 1021 Cbc_dualColumnSolution(Cbc_Model * /*model*/) 1022 { 1023 const char prefix[] = "Cbc_C_Interface::Cbc_dualColumnSolution(): "; 1024 // const int VERBOSE = 1; 1025 if (VERBOSE > 0) printf("%s begin\n", prefix); 1026 1027 double * result = NULL; 1028 // cannot find this in Cbc, Osi, or OsiClp 1029 // may have to make it somehow 1030 //tbd return model>model_>dualColumnSolution(); 1031 if (VERBOSE > 0) printf("%s WARNING: NOT IMPLEMENTED\n", prefix); 1032 1033 if (VERBOSE > 0) printf("%s return %p\n", prefix, static_cast<void*>(result)); 1034 return NULL; 1035 } 1036 /* Row lower */ 1037 COINLIBAPI double * COINLINKAGE 1038 Cbc_rowLower(Cbc_Model * /*model*/) 1039 { 1040 const char prefix[] = "Cbc_C_Interface::Cbc_rowLower(): "; 1041 // const int VERBOSE = 1; 1042 if (VERBOSE > 0) printf("%s begin\n", prefix); 1043 1044 double * result = NULL; 1045 // cannot find this in Cbc, Osi, or OsiClp 1046 // may have to make it somehow 1047 //tbd return model>model_>rowLower(); 1048 if (VERBOSE > 0) printf("%s WARNING: NOT IMPLEMENTED\n", prefix); 1049 1050 if (VERBOSE > 0) printf("%s return %p\n", prefix, static_cast<void*>(result)); 1051 return NULL; 1052 } 1053 /* Row upper */ 1054 COINLIBAPI double * COINLINKAGE 1055 Cbc_rowUpper(Cbc_Model * /*model*/) 1056 { 1057 const char prefix[] = "Cbc_C_Interface::Cbc_rowUpper(): "; 1058 // const int VERBOSE = 1; 1059 if (VERBOSE > 0) printf("%s begin\n", prefix); 1060 1061 double * result = NULL; 1062 // cannot find this in Cbc, Osi, or OsiClp 1063 // may have to make it somehow 1064 //tbd return model>model_>rowUpper(); 1065 if (VERBOSE > 0) printf("%s WARNING: NOT IMPLEMENTED\n", prefix); 1066 1067 if (VERBOSE > 0) printf("%s return %p\n", prefix, static_cast<void*>(result)); 1068 return NULL; 1069 } 1070 /* Objective Coefficients */ 1071 COINLIBAPI double * COINLINKAGE 1072 Cbc_objective(Cbc_Model * /*model*/) 1073 { 1074 const char prefix[] = "Cbc_C_Interface::Cbc_objective(): "; 1075 // const int VERBOSE = 1; 1076 if (VERBOSE > 0) printf("%s begin\n", prefix); 1077 1078 double * result = NULL; 1079 // cannot find this in Cbc, Osi, or OsiClp 1080 // may have to make it somehow 1081 // result = model>model_>objective(); 1082 if (VERBOSE > 0) printf("%s WARNING: NOT IMPLEMENTED\n", prefix); 1083 1084 if (VERBOSE > 0) printf("%s return %p\n", prefix, static_cast<void*>(result)); 1085 return NULL; 1086 } 1087 /* Column Lower */ 1088 COINLIBAPI double * COINLINKAGE 1089 Cbc_columnLower(Cbc_Model * /*model*/) 1090 { 1091 const char prefix[] = "Cbc_C_Interface::Cbc_columnLower(): "; 1092 // const int VERBOSE = 1; 1093 if (VERBOSE > 0) printf("%s begin\n", prefix); 1094 1095 double * result = NULL; 1096 // cannot find this in Cbc, Osi, or OsiClp 1097 // may have to make it somehow 1098 //tbd return model>model_>columnLower(); 1099 if (VERBOSE > 0) printf("%s WARNING: NOT IMPLEMENTED\n", prefix); 1100 1101 if (VERBOSE > 0) printf("%s return %p\n", prefix, static_cast<void*>(result)); 1102 return NULL; 1103 } 1104 /* Column Upper */ 1105 COINLIBAPI double * COINLINKAGE 1106 Cbc_columnUpper(Cbc_Model * /*model*/) 1107 { 1108 const char prefix[] = "Cbc_C_Interface::Cbc_columnUpper(): "; 1109 // const int VERBOSE = 1; 1110 if (VERBOSE > 0) printf("%s begin\n", prefix); 1111 1112 double * result = NULL; 1113 // cannot find this in Cbc, Osi, or OsiClp 1114 // may have to make it somehow 1115 //tbd return model>model_>columnUpper(); 1116 if (VERBOSE > 0) printf("%s WARNING: NOT IMPLEMENTED\n", prefix); 1117 1118 if (VERBOSE > 0) printf("%s return %p\n", prefix, static_cast<void*>(result)); 1119 return NULL; 1120 } 553 1121 554 /* Number of elements in matrix */ 1122 555 COINLIBAPI int COINLINKAGE … … 1197 630 // ====================================================================== 1198 631 1199 /* Objective value */ 1200 COINLIBAPI double COINLINKAGE 1201 Cbc_objectiveValue(Cbc_Model * model) 1202 { 1203 const char prefix[] = "Cbc_C_Interface::Cbc_objectiveValue(): "; 1204 // const int VERBOSE = 1; 1205 if (VERBOSE > 0) printf("%s begin\n", prefix); 1206 1207 double result = 0.0; 1208 result = model>model_>getObjValue(); 1209 1210 if (VERBOSE > 0) printf("%s return %g\n", prefix, result); 1211 return result; 1212 } 1213 /* Infeasibility/unbounded ray (NULL returned if none/wrong) 1214 Up to user to use delete [] on these arrays. */ 1215 COINLIBAPI double * COINLINKAGE 1216 Cbc_infeasibilityRay(Cbc_Model * /*model*/) 1217 { 1218 const char prefix[] = "Cbc_C_Interface::Cbc_infeasibilityRay(): "; 1219 // const int VERBOSE = 1; 1220 if (VERBOSE > 0) printf("%s begin\n", prefix); 1221 1222 double * result = NULL; 1223 // lots of rays (probably too many) are available in 1224 // OsiClpSolverInterface::getDualRays() 1225 // 1226 //tbd result = model>model_>infeasibilityRay(); 1227 if (VERBOSE > 0) printf("%s WARNING: NOT IMPLEMENTED\n", prefix); 1228 1229 if (VERBOSE > 0) printf("%s return %p\n", prefix, static_cast<void*>(result)); 1230 return result; 1231 } 1232 COINLIBAPI double * COINLINKAGE 1233 Cbc_unboundedRay(Cbc_Model * /*model*/) 1234 { 1235 const char prefix[] = "Cbc_C_Interface::Cbc_unboundedRay(): "; 1236 // const int VERBOSE = 1; 1237 if (VERBOSE > 0) printf("%s begin\n", prefix); 1238 1239 double * result = NULL; 1240 // lots of rays (probably too many) are available in 1241 // OsiClpSolverInterface::getPrimalRays() 1242 // 1243 //tbd result = model>model_>unboundedRay(); 1244 if (VERBOSE > 0) printf("%s WARNING: NOT IMPLEMENTED\n", prefix); 1245 1246 if (VERBOSE > 0) printf("%s return %p\n", prefix, static_cast<void*>(result)); 1247 return result; 1248 } 1249 /* See if status array exists (partly for OsiClp) */ 1250 COINLIBAPI int COINLINKAGE 1251 Cbc_statusExists(Cbc_Model * /*model*/) 1252 { 1253 const char prefix[] = "Cbc_C_Interface::Cbc_statusExists(): "; 1254 // const int VERBOSE = 1; 1255 if (VERBOSE > 0) printf("%s begin\n", prefix); 1256 1257 int result = 0; 1258 //tbd result = model>model_>statusExists() ? 1 : 0; 1259 if (VERBOSE > 0) printf("%s WARNING: NOT IMPLEMENTED\n", prefix); 1260 1261 if (VERBOSE > 0) printf("%s return %i\n", prefix, result); 1262 return result; 1263 } 1264 /* Return address of status array (char[numberRows+numberColumns]) */ 1265 COINLIBAPI void COINLINKAGE 1266 Cbc_getBasisStatus(Cbc_Model * /*model*/, int * /*cstat*/, int * /*rstat*/) 1267 { 1268 const char prefix[] = "Cbc_C_Interface::Cbc_getBasisStatus(): "; 1269 // const int VERBOSE = 1; 1270 if (VERBOSE > 0) printf("%s begin\n", prefix); 1271 1272 // have to figure this out 1273 //tbd model>model_>solver()>getBasisStatus(cstat, rstat); 1274 if (VERBOSE > 0) printf("%s WARNING: NOT IMPLEMENTED\n", prefix); 1275 1276 if (VERBOSE > 0) printf("%s return\n", prefix); 1277 return; 1278 } 1279 /* Copy in status vector */ 1280 COINLIBAPI void COINLINKAGE 1281 Cbc_setBasisStatus(Cbc_Model * /*model*/, int * /*cstat*/, int * /*rstat*/) 1282 { 1283 const char prefix[] = "Cbc_C_Interface::Cbc_setBasisStatus(): "; 1284 // const int VERBOSE = 1; 1285 if (VERBOSE > 0) printf("%s begin\n", prefix); 1286 1287 // model>model_>solver()>setBasisStatus(cstat, rstat); 1288 if (VERBOSE > 0) printf("%s WARNING: NOT IMPLEMENTED\n", prefix); 1289 1290 if (VERBOSE > 0) printf("%s return\n", prefix); 1291 } 1292 1293 /* User pointer for whatever reason */ 1294 COINLIBAPI void COINLINKAGE 1295 Cbc_setUserPointer (Cbc_Model * /*model*/, void * /*pointer*/) 1296 { 1297 const char prefix[] = "Cbc_C_Interface::Cbc_setUserPointer(): "; 1298 // const int VERBOSE = 1; 1299 if (VERBOSE > 0) printf("%s begin\n", prefix); 1300 1301 // not sure what this is for 1302 // 1303 //tbd model>model_>setUserPointer(pointer); 1304 if (VERBOSE > 0) printf("%s WARNING: NOT IMPLEMENTED\n", prefix); 1305 1306 if (VERBOSE > 0) printf("%s return\n", prefix); 1307 } 1308 COINLIBAPI void * COINLINKAGE 1309 Cbc_getUserPointer (Cbc_Model * /*model*/) 1310 { 1311 const char prefix[] = "Cbc_C_Interface::Cbc_getUserPointer(): "; 1312 // const int VERBOSE = 1; 1313 if (VERBOSE > 0) printf("%s begin\n", prefix); 1314 1315 void * result = NULL; 1316 // not sure what this is for 1317 // 1318 //tbd result = model>model_>getUserPointer(); 1319 if (VERBOSE > 0) printf("%s WARNING: NOT IMPLEMENTED\n", prefix); 1320 1321 if (VERBOSE > 0) printf("%s return %p\n", prefix, result); 1322 return result; 1323 } 632 633 1324 634 /* Pass in Callback function */ 1325 635 COINLIBAPI void COINLINKAGE … … 1356 666 if (VERBOSE > 0) printf("%s return\n", prefix); 1357 667 } 1358 /* Amount of print out:1359 0  none1360 1  just final1361 2  just factorizations1362 3  as 2 plus a bit more1363 4  verbose1364 above that 8,16,32 etc just for selective debug1365 */1366 COINLIBAPI void COINLINKAGE1367 Cbc_setLogLevel(Cbc_Model * model, int value)1368 {1369 const char prefix[] = "Cbc_C_Interface::Cbc_setLogLevel(): ";1370 // const int VERBOSE = 1;1371 if (VERBOSE > 0) printf("%s begin\n", prefix);1372 if (VERBOSE > 1) printf("%s value = %i\n", prefix, value);1373 1374 model>model_>messageHandler()>setLogLevel(value);1375 1376 if (VERBOSE > 0) printf("%s return\n", prefix);1377 }1378 COINLIBAPI int COINLINKAGE1379 Cbc_logLevel(Cbc_Model * model)1380 {1381 const char prefix[] = "Cbc_C_Interface::Cbc_logLevel(): ";1382 // const int VERBOSE = 1;1383 if (VERBOSE > 0) printf("%s begin\n", prefix);1384 1385 int result = 0;1386 result = model>model_>messageHandler()>logLevel();1387 1388 if (VERBOSE > 0) printf("%s return %i\n", prefix, result);1389 return result;1390 }1391 668 /* length of names (0 means no names0 */ 1392 669 COINLIBAPI int COINLINKAGE … … 1436 713 } 1437 714 1438 /* General branch and bound solve algorithm which can do presolve.1439 See CbcSolve.hpp for options1440 */1441 COINLIBAPI int COINLINKAGE1442 Cbc_initialSolve(Cbc_Model * model)1443 {1444 const char prefix[] = "Cbc_C_Interface::Cbc_initialSolve(): ";1445 // const int VERBOSE = 1;1446 if (VERBOSE > 0) printf("%s begin\n", prefix);1447 1448 int result = 0;1449 model>model_>initialSolve();1450 result = model>model_>status();1451 1452 if (VERBOSE > 0) printf("%s return %i\n", prefix, result);1453 return result;1454 }1455 /* General solve algorithm which can do presolve.1456 See CbcModel.hpp for options1457 */1458 COINLIBAPI int COINLINKAGE1459 Cbc_branchAndBound(Cbc_Model * model)1460 {1461 const char prefix[] = "Cbc_C_Interface::Cbc_branchAndBound(): ";1462 // const int VERBOSE = 3;1463 if (VERBOSE > 0) printf("%s begin\n", prefix);1464 1465 int result = 0;1466 if (VERBOSE > 2) Cbc_printModel(model, prefix);1467 try {1468 model>model_>branchAndBound();1469 model>model_>solver()>resolve();1470 } catch (CoinError e) {1471 printf("%s ERROR: %s::%s, %s\n", prefix,1472 e.className().c_str(), e.methodName().c_str(), e.message().c_str());1473 }1474 result = model>model_>status();1475 1476 if (VERBOSE > 0) printf("%s return %i\n", prefix, result);1477 return result;1478 }1479 715 COINLIBAPI int COINLINKAGE 1480 716 Cbc_solve(Cbc_Model * model) … … 1494 730 return result; 1495 731 } 1496 /* Sets or unsets scaling, 0 off, 1 equilibrium, 2 geometric, 3, auto, 4 dynamic(later) */ 1497 COINLIBAPI void COINLINKAGE 1498 Cbc_scaling(Cbc_Model * model, int mode) 1499 { 1500 const char prefix[] = "Cbc_C_Interface::Cbc_scaling(): "; 1501 // const int VERBOSE = 1; 1502 if (VERBOSE > 0) printf("%s begin\n", prefix); 1503 1504 OsiSolverInterface * solver = model>model_>solver(); 1505 bool modeBool = (mode == 0); 1506 solver>setHintParam(OsiDoScale, modeBool); 1507 1508 if (VERBOSE > 0) printf("%s return\n", prefix); 1509 } 1510 /* Gets scalingFlag */ 1511 COINLIBAPI int COINLINKAGE 1512 Cbc_scalingFlag(Cbc_Model * /*model*/) 1513 { 1514 const char prefix[] = "Cbc_C_Interface::Cbc_scalingFlag(): "; 1515 // const int VERBOSE = 1; 1516 if (VERBOSE > 0) printf("%s begin\n", prefix); 1517 1518 int result = 0; 1519 // try to use OsiSolverInterface::getHintParam(OsiDoScale, ???) 1520 //tbd result = model>model_>scalingFlag(); 1521 if (VERBOSE > 0) printf("%s WARNING: NOT IMPLEMENTED\n", prefix); 1522 1523 if (VERBOSE > 0) printf("%s return %i\n", prefix, result); 1524 return result; 1525 } 1526 /* Crash  at present just aimed at dual, returns 1527 2 if dual preferred and crash basis created 1528 1 if dual preferred and all slack basis preferred 1529 0 if basis going in was not all slack 1530 1 if primal preferred and all slack basis preferred 1531 2 if primal preferred and crash basis created. 1532 1533 if gap between bounds <="gap" variables can be flipped 1534 1535 If "pivot" is 1536 0 No pivoting (so will just be choice of algorithm) 1537 1 Simple pivoting e.g. gub 1538 2 Mini iterations 1539 */ 1540 COINLIBAPI int COINLINKAGE 1541 Cbc_crash(Cbc_Model * /*model*/, double /*gap*/, int /*pivot*/) 1542 { 1543 const char prefix[] = "Cbc_C_Interface::Cbc_crash(): "; 1544 // const int VERBOSE = 1; 1545 if (VERBOSE > 0) printf("%s begin\n", prefix); 1546 1547 int result = 0; 1548 // cannot find names in Cbc, Osi, or OsiClp 1549 //tbd result = model>model_>crash(gap,pivot); 1550 if (VERBOSE > 0) printf("%s WARNING: NOT IMPLEMENTED\n", prefix); 1551 1552 if (VERBOSE > 0) printf("%s return %i\n", prefix, result); 1553 return result; 1554 } 1555 /* If problem is primal feasible */ 1556 COINLIBAPI int COINLINKAGE 1557 Cbc_primalFeasible(Cbc_Model * model) 1558 { 1559 const char prefix[] = "Cbc_C_Interface::Cbc_primalFeasible(): "; 1560 // const int VERBOSE = 1; 1561 if (VERBOSE > 0) printf("%s begin\n", prefix); 1562 1563 int result = 0; 1564 OsiSolverInterface * solver = model>model_>solver(); 1565 result = solver>isProvenPrimalInfeasible() ? 0 : 1; 1566 1567 if (VERBOSE > 0) printf("%s return %i\n", prefix, result); 1568 return result; 1569 } 1570 /* If problem is dual feasible */ 1571 COINLIBAPI int COINLINKAGE 1572 Cbc_dualFeasible(Cbc_Model * model) 1573 { 1574 const char prefix[] = "Cbc_C_Interface::Cbc_dualFeasible(): "; 1575 // const int VERBOSE = 1; 1576 if (VERBOSE > 0) printf("%s begin\n", prefix); 1577 1578 int result = 0; 1579 OsiSolverInterface * solver = model>model_>solver(); 1580 result = solver>isProvenDualInfeasible() ? 0 : 1; 1581 1582 if (VERBOSE > 0) printf("%s return %i\n", prefix, result); 1583 return result; 1584 } 1585 /* Dual bound */ 1586 COINLIBAPI double COINLINKAGE 1587 Cbc_dualBound(Cbc_Model * /*model*/) 1588 { 1589 const char prefix[] = "Cbc_C_Interface::Cbc_dualBound(): "; 1590 // const int VERBOSE = 1; 1591 if (VERBOSE > 0) printf("%s begin\n", prefix); 1592 1593 double result = 0; 1594 // cannot find in Cbc, Osi, or OsiClp 1595 //tbd result = model>model_>dualBound(); 1596 if (VERBOSE > 0) printf("%s WARNING: NOT IMPLEMENTED\n", prefix); 1597 1598 if (VERBOSE > 0) printf("%s return %g\n", prefix, result); 1599 return result; 1600 } 1601 COINLIBAPI void COINLINKAGE 1602 Cbc_setDualBound(Cbc_Model * /*model*/, double /*value*/) 1603 { 1604 const char prefix[] = "Cbc_C_Interface::Cbc_setDualBound(): "; 1605 // const int VERBOSE = 1; 1606 if (VERBOSE > 0) printf("%s begin\n", prefix); 1607 1608 // cannot find names in Cbc, Osi, or OsiClp 1609 //tbd model>model_>setDualBound(value); 1610 if (VERBOSE > 0) printf("%s WARNING: NOT IMPLEMENTED\n", prefix); 1611 1612 if (VERBOSE > 0) printf("%s return\n", prefix); 1613 } 1614 /* Infeasibility cost */ 1615 COINLIBAPI double COINLINKAGE 1616 Cbc_infeasibilityCost(Cbc_Model * /*model*/) 1617 { 1618 const char prefix[] = "Cbc_C_Interface::Cbc_infeasibilityCost(): "; 1619 // const int VERBOSE = 1; 1620 if (VERBOSE > 0) printf("%s begin\n", prefix); 1621 1622 double result = 0; 1623 // cannot find names in Cbc, Osi, or OsiClp 1624 //tbd result = model>model_>solver()>infeasibilityCost(); 1625 if (VERBOSE > 0) printf("%s WARNING: NOT IMPLEMENTED\n", prefix); 1626 1627 if (VERBOSE > 0) printf("%s return %g\n", prefix, result); 1628 return result; 1629 } 1630 COINLIBAPI void COINLINKAGE 1631 Cbc_setInfeasibilityCost(Cbc_Model * /*model*/, double /*value*/) 1632 { 1633 const char prefix[] = "Cbc_C_Interface::Cbc_setInfeasibilityCost(): "; 1634 // const int VERBOSE = 1; 1635 if (VERBOSE > 0) printf("%s begin\n", prefix); 1636 1637 // cannot find names in Cbc, Osi, or OsiClp 1638 //tbd model>model_>setInfeasibilityCost(value); 1639 if (VERBOSE > 0) printf("%s WARNING: NOT IMPLEMENTED\n", prefix); 1640 1641 if (VERBOSE > 0) printf("%s return\n", prefix); 1642 } 1643 /* Perturbation: 1644 50  switch on perturbation 1645 100  auto perturb if takes too long (1.0e6 largest nonzero) 1646 101  we are perturbed 1647 102  don't try perturbing again 1648 default is 100 1649 others are for playing 1650 */ 1651 COINLIBAPI int COINLINKAGE 1652 Cbc_perturbation(Cbc_Model * /*model*/) 1653 { 1654 const char prefix[] = "Cbc_C_Interface::Cbc_perturbation(): "; 1655 // const int VERBOSE = 1; 1656 if (VERBOSE > 0) printf("%s begin\n", prefix); 1657 1658 int result = 0; 1659 // cannot find names in Cbc, Osi, or OsiClp 1660 //tbd result = model>model_>perturbation(); 1661 if (VERBOSE > 0) printf("%s WARNING: NOT IMPLEMENTED\n", prefix); 1662 1663 if (VERBOSE > 0) printf("%s return %i\n", prefix, result); 1664 return result; 1665 } 1666 COINLIBAPI void COINLINKAGE 1667 Cbc_setPerturbation(Cbc_Model * /*model*/, int /*value*/) 1668 { 1669 const char prefix[] = "Cbc_C_Interface::Cbc_setPerturbation(): "; 1670 // const int VERBOSE = 1; 1671 if (VERBOSE > 0) printf("%s begin\n", prefix); 1672 1673 // cannot find names in Cbc, Osi, or OsiClp 1674 //tbd model>model_>setPerturbation(value); 1675 if (VERBOSE > 0) printf("%s WARNING: NOT IMPLEMENTED\n", prefix); 1676 1677 if (VERBOSE > 0) printf("%s return\n", prefix); 1678 } 1679 /* Current (or last) algorithm */ 1680 COINLIBAPI int COINLINKAGE 1681 Cbc_algorithm(Cbc_Model * /*model*/) 1682 { 1683 const char prefix[] = "Cbc_C_Interface::Cbc_setPerturbation(): "; 1684 // const int VERBOSE = 1; 1685 if (VERBOSE > 0) printf("%s begin\n", prefix); 1686 1687 int result = 0; 1688 // cannot find names in Cbc, Osi, or OsiClp 1689 //tbd result = model>model_>algorithm(); 1690 if (VERBOSE > 0) printf("%s WARNING: NOT IMPLEMENTED\n", prefix); 1691 1692 if (VERBOSE > 0) printf("%s return %i\n", prefix, result); 1693 return result; 1694 } 1695 /* Set algorithm */ 1696 COINLIBAPI void COINLINKAGE 1697 Cbc_setAlgorithm(Cbc_Model * /*model*/, int /*value*/) 1698 { 1699 const char prefix[] = "Cbc_C_Interface::Cbc_setAlgorithm(): "; 1700 // const int VERBOSE = 1; 1701 if (VERBOSE > 0) printf("%s begin\n", prefix); 1702 1703 // cannot find names in Cbc, Osi, or OsiClp 1704 //tbd model>model_>setAlgorithm(value); 1705 if (VERBOSE > 0) printf("%s WARNING: NOT IMPLEMENTED\n", prefix); 1706 1707 if (VERBOSE > 0) printf("%s return\n", prefix); 1708 } 1709 /* Sum of dual infeasibilities */ 1710 COINLIBAPI double COINLINKAGE 1711 Cbc_sumDualInfeasibilities(Cbc_Model * /*model*/) 1712 { 1713 const char prefix[] = "Cbc_C_Interface::Cbc_sumDualInfeasibilities(): "; 1714 // const int VERBOSE = 1; 1715 if (VERBOSE > 0) printf("%s begin\n", prefix); 1716 1717 double result = 0; 1718 // cannot find names in Cbc, Osi, or OsiClp 1719 //tbd result = model>model_>sumDualInfeasibilities(); 1720 if (VERBOSE > 0) printf("%s WARNING: NOT IMPLEMENTED\n", prefix); 1721 1722 if (VERBOSE > 0) printf("%s return %g\n", prefix, result); 1723 return result; 1724 } 1725 /* Number of dual infeasibilities */ 1726 COINLIBAPI int COINLINKAGE 1727 Cbc_numberDualInfeasibilities(Cbc_Model * /*model*/) 1728 { 1729 const char prefix[] = "Cbc_C_Interface::Cbc_numberDualInfeasibilities(): "; 1730 // const int VERBOSE = 1; 1731 if (VERBOSE > 0) printf("%s begin\n", prefix); 1732 1733 int result = 0; 1734 // cannot find names in Cbc, Osi, or OsiClp 1735 //tbd result = model>model_>numberDualInfeasibilities(); 1736 if (VERBOSE > 0) printf("%s WARNING: NOT IMPLEMENTED\n", prefix); 1737 1738 if (VERBOSE > 0) printf("%s return %i\n", prefix, result); 1739 return result; 1740 } 732 1741 733 /* Sum of primal infeasibilities */ 1742 734 COINLIBAPI double COINLINKAGE … … 1770 762 return result; 1771 763 } 1772 /* Save model to file, returns 0 if success. This is designed for 1773 use outside algorithms so does not save iterating arrays etc. 1774 It does not save any messaging information. 1775 Does not save scaling values. 1776 It does not know about all types of virtual functions. 1777 */ 1778 COINLIBAPI int COINLINKAGE 1779 Cbc_saveModel(Cbc_Model * /*model*/, const char * /*fileName*/) 1780 { 1781 const char prefix[] = "Cbc_C_Interface::Cbc_saveModel(): "; 1782 // const int VERBOSE = 1; 1783 if (VERBOSE > 0) printf("%s begin\n", prefix); 1784 1785 int result = 0; 1786 // there is a writeMPS method in Osi 1787 //tbd result = model>model_>saveModel(fileName); 1788 if (VERBOSE > 0) printf("%s WARNING: NOT IMPLEMENTED\n", prefix); 1789 1790 if (VERBOSE > 0) printf("%s return %i\n", prefix, result); 1791 return result; 1792 } 1793 /* Restore model from file, returns 0 if success, 1794 deletes current model */ 1795 COINLIBAPI int COINLINKAGE 1796 Cbc_restoreModel(Cbc_Model * /*model*/, const char * /*fileName*/) 1797 { 1798 const char prefix[] = "Cbc_C_Interface::Cbc_restoreModel(): "; 1799 // const int VERBOSE = 1; 1800 if (VERBOSE > 0) printf("%s begin\n", prefix); 1801 1802 int result = 0; 1803 // there is a readMPS method in Osi 1804 //tbd result = model>model_>restoreModel(fileName); 1805 if (VERBOSE > 0) printf("%s WARNING: NOT IMPLEMENTED\n", prefix); 1806 1807 if (VERBOSE > 0) printf("%s return %i\n", prefix, result); 1808 return result; 1809 } 764 1810 765 1811 766 /** Call this to really test if a valid solution can be feasible … … 1828 783 return; 1829 784 } 1830 /* Number of rows */ 1831 COINLIBAPI int COINLINKAGE 1832 Cbc_getNumRows(Cbc_Model * model) 1833 { 1834 const char prefix[] = "Cbc_C_Interface::Cbc_getNumRows(): "; 1835 // const int VERBOSE = 1; 1836 if (VERBOSE > 0) printf("%s begin\n", prefix); 1837 1838 int result = 0; 1839 result = model>model_>getNumRows(); 1840 1841 if (VERBOSE > 0) printf("%s return %d\n", prefix, result); 1842 return result; 1843 } 1844 /* Number of columns */ 1845 COINLIBAPI int COINLINKAGE 1846 Cbc_getNumCols(Cbc_Model * model) 1847 { 1848 const char prefix[] = "Cbc_C_Interface::Cbc_getNumCols(): "; 1849 // const int VERBOSE = 1; 1850 if (VERBOSE > 0) printf("%s begin\n", prefix); 1851 1852 int result = 0; 1853 result = model>model_>getNumCols(); 1854 1855 if (VERBOSE > 0) printf("%s return %d\n", prefix, result); 1856 return result; 1857 } 1858 /* Number of iterations */ 1859 COINLIBAPI int COINLINKAGE 1860 Cbc_getIterationCount(Cbc_Model * model) 1861 { 1862 const char prefix[] = "Cbc_C_Interface::Cbc_getIterationCount(): "; 1863 // const int VERBOSE = 1; 1864 if (VERBOSE > 0) printf("%s begin\n", prefix); 1865 1866 int result = 0; 1867 result = model>model_>getIterationCount(); 1868 1869 if (VERBOSE > 0) printf("%s return %d\n", prefix, result); 1870 return result; 1871 } 1872 /* Are there a numerical difficulties? */ 1873 COINLIBAPI int COINLINKAGE 1874 Cbc_isAbandoned(Cbc_Model * model) 1875 { 1876 const char prefix[] = "Cbc_C_Interface::Cbc_isAbandoned(): "; 1877 // const int VERBOSE = 1; 1878 if (VERBOSE > 0) printf("%s begin\n", prefix); 1879 1880 int result = 0; 1881 result = model>model_>isAbandoned() ? 1 : 0; 1882 1883 if (VERBOSE > 0) printf("%s return %i\n", prefix, result); 1884 return result; 1885 } 1886 /* Is optimality proven? */ 1887 COINLIBAPI int COINLINKAGE 1888 Cbc_isProvenOptimal(Cbc_Model * model) 1889 { 1890 const char prefix[] = "Cbc_C_Interface::Cbc_isProvenOptimal(): "; 1891 // const int VERBOSE = 1; 1892 if (VERBOSE > 0) printf("%s begin\n", prefix); 1893 1894 int result = 0; 1895 result = model>model_>isProvenOptimal() ? 1 : 0; 1896 1897 if (VERBOSE > 0) printf("%s return %i\n", prefix, result); 1898 return result; 1899 } 1900 /* Is primal infeasiblity proven? */ 1901 COINLIBAPI int COINLINKAGE 1902 Cbc_isProvenPrimalInfeasible(Cbc_Model * model) 1903 { 1904 const char prefix[] = "Cbc_C_Interface::Cbc_isProvenPrimalInfeasible(): "; 1905 // const int VERBOSE = 1; 1906 if (VERBOSE > 0) printf("%s begin\n", prefix); 1907 1908 int result = 0; 1909 OsiSolverInterface * solver = model>model_>solver(); 1910 result = solver>isProvenPrimalInfeasible() ? 1 : 0; 1911 1912 if (VERBOSE > 0) printf("%s return %i\n", prefix, result); 1913 return result; 1914 } 1915 /* Is dual infeasiblity proven? */ 1916 COINLIBAPI int COINLINKAGE 1917 Cbc_isProvenDualInfeasible(Cbc_Model * model) 1918 { 1919 const char prefix[] = "Cbc_C_Interface::Cbc_isProvenDualInfeasible(): "; 1920 // const int VERBOSE = 1; 1921 if (VERBOSE > 0) printf("%s begin\n", prefix); 1922 1923 int result = 0; 1924 OsiSolverInterface * solver = model>model_>solver(); 1925 result = solver>isProvenDualInfeasible() ? 1 : 0; 1926 1927 if (VERBOSE > 0) printf("%s return %i\n", prefix, result); 1928 return result; 1929 } 1930 /* Is the given primal objective limit reached? */ 1931 COINLIBAPI int COINLINKAGE 1932 Cbc_isPrimalObjectiveLimitReached(Cbc_Model * model) 1933 { 1934 const char prefix[] = "Cbc_C_Interface::Cbc_isPrimalObjectiveLimitReached(): "; 1935 // const int VERBOSE = 1; 1936 if (VERBOSE > 0) printf("%s begin\n", prefix); 1937 1938 int result = 0; 1939 OsiSolverInterface * solver = model>model_>solver(); 1940 result = solver>isPrimalObjectiveLimitReached() ? 1 : 0; 1941 1942 if (VERBOSE > 0) printf("%s return %i\n", prefix, result); 1943 return result; 1944 } 1945 /* Is the given dual objective limit reached? */ 1946 COINLIBAPI int COINLINKAGE 1947 Cbc_isDualObjectiveLimitReached(Cbc_Model * model) 1948 { 1949 const char prefix[] = "Cbc_C_Interface::Cbc_isDualObjectiveLimitReached(): "; 1950 // const int VERBOSE = 1; 1951 if (VERBOSE > 0) printf("%s begin\n", prefix); 1952 1953 int result = 0; 1954 OsiSolverInterface * solver = model>model_>solver(); 1955 result = solver>isDualObjectiveLimitReached() ? 1 : 0; 1956 1957 if (VERBOSE > 0) printf("%s return %i\n", prefix, result); 1958 return result; 1959 } 1960 /* Iteration limit reached? */ 1961 COINLIBAPI int COINLINKAGE 1962 Cbc_isIterationLimitReached(Cbc_Model * model) 1963 { 1964 const char prefix[] = "Cbc_C_Interface::Cbc_isIterationLimitReached(): "; 1965 // const int VERBOSE = 1; 1966 if (VERBOSE > 0) printf("%s begin\n", prefix); 1967 1968 int result = 0; 1969 OsiSolverInterface * solver = model>model_>solver(); 1970 result = solver>isIterationLimitReached() ? 1 : 0; 1971 1972 if (VERBOSE > 0) printf("%s return %i\n", prefix, result); 1973 return result; 1974 } 1975 /* Direction of optimization (1  minimize, 1  maximize, 0  ignore */ 1976 COINLIBAPI double COINLINKAGE 1977 Cbc_getObjSense(Cbc_Model * model) 1978 { 1979 const char prefix[] = "Cbc_C_Interface::Cbc_getObjSense(): "; 1980 // const int VERBOSE = 1; 1981 if (VERBOSE > 0) printf("%s begin\n", prefix); 1982 1983 double result = 0; 1984 result = model>model_>getObjSense(); 1985 1986 if (VERBOSE > 0) printf("%s return %g\n", prefix, result); 1987 return result; 1988 } 1989 /* Primal row solution */ 1990 COINLIBAPI const double * COINLINKAGE 1991 Cbc_getRowActivity(Cbc_Model * model) 1992 { 1993 const char prefix[] = "Cbc_C_Interface::Cbc_getRowActivity(): "; 1994 // const int VERBOSE = 1; 1995 if (VERBOSE > 0) printf("%s begin\n", prefix); 1996 1997 const double * result = NULL; 1998 result = model>model_>getRowActivity(); 1999 2000 if (VERBOSE > 0) 2001 printf("%s return %p\n", prefix, static_cast<const void*>(result)); 2002 return result; 2003 } 2004 /* Primal column solution */ 2005 COINLIBAPI const double * COINLINKAGE 2006 Cbc_getColSolution(Cbc_Model * model) 2007 { 2008 const char prefix[] = "Cbc_C_Interface::Cbc_getColSolution(): "; 2009 // const int VERBOSE = 1; 2010 if (VERBOSE > 0) printf("%s begin\n", prefix); 2011 2012 const double * result = NULL; 2013 result = model>model_>getColSolution(); 2014 2015 if (VERBOSE > 0) 2016 printf("%s return %p\n", prefix, static_cast<const void*>(result)); 2017 return result; 2018 } 785 786 787 788 CbcGetProperty(int, getNumCols) 789 CbcGetProperty(int, getNumRows) 790 CbcGetProperty(int, getIterationCount) 791 CbcGetProperty(int, isAbandoned) 792 CbcGetProperty(int, isProvenOptimal) 793 CbcGetProperty(int, isProvenInfeasible) 794 CbcGetProperty(int, isContinuousUnbounded) 795 CbcGetProperty(int, isNodeLimitReached) 796 CbcGetProperty(int, isSecondsLimitReached) 797 CbcGetProperty(int, isSolutionLimitReached) 798 CbcGetProperty(int, isInitialSolveAbandoned) 799 CbcGetProperty(int, isInitialSolveProvenOptimal) 800 CbcGetProperty(int, isInitialSolveProvenPrimalInfeasible) 801 802 CbcGetProperty(double, getObjSense) 803 804 COINLIBAPI void COINLINKAGE 805 Cbc_setObjSense(Cbc_Model * model, double sense) 806 { 807 model>model_>setObjSense(sense); 808 } 809 810 CbcGetProperty(const double*, getRowActivity) 811 CbcGetProperty(const double*, getColSolution) 812 2019 813 COINLIBAPI void COINLINKAGE 2020 814 Cbc_setColSolution(Cbc_Model * model, const double * input) … … 2030 824 return; 2031 825 } 2032 /* Dual row solution */ 2033 COINLIBAPI const double * COINLINKAGE 2034 Cbc_getRowPrice(Cbc_Model * model) 2035 { 2036 const char prefix[] = "Cbc_C_Interface::Cbc_getRowPrice(): "; 2037 // const int VERBOSE = 1; 2038 if (VERBOSE > 0) printf("%s begin\n", prefix); 2039 2040 const double * result = NULL; 2041 result = model>model_>getRowPrice(); 2042 2043 if (VERBOSE > 0) 2044 printf("%s return %p\n", prefix, static_cast<const void*>(result)); 2045 return result; 2046 } 2047 /* Reduced costs */ 2048 COINLIBAPI const double * COINLINKAGE 2049 Cbc_getReducedCost(Cbc_Model * model) 2050 { 2051 const char prefix[] = "Cbc_C_Interface::Cbc_getReducedCost(): "; 2052 // const int VERBOSE = 1; 2053 if (VERBOSE > 0) printf("%s begin\n", prefix); 2054 2055 const double * result = NULL; 2056 result = model>model_>getReducedCost(); 2057 2058 if (VERBOSE > 0) 2059 printf("%s return %p\n", prefix, static_cast<const void*>(result)); 2060 return result; 2061 } 2062 /* Row lower */ 2063 COINLIBAPI const double * COINLINKAGE 2064 Cbc_getRowLower(Cbc_Model * model) 2065 { 2066 const char prefix[] = "Cbc_C_Interface::Cbc_getRowLower(): "; 2067 // const int VERBOSE = 1; 2068 if (VERBOSE > 0) printf("%s begin\n", prefix); 2069 2070 const double * result = NULL; 2071 result = model>model_>getRowLower(); 2072 2073 if (VERBOSE > 0) 2074 printf("%s return %p\n", prefix, static_cast<const void*>(result)); 2075 return result; 2076 } 2077 /* Row upper */ 2078 COINLIBAPI const double * COINLINKAGE 2079 Cbc_getRowUpper(Cbc_Model * model) 2080 { 2081 const char prefix[] = "Cbc_C_Interface::Cbc_getRowUpper(): "; 2082 // const int VERBOSE = 1; 2083 if (VERBOSE > 0) printf("%s begin\n", prefix); 2084 2085 const double * result = NULL; 2086 result = model>model_>getRowUpper(); 2087 2088 if (VERBOSE > 0) 2089 printf("%s return %p\n", prefix, static_cast<const void*>(result)); 2090 return result; 2091 } 2092 /* Objective Coefficients */ 2093 COINLIBAPI const double * COINLINKAGE 2094 Cbc_getObjCoefficients(Cbc_Model * model) 2095 { 2096 const char prefix[] = "Cbc_C_Interface::Cbc_getObjCoefficients(): "; 2097 // const int VERBOSE = 1; 2098 if (VERBOSE > 0) printf("%s begin\n", prefix); 2099 2100 const double * result = NULL; 2101 result = model>model_>getObjCoefficients(); 2102 2103 if (VERBOSE > 0) 2104 printf("%s return %p\n", prefix, static_cast<const void*>(result)); 2105 return result; 2106 } 2107 /* Column Lower */ 2108 COINLIBAPI const double * COINLINKAGE 2109 Cbc_getColLower(Cbc_Model * model) 2110 { 2111 const char prefix[] = "Cbc_C_Interface::Cbc_getColLower(): "; 2112 // const int VERBOSE = 1; 2113 if (VERBOSE > 0) printf("%s begin\n", prefix); 2114 2115 const double * result = NULL; 2116 result = model>model_>getColLower(); 2117 2118 if (VERBOSE > 0) 2119 printf("%s return %p\n", prefix, static_cast<const void*>(result)); 2120 return result; 2121 } 2122 /* Column Upper */ 2123 COINLIBAPI const double * COINLINKAGE 2124 Cbc_getColUpper(Cbc_Model * model) 2125 { 2126 const char prefix[] = "Cbc_C_Interface::Cbc_getColUpper(): "; 2127 // const int VERBOSE = 1; 2128 if (VERBOSE > 0) printf("%s begin\n", prefix); 2129 2130 const double * result = NULL; 2131 result = model>model_>getColUpper(); 2132 2133 if (VERBOSE > 0) 2134 printf("%s return %p\n", prefix, static_cast<const void*>(result)); 2135 return result; 2136 } 2137 /* Objective value */ 2138 COINLIBAPI double COINLINKAGE 2139 Cbc_getObjValue(Cbc_Model * model) 2140 { 2141 const char prefix[] = "Cbc_C_Interface::Cbc_getObjValue(): "; 2142 // const int VERBOSE = 1; 2143 if (VERBOSE > 0) printf("%s begin\n", prefix); 2144 2145 double result = 0; 2146 result = model>model_>getObjValue(); 2147 2148 if (VERBOSE > 0) 2149 printf("%s return %g\n", prefix, result); 2150 return result; 2151 } 826 827 CbcGetProperty(const double*, getRowLower) 828 CbcGetProperty(const double*, getRowUpper) 829 CbcGetProperty(const double*, getObjCoefficients) 830 CbcGetProperty(const double*, getColLower) 831 CbcGetProperty(const double*, getColUpper) 832 833 CbcGetProperty(double, getObjValue) 834 2152 835 /* Print model */ 2153 836 COINLIBAPI void COINLINKAGE … … 2191 874 static_cast<const void*>(colub), static_cast<const void*>(obj), 2192 875 static_cast<const void*>(rowlb), static_cast<const void*>(rowub)); 2193 printf("%s optimization direction = %g\n", argPrefix, Cbc_ optimizationDirection(model));876 printf("%s optimization direction = %g\n", argPrefix, Cbc_getObjSense(model)); 2194 877 printf(" (1  minimize, 1  maximize, 0  ignore)\n"); 2195 878 { … … 2233 916 return result; 2234 917 } 2235 /** Number of nodes explored in B&B tree */ 2236 COINLIBAPI int COINLINKAGE 2237 Cbc_getNodeCount(Cbc_Model * model) 2238 { 2239 const char prefix[] = "Cbc_C_Interface::Cbc_getNodeCount(): "; 2240 // const int VERBOSE = 1; 2241 if (VERBOSE > 0) printf("%s begin\n", prefix); 2242 2243 int result = 0; 2244 result = model>model_>getNodeCount() ; 2245 2246 if (VERBOSE > 0) printf("%s return %i\n", prefix, result); 2247 return result; 2248 } 918 919 CbcGetProperty(int, getNodeCount) 920 2249 921 /** Return a copy of this model */ 2250 922 COINLIBAPI Cbc_Model * COINLINKAGE … … 2255 927 if (VERBOSE > 0) printf("%s begin\n", prefix); 2256 928 2257 Cbc_Model * result = new Cbc_Model ;929 Cbc_Model * result = new Cbc_Model(); 2258 930 result>model_ = new CbcModel(*(model>model_)); 2259 931 result>solver_ = dynamic_cast< OsiClpSolverInterface*> (result>model_>solver()); … … 2272 944 2273 945 model>model_>solver()>setContinuous(iColumn); 946 947 if (VERBOSE > 0) printf("%s return\n", prefix); 948 return model; 949 } 950 /** Set this the variable to be integer */ 951 COINLIBAPI Cbc_Model * COINLINKAGE 952 Cbc_setInteger(Cbc_Model * model, int iColumn) 953 { 954 const char prefix[] = "Cbc_C_Interface::Cbc_setContinuous(): "; 955 // const int VERBOSE = 1; 956 if (VERBOSE > 0) printf("%s begin\n", prefix); 957 958 model>model_>solver()>setInteger(iColumn); 2274 959 2275 960 if (VERBOSE > 0) printf("%s return\n", prefix); … … 2340 1025 if (VERBOSE > 0) printf("%sbegin\n", prefix); 2341 1026 2342 int numRows = Cbc_ numberRows(model);1027 int numRows = Cbc_getNumRows(model); 2343 1028 if (VERBOSE > 0) printf("%s numRows = %i\n", prefix, numRows); 2344 1029 2345 1030 // The passed sparse matrix must have the same number of rows as the model 2346 assert(numRows == Cbc_ numberRows(model));1031 assert(numRows == Cbc_getNumRows(model)); 2347 1032 2348 1033 int row, i; … … 2452 1137 2453 1138 const double * rowPrimal = Cbc_getRowActivity(model); 2454 // * Alternatively getReducedCost(model)2455 const double * rowDual = Cbc_getRowPrice(model);2456 // * Alternatively getColLower(model)2457 1139 const double * rowLower = Cbc_getRowLower(model); 2458 // * Alternatively getColUpper(model)2459 1140 const double * rowUpper = Cbc_getRowUpper(model); 2460 1141 printf("\n"); … … 2463 1144 // assert(Cbc_lengthNames(model)); 2464 1145 2465 printf(" Primal DualLower Upper\n");1146 printf(" Primal Lower Upper\n"); 2466 1147 for (iRow = 0; iRow < numberRows; iRow++) { 2467 1148 double value; … … 2473 1154 printf("%6d %8s", iRow, name); 2474 1155 printf(" %13g", rowPrimal[iRow]); 2475 printf(" %13g", rowDual[iRow]);2476 1156 printf(" %13g", rowLower[iRow]); 2477 1157 printf(" %13g", rowUpper[iRow]); … … 2492 1172 // * Columns 2493 1173 2494 int numberColumns = Cbc_ numberColumns(model);1174 int numberColumns = Cbc_getNumCols(model); 2495 1175 int iColumn; 2496 1176 2497 1177 2498 // * Alternatively getColSolution(model)2499 1178 const double * columnPrimal = Cbc_getColSolution(model); 2500 // * Alternatively getReducedCost(model)2501 const double * columnDual = Cbc_getReducedCost(model);2502 // * Alternatively getColLower(model)2503 1179 const double * columnLower = Cbc_getColLower(model); 2504 // * Alternatively getColUpper(model)2505 1180 const double * columnUpper = Cbc_getColUpper(model); 2506 // * Alternatively getObjCoefficients(model)2507 1181 const double * columnObjective = Cbc_getObjCoefficients(model); 2508 2509 const char * isInteger = Cbc_integerInformation(model);2510 1182 2511 1183 printf("\n"); … … 2514 1186 // assert(Cbc_lengthNames(model)); 2515 1187 2516 printf(" Primal DualLower Upper Cost isInteger\n");1188 printf(" Primal Lower Upper Cost isInteger\n"); 2517 1189 for (iColumn = 0; iColumn < numberColumns; iColumn++) { 2518 1190 double value; … … 2524 1196 printf("%6d %8s", iColumn, name); 2525 1197 printf(" %13g", columnPrimal[iColumn]); 2526 printf(" %13g", columnDual[iColumn]);2527 1198 printf(" %13g", columnLower[iColumn]); 2528 1199 printf(" %13g", columnUpper[iColumn]); 2529 1200 printf(" %13g", columnObjective[iColumn]); 2530 printf(" %13i", isInteger[iColumn]);1201 printf(" %13i", Cbc_isInteger(model,iColumn)); 2531 1202 printf("\n"); 2532 1203 } … … 2537 1208 return; 2538 1209 } 2539 /** Dual initial solve */ 2540 COINLIBAPI int COINLINKAGE 2541 Cbc_initialDualSolve(Cbc_Model * /*model*/) 2542 { 2543 return 0; 2544 } 2545 /** Primal initial solve */ 2546 COINLIBAPI int COINLINKAGE 2547 Cbc_initialPrimalSolve(Cbc_Model * /*model*/) 2548 { 2549 return 0; 2550 } 2551 /** Dual algorithm  see ClpSimplexDual.hpp for method */ 2552 COINLIBAPI int COINLINKAGE 2553 Cbc_dual(Cbc_Model * /*model*/, int /*ifValuesPass*/) 2554 { 2555 return 0; 2556 } 2557 /** Primal algorithm  see ClpSimplexPrimal.hpp for method */ 2558 COINLIBAPI int COINLINKAGE 2559 Cbc_primal(Cbc_Model * /*model*/, int /*ifValuesPass*/) 2560 { 2561 return 0; 2562 } 1210 2563 1211 #if defined(__MWERKS__) 2564 1212 #pragma export off 
trunk/Cbc/src/Cbc_C_Interface.h
r2016 r2019 76 76 Cbc_writeMps(Cbc_Model * model, const char *filename) 77 77 ; 78 /** Integer information */79 COINLIBAPI char * COINLINKAGE80 Cbc_integerInformation(Cbc_Model * model)81 ;82 /** Copy in integer information */83 COINLIBAPI void COINLINKAGE84 Cbc_copyInIntegerInformation(Cbc_Model * model, const char * information)85 ;86 /** Drop integer informations */87 COINLIBAPI void COINLINKAGE88 Cbc_deleteIntegerInformation(Cbc_Model * model)89 ;90 /** Resizes rim part of model */91 COINLIBAPI void COINLINKAGE92 Cbc_resize (Cbc_Model * model, int newNumberRows, int newNumberColumns)93 ;94 78 /** Deletes rows */ 95 79 COINLIBAPI void COINLINKAGE … … 128 112 /**@name gets and sets  you will find some synonyms at the end of this file */ 129 113 /*@{*/ 130 /** Number of rows */131 COINLIBAPI int COINLINKAGE132 Cbc_numberRows(Cbc_Model * model)133 ;134 /** Number of columns */135 COINLIBAPI int COINLINKAGE136 Cbc_numberColumns(Cbc_Model * model)137 ;138 /** Primal tolerance to use */139 COINLIBAPI double COINLINKAGE140 Cbc_primalTolerance(Cbc_Model * model)141 ;142 COINLIBAPI void COINLINKAGE143 Cbc_setPrimalTolerance(Cbc_Model * model, double value)144 ;145 /** Dual tolerance to use */146 COINLIBAPI double COINLINKAGE147 Cbc_dualTolerance(Cbc_Model * model)148 ;149 COINLIBAPI void COINLINKAGE150 Cbc_setDualTolerance(Cbc_Model * model, double value)151 ;152 /* Integer tolerance to use */153 COINLIBAPI double COINLINKAGE154 Cbc_integerTolerance(Cbc_Model * model)155 ;156 COINLIBAPI void COINLINKAGE157 Cbc_setIntegerTolerance(Cbc_Model * model, double value)158 ;159 /** Dual objective limit */160 COINLIBAPI double COINLINKAGE161 Cbc_dualObjectiveLimit(Cbc_Model * model)162 ;163 COINLIBAPI void COINLINKAGE164 Cbc_setDualObjectiveLimit(Cbc_Model * model, double value)165 ;166 114 /** Objective offset */ 167 115 COINLIBAPI double COINLINKAGE … … 181 129 COINLIBAPI int COINLINKAGE 182 130 Cbc_setProblemName(Cbc_Model * model, int maxNumberCharacters, char * array) 183 ;184 /** Number of iterations */185 COINLIBAPI int COINLINKAGE186 Cbc_numberIterations(Cbc_Model * model)187 ;188 COINLIBAPI void COINLINKAGE189 Cbc_setNumberIterations(Cbc_Model * model, int numberIterations)190 ;191 /** Maximum number of iterations */192 COINLIBAPI int COINLINKAGE193 Cbc_maximumIterations(Cbc_Model * model)194 ;195 COINLIBAPI void COINLINKAGE196 Cbc_setMaximumIterations(Cbc_Model * model, int value)197 ;198 /** Maximum number of nodes */199 COINLIBAPI int COINLINKAGE200 Cbc_maxNumNode(Cbc_Model * model)201 ;202 COINLIBAPI void COINLINKAGE203 Cbc_setMaxNumNode(Cbc_Model * model, int value)204 ;205 /* Maximum number of solutions */206 COINLIBAPI int COINLINKAGE207 Cbc_maxNumSol(Cbc_Model * model)208 ;209 COINLIBAPI void COINLINKAGE210 Cbc_setMaxNumSol(Cbc_Model * model, int value)211 ;212 /** Maximum time in seconds (from when set called) */213 COINLIBAPI double COINLINKAGE214 Cbc_maximumSeconds(Cbc_Model * model)215 ;216 COINLIBAPI void COINLINKAGE217 Cbc_setMaximumSeconds(Cbc_Model * model, double value)218 ;219 /** Returns true if hit maximum iterations (or time) */220 COINLIBAPI int COINLINKAGE221 Cbc_hitMaximumIterations(Cbc_Model * model)222 131 ; 223 132 /** Status of problem: … … 231 140 Cbc_status(Cbc_Model * model) 232 141 ; 233 /** Set problem status */234 COINLIBAPI void COINLINKAGE235 Cbc_setProblemStatus(Cbc_Model * model, int problemStatus)236 ;237 142 /** Secondary status of problem  may get extended 238 143 0  none … … 248 153 Cbc_setSecondaryStatus(Cbc_Model * model, int status) 249 154 ; 250 /** Direction of optimization (1  minimize, 1  maximize, 0  ignore */251 COINLIBAPI double COINLINKAGE252 Cbc_optimizationDirection(Cbc_Model * model)253 ;254 COINLIBAPI void COINLINKAGE255 Cbc_setOptimizationDirection(Cbc_Model * model, double value)256 ;257 /** Primal row solution */258 COINLIBAPI double * COINLINKAGE259 Cbc_primalRowSolution(Cbc_Model * model)260 ;261 /** Primal column solution */262 COINLIBAPI double * COINLINKAGE263 Cbc_primalColumnSolution(Cbc_Model * model)264 ;265 /** Dual row solution */266 COINLIBAPI double * COINLINKAGE267 Cbc_dualRowSolution(Cbc_Model * model)268 ;269 /** Reduced costs */270 COINLIBAPI double * COINLINKAGE271 Cbc_dualColumnSolution(Cbc_Model * model)272 ;273 /** Row lower */274 COINLIBAPI double* COINLINKAGE275 Cbc_rowLower(Cbc_Model * model)276 ;277 /** Row upper */278 COINLIBAPI double* COINLINKAGE279 Cbc_rowUpper(Cbc_Model * model)280 ;281 /** Objective */282 COINLIBAPI double * COINLINKAGE283 Cbc_objective(Cbc_Model * model)284 ;285 /** Column Lower */286 COINLIBAPI double * COINLINKAGE287 Cbc_columnLower(Cbc_Model * model)288 ;289 /** Column Upper */290 COINLIBAPI double * COINLINKAGE291 Cbc_columnUpper(Cbc_Model * model)292 ;293 155 /** Number of elements in matrix */ 294 156 COINLIBAPI int COINLINKAGE … … 311 173 Cbc_getElements(Cbc_Model * model) 312 174 ; 313 /** Objective value */ 314 COINLIBAPI double COINLINKAGE 315 Cbc_objectiveValue(Cbc_Model * model) 316 ; 317 /** Infeasibility/unbounded ray (NULL returned if none/wrong) 318 Up to user to use delete [] on these arrays. */ 319 COINLIBAPI double * COINLINKAGE 320 Cbc_infeasibilityRay(Cbc_Model * model) 321 ; 322 COINLIBAPI double * COINLINKAGE 323 Cbc_unboundedRay(Cbc_Model * model) 324 ; 325 /** See if status array exists (partly for OsiClp) */ 326 COINLIBAPI int COINLINKAGE 327 Cbc_statusExists(Cbc_Model * model) 328 ; 329 /** Return address of status array (char[numberRows+numberColumns]) */ 330 COINLIBAPI void COINLINKAGE 331 Cbc_getBasisStatus(Cbc_Model * model, int * cstat, int * rstat) 332 ; 333 /** Copy in status vector */ 334 COINLIBAPI void COINLINKAGE 335 Cbc_setBasisStatus(Cbc_Model * model, int * cstat, int * rstat) 336 ; 337 338 /** User pointer for whatever reason */ 339 COINLIBAPI void COINLINKAGE 340 Cbc_setUserPointer (Cbc_Model * model, void * pointer) 341 ; 342 COINLIBAPI void * COINLINKAGE 343 Cbc_getUserPointer (Cbc_Model * model) 344 ; 175 345 176 /*@}*/ 346 177 /**@name Message handling. Call backs are handled by ONE function */ … … 356 187 Cbc_clearCallBack(Cbc_Model * model) 357 188 ; 358 /** Amount of print out:359 0  none360 1  just final361 2  just factorizations362 3  as 2 plus a bit more363 4  verbose364 above that 8,16,32 etc just for selective debug365 */366 COINLIBAPI void COINLINKAGE367 Cbc_setLogLevel(Cbc_Model * model, int value)368 ;369 COINLIBAPI int COINLINKAGE370 Cbc_logLevel(Cbc_Model * model)371 ;372 189 /** length of names (0 means no names0 */ 373 190 COINLIBAPI int COINLINKAGE … … 388 205 /**@name Functions most useful to user */ 389 206 /*@{*/ 390 /** General solve algorithm which can do presolve.391 See ClpSolve.hpp for options392 */393 COINLIBAPI int COINLINKAGE394 Cbc_initialSolve(Cbc_Model * model)395 ;396 /* General solve algorithm which can do presolve.397 See CbcModel.hpp for options398 */399 COINLIBAPI int COINLINKAGE400 Cbc_branchAndBound(Cbc_Model * model)401 ;402 207 /* Solve using CbcMain1. This is the recommended default solve function. 403 208 */ … … 405 210 Cbc_solve(Cbc_Model * model) 406 211 ; 407 /** Sets or unsets scaling, 0 off, 1 equilibrium, 2 geometric, 3, auto, 4 dynamic(later) */408 COINLIBAPI void COINLINKAGE409 Cbc_scaling(Cbc_Model * model, int mode)410 ;411 /** Gets scalingFlag */412 COINLIBAPI int COINLINKAGE413 Cbc_scalingFlag(Cbc_Model * model)414 ;415 /** Crash  at present just aimed at dual, returns416 2 if dual preferred and crash basis created417 1 if dual preferred and all slack basis preferred418 0 if basis going in was not all slack419 1 if primal preferred and all slack basis preferred420 2 if primal preferred and crash basis created.421 422 if gap between bounds <="gap" variables can be flipped423 424 If "pivot" is425 0 No pivoting (so will just be choice of algorithm)426 1 Simple pivoting e.g. gub427 2 Mini iterations428 */429 COINLIBAPI int COINLINKAGE430 Cbc_crash(Cbc_Model * model, double gap, int pivot)431 ;432 212 /*@}*/ 433 213 … … 435 215 /**@name most useful gets and sets */ 436 216 /*@{*/ 437 /** If problem is primal feasible */438 COINLIBAPI int COINLINKAGE439 Cbc_primalFeasible(Cbc_Model * model)440 ;441 /** If problem is dual feasible */442 COINLIBAPI int COINLINKAGE443 Cbc_dualFeasible(Cbc_Model * model)444 ;445 /** Dual bound */446 COINLIBAPI double COINLINKAGE447 Cbc_dualBound(Cbc_Model * model)448 ;449 COINLIBAPI void COINLINKAGE450 Cbc_setDualBound(Cbc_Model * model, double value)451 ;452 /** Infeasibility cost */453 COINLIBAPI double COINLINKAGE454 Cbc_infeasibilityCost(Cbc_Model * model)455 ;456 COINLIBAPI void COINLINKAGE457 Cbc_setInfeasibilityCost(Cbc_Model * model, double value)458 ;459 /** Perturbation:460 50  switch on perturbation461 100  auto perturb if takes too long (1.0e6 largest nonzero)462 101  we are perturbed463 102  don't try perturbing again464 default is 100465 others are for playing466 */467 COINLIBAPI int COINLINKAGE468 Cbc_perturbation(Cbc_Model * model)469 ;470 COINLIBAPI void COINLINKAGE471 Cbc_setPerturbation(Cbc_Model * model, int value)472 ;473 /** Current (or last) algorithm */474 COINLIBAPI int COINLINKAGE475 Cbc_algorithm(Cbc_Model * model)476 ;477 /** Set algorithm */478 COINLIBAPI void COINLINKAGE479 Cbc_setAlgorithm(Cbc_Model * model, int value)480 ;481 /** Sum of dual infeasibilities */482 COINLIBAPI double COINLINKAGE483 Cbc_sumDualInfeasibilities(Cbc_Model * model)484 ;485 /** Number of dual infeasibilities */486 COINLIBAPI int COINLINKAGE487 Cbc_numberDualInfeasibilities(Cbc_Model * model)488 ;489 217 /** Sum of primal infeasibilities */ 490 218 COINLIBAPI double COINLINKAGE … … 494 222 COINLIBAPI int COINLINKAGE 495 223 Cbc_numberPrimalInfeasibilities(Cbc_Model * model) 496 ;497 /** Save model to file, returns 0 if success. This is designed for498 use outside algorithms so does not save iterating arrays etc.499 It does not save any messaging information.500 Does not save scaling values.501 It does not know about all types of virtual functions.502 */503 COINLIBAPI int COINLINKAGE504 Cbc_saveModel(Cbc_Model * model, const char * fileName)505 ;506 /** Restore model from file, returns 0 if success,507 deletes current model */508 COINLIBAPI int COINLINKAGE509 Cbc_restoreModel(Cbc_Model * model, const char * fileName)510 224 ; 511 225 … … 540 254 Cbc_isProvenOptimal(Cbc_Model * model) 541 255 ; 542 /** Is primal infeasiblity proven? */ 543 COINLIBAPI int COINLINKAGE 544 Cbc_isProvenPrimalInfeasible(Cbc_Model * model) 545 ; 546 /** Is dual infeasiblity proven? */ 547 COINLIBAPI int COINLINKAGE 548 Cbc_isProvenDualInfeasible(Cbc_Model * model) 549 ; 550 /** Is the given primal objective limit reached? */ 551 COINLIBAPI int COINLINKAGE 552 Cbc_isPrimalObjectiveLimitReached(Cbc_Model * model) 553 ; 554 /** Is the given dual objective limit reached? */ 555 COINLIBAPI int COINLINKAGE 556 Cbc_isDualObjectiveLimitReached(Cbc_Model * model) 557 ; 558 /** Iteration limit reached? */ 559 COINLIBAPI int COINLINKAGE 560 Cbc_isIterationLimitReached(Cbc_Model * model) 561 ; 562 /** Direction of optimization (1  minimize, 1  maximize, 0  ignore */ 256 /** Is infeasiblity proven (or none better than cutoff)? */ 257 COINLIBAPI int COINLINKAGE 258 Cbc_isProvenInfeasible(Cbc_Model * model) 259 ; 260 /** Was continuous solution unbounded? */ 261 COINLIBAPI int COINLINKAGE 262 Cbc_isContinuousUnbounded(Cbc_Model * model) 263 ; 264 /** Node limit reached? */ 265 COINLIBAPI int COINLINKAGE 266 Cbc_isNodeLimitReached(Cbc_Model * model) 267 ; 268 /** Time limit reached? */ 269 COINLIBAPI int COINLINKAGE 270 Cbc_isSecondsLimitReached(Cbc_Model * model) 271 ; 272 /** Solution limit reached? */ 273 COINLIBAPI int COINLINKAGE 274 Cbc_isSolutionLimitReached(Cbc_Model * model) 275 ; 276 /** Are there numerical difficulties (for initialSolve) ? */ 277 COINLIBAPI int COINLINKAGE 278 Cbc_isInitialSolveAbandoned(Cbc_Model * model) 279 ; 280 /** Is optimality proven (for initialSolve) ? */ 281 COINLIBAPI int COINLINKAGE 282 Cbc_isInitialSolveProvenOptimal(Cbc_Model * model) 283 ; 284 /** Is primal infeasiblity proven (for initialSolve) ? */ 285 COINLIBAPI int COINLINKAGE 286 Cbc_isInitialSolveProvenPrimalInfeasible(Cbc_Model * model) 287 ; 288 /** Direction of optimization (1  minimize, 1  maximize, 0  ignore) */ 289 COINLIBAPI void COINLINKAGE 290 Cbc_setObjSense(Cbc_Model * model, double sense) 291 ; 292 /** Direction of optimization (1  minimize, 1  maximize, 0  ignore) */ 563 293 COINLIBAPI double COINLINKAGE 564 294 Cbc_getObjSense(Cbc_Model * model) 565 295 ; 566 /** Primal row solution */ 296 /** Primal row solution 297 * This is the vector A*x, where A is the constraint matrix 298 * and x is the current solution. */ 567 299 COINLIBAPI const double * COINLINKAGE 568 300 Cbc_getRowActivity(Cbc_Model * model) … … 574 306 COINLIBAPI void COINLINKAGE 575 307 Cbc_setColSolution(Cbc_Model * model, const double * input) 576 ;577 /** Dual row solution */578 COINLIBAPI const double * COINLINKAGE579 Cbc_getRowPrice(Cbc_Model * model)580 ;581 /** Reduced costs */582 COINLIBAPI const double * COINLINKAGE583 Cbc_getReducedCost(Cbc_Model * model)584 308 ; 585 309 /** Row lower */ … … 630 354 COINLIBAPI Cbc_Model * COINLINKAGE 631 355 Cbc_setContinuous(Cbc_Model * model, int iColumn) 356 ; 357 /** Set this the variable to be integer */ 358 COINLIBAPI Cbc_Model * COINLINKAGE 359 Cbc_setInteger(Cbc_Model * model, int iColumn) 632 360 ; 633 361 /** Add SOS constraints to the model using dense matrix */ … … 649 377 Cbc_printSolution(Cbc_Model * model) 650 378 ; 651 /** Dual initial solve */652 COINLIBAPI int COINLINKAGE653 Cbc_initialDualSolve(Cbc_Model * model)654 ;655 /** Primal initial solve */656 COINLIBAPI int COINLINKAGE657 Cbc_initialPrimalSolve(Cbc_Model * model)658 ;659 /** Dual algorithm  see ClpSimplexDual.hpp for method */660 COINLIBAPI int COINLINKAGE661 Cbc_dual(Cbc_Model * model, int ifValuesPass)662 ;663 /** Primal algorithm  see ClpSimplexPrimal.hpp for method */664 COINLIBAPI int COINLINKAGE665 Cbc_primal(Cbc_Model * model, int ifValuesPass)666 ;667 379 /*@}*/ 668 380 #ifdef __cplusplus 
trunk/Cbc/test/CInterfaceTest.c
r2016 r2019 16 16 17 17 /* Simple knapsack problem 18 M inimize 5x[1]  3x[2]  2x[3]  7x[4] 4x[5]18 Maximize 5x[1] + 3x[2] + 2x[3] + 7x[4] + 4x[5] 19 19 s.t. 2x[1] + 8x[2] + 4x[3] + 2x[4] + 5x[5] <= 10 20 20 All x binary … … 26 26 double collb[] = {0,0,0,0,0}; 27 27 double colub[] = {1,1,1,1,1}; 28 double obj[] = { 5, 3, 2, 7, 4};28 double obj[] = {5, 3, 2, 7, 4}; 29 29 double rowlb[] = {INFINITY}; 30 30 double rowub[] = {10}; 31 char integer[] = {1,1,1,1,1};32 char *information;33 31 const double *sol; 34 32 int i; … … 36 34 Cbc_loadProblem(model, 5, 1, start, rowindex, value, collb, colub, obj, rowlb, rowub); 37 35 38 Cbc_copyInIntegerInformation(model, integer);39 40 36 assert(Cbc_getNumCols(model) == 5); 41 37 assert(Cbc_getNumRows(model) == 1); 42 38 43 information = Cbc_integerInformation(model);44 39 for (i = 0; i < 5; i++) { 45 assert(information[i] == 1); 40 Cbc_setInteger(model, i); 41 assert(Cbc_isInteger(model,i)); 46 42 } 47 43 48 assert(Cbc_optimizationDirection(model) == 1); 44 Cbc_setObjSense(model, 1); 45 assert(Cbc_getObjSense(model) == 1); 49 46 50 47 Cbc_solve(model); 51 48 52 49 assert(Cbc_isProvenOptimal(model)); 53 assert(fabs( Cbc_objectiveValue(model) (16.0) < 1e6)); 50 assert(!Cbc_isAbandoned(model)); 51 assert(!Cbc_isProvenInfeasible(model)); 52 assert(!Cbc_isContinuousUnbounded(model)); 53 assert(!Cbc_isNodeLimitReached(model)); 54 assert(!Cbc_isSecondsLimitReached(model)); 55 assert(!Cbc_isSolutionLimitReached(model)); 56 assert(fabs( Cbc_getObjValue(model) (16.0) < 1e6)); 54 57 55 58 sol = Cbc_getColSolution(model); … … 80 83 double colub[] = {1.0}; 81 84 double obj[] = {1.0}; 82 char integer[] = {1};83 85 84 86 Cbc_loadProblem(model, 1, 1, start, rowindex, value, collb, colub, obj, rowlb, rowub); 85 87 86 Cbc_ copyInIntegerInformation(model, integer);88 Cbc_setInteger(model, 0); 87 89 88 90 assert(Cbc_getNumCols(model) == 1); … … 92 94 93 95 assert(!Cbc_isProvenOptimal(model)); 94 assert(Cbc_isProven PrimalInfeasible(model));96 assert(Cbc_isProvenInfeasible(model)); 95 97 96 98 } … … 115 117 double colub[] = {INFINITY, INFINITY}; 116 118 double obj[] = {1.0}; 117 char integer[] = {1,0};118 119 119 120 Cbc_loadProblem(model, 2, 2, start, rowindex, value, collb, colub, obj, rowlb, rowub); 120 121 121 Cbc_ copyInIntegerInformation(model, integer);122 Cbc_setInteger(model, 0); 122 123 123 124 Cbc_solve(model); 124 125 125 126 assert(!Cbc_isProvenOptimal(model)); 126 assert(!Cbc_isProven PrimalInfeasible(model));127 assert(Cbc_is ProvenDualInfeasible(model));127 assert(!Cbc_isProvenInfeasible(model)); 128 assert(Cbc_isContinuousUnbounded(model)); 128 129 129 130
Note: See TracChangeset
for help on using the changeset viewer.