Changeset 26


Ignore:
Timestamp:
Aug 22, 2006 12:54:37 PM (13 years ago)
Author:
andreasw
Message:

Fix ticket #2, improve behavior of OA in non-convex problems

Location:
branches/devel/Bonmin
Files:
16 edited

Legend:

Unmodified
Added
Removed
  • branches/devel/Bonmin/experimental/Bcp/Makefile.am

    r1 r26  
    2525  COINLIBS += \
    2626        $(OSIOBJDIR)/src/OsiCpx/libOsiCpx.la \
    27         $(COINUTILSOBJDIR)/src/libCoinUtils.la \
    2827        $(CPXLIB)
    2928endif
     
    4039bonminbcp_SOURCES = BB_cut.hpp BB_cut.cpp BM.hpp BM.cpp BM_pack.cpp bm_var.hpp
    4140
     41bonminbcp_DEPENDENCIES = amplsolver.a
     42
     43AMPL_PATHED_FILES = \
     44        asl.h \
     45        jac0dim.c \
     46        misc.c \
     47        pfg_read.c
     48AMPL_SRC = $(abs_source_dir)/../ThirdParty/ASL/solvers
     49
     50amplsolver.a:
     51        mkdir -p solvers ; \
     52        cd solvers ; \
     53        for f in $(AMPL_SRC)/*.c* $(AMPL_SRC)/*.h*; do \
     54                $(LN_S) $$f ; \
     55        done ; \
     56        for f in $(AMPL_PATHED_FILES); do \
     57                rm $$f ; \
     58                cp $(AMPL_SRC)/$$f . ; \
     59        done ; \
     60        patch -p1 < $(abs_source_dir)/experimental/Bcp/ampl_bcp.patch ; \
     61        for f in `grep -l 'strtod' *.c *.h`; do \
     62                mv $$f $$f.orig ; \
     63                sed -e 's/strtod/ASLstrtod/g' -e 's/ASLASLstrtod/ASLstrtod/g' $$f.orig > $$f ; \
     64                rm $$f.orig ; \
     65        done ; \
     66        for f in `grep -l 'atof(' *.c`; do \
     67                mv $$f $$f.orig ; \
     68                sed -e 's/atof/ASLatof/g' -e 's/ASLASLatof/ASLatof/g' $$f.orig > $$f ; \
     69                rm $$f.orig ; \
     70        done ; \
     71        sed -e 's/CFLAGS =/CFLAGS = -DNO_FUNCADD/g' $(AMPL_SRC)/makefile.u > makefile.u ; \
     72        $(MAKE) -f makefile.u ; \
     73        cp amplsolver.a ..
     74
    4275bonminbcp_LDADD = \
    4376        ../../src/Apps/libbonmin.la \
     
    4578        $(IPOPTOBJDIR)/src/Apps/AmplSolver/libamplinterface.la \
    4679        $(IPOPTLIBS) \
    47         $(ASLLIB) \
    4880        $(LIBCBCCOPY) \
    4981        $(COINLIBS) \
     82        amplsolver.a \
    5083        $(ADDLIBS)
    5184
  • branches/devel/Bonmin/experimental/Bcp/Makefile.in

    r1 r26  
    4444@COIN_HAS_CPX_TRUE@am__append_1 = \
    4545@COIN_HAS_CPX_TRUE@     $(OSIOBJDIR)/src/OsiCpx/libOsiCpx.la \
    46 @COIN_HAS_CPX_TRUE@     $(COINUTILSOBJDIR)/src/libCoinUtils.la \
    4746@COIN_HAS_CPX_TRUE@     $(CPXLIB)
    4847
     
    7069@COIN_HAS_CPX_TRUE@am__DEPENDENCIES_3 =  \
    7170@COIN_HAS_CPX_TRUE@     $(OSIOBJDIR)/src/OsiCpx/libOsiCpx.la \
    72 @COIN_HAS_CPX_TRUE@     $(COINUTILSOBJDIR)/src/libCoinUtils.la \
    7371@COIN_HAS_CPX_TRUE@     $(am__DEPENDENCIES_2)
    7472am__DEPENDENCIES_4 = $(BCPOBJDIR)/src/libBcp.la \
     
    7775        $(OSIOBJDIR)/src/libOsi.la $(CLPOBJDIR)/src/libClp.la \
    7876        $(COINUTILSOBJDIR)/src/libCoinUtils.la $(am__DEPENDENCIES_3)
    79 bonminbcp_DEPENDENCIES = ../../src/Apps/libbonmin.la \
    80         ../../src/BonminAmplInterface/libamplinterface.la \
    81         $(IPOPTOBJDIR)/src/Apps/AmplSolver/libamplinterface.la \
    82         $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_2) \
    83         $(am__DEPENDENCIES_4) $(am__DEPENDENCIES_2)
    8477depcomp = $(SHELL) $(top_srcdir)/../depcomp
    8578am__depfiles_maybe = depfiles
     
    327320########################################################################
    328321bonminbcp_SOURCES = BB_cut.hpp BB_cut.cpp BM.hpp BM.cpp BM_pack.cpp bm_var.hpp
     322bonminbcp_DEPENDENCIES = amplsolver.a
     323AMPL_PATHED_FILES = \
     324        asl.h \
     325        jac0dim.c \
     326        misc.c \
     327        pfg_read.c
     328
     329AMPL_SRC = $(abs_source_dir)/../ThirdParty/ASL/solvers
    329330bonminbcp_LDADD = \
    330331        ../../src/Apps/libbonmin.la \
     
    332333        $(IPOPTOBJDIR)/src/Apps/AmplSolver/libamplinterface.la \
    333334        $(IPOPTLIBS) \
    334         $(ASLLIB) \
    335335        $(LIBCBCCOPY) \
    336336        $(COINLIBS) \
     337        amplsolver.a \
    337338        $(ADDLIBS)
    338339
     
    645646        uninstall-binPROGRAMS uninstall-info-am
    646647
     648
     649amplsolver.a:
     650        mkdir -p solvers ; \
     651        cd solvers ; \
     652        for f in $(AMPL_SRC)/*.c* $(AMPL_SRC)/*.h*; do \
     653                $(LN_S) $$f ; \
     654        done ; \
     655        for f in $(AMPL_PATHED_FILES); do \
     656                rm $$f ; \
     657                cp $(AMPL_SRC)/$$f . ; \
     658        done ; \
     659        patch -p1 < $(abs_source_dir)/experimental/Bcp/ampl_bcp.patch ; \
     660        for f in `grep -l 'strtod' *.c *.h`; do \
     661                mv $$f $$f.orig ; \
     662                sed -e 's/strtod/ASLstrtod/g' -e 's/ASLASLstrtod/ASLstrtod/g' $$f.orig > $$f ; \
     663                rm $$f.orig ; \
     664        done ; \
     665        for f in `grep -l 'atof(' *.c`; do \
     666                mv $$f $$f.orig ; \
     667                sed -e 's/atof/ASLatof/g' -e 's/ASLASLatof/ASLatof/g' $$f.orig > $$f ; \
     668                rm $$f.orig ; \
     669        done ; \
     670        sed -e 's/CFLAGS =/CFLAGS = -DNO_FUNCADD/g' $(AMPL_SRC)/makefile.u > makefile.u ; \
     671        $(MAKE) -f makefile.u ; \
     672        cp amplsolver.a ..
    647673# Tell versions [3.59,3.63) of GNU make to not export all variables.
    648674# Otherwise a system limit (for SysV at least) may be exceeded.
  • branches/devel/Bonmin/experimental/FP/FP.cpp

    r1 r26  
    5252           std::string* nl_file_content /* = NULL */):AmplTMINLP()
    5353           {
    54                std::cout<<"Toto"<<std::endl;
    5554               Initialize2(jnlst, options, argv, suffix_handler,
    5655               appName, nl_file_content);
  • branches/devel/Bonmin/experimental/FP/Makefile.am

    r1 r26  
    1212
    1313
    14 if COIN_HAS_CPX
    1514  bin_PROGRAMS = oa_fp
    16 endif
    1715
    1816
  • branches/devel/Bonmin/experimental/FP/Makefile.in

    r1 r26  
    4343build_triplet = @build@
    4444host_triplet = @host@
    45 @COIN_HAS_CPX_TRUE@bin_PROGRAMS = oa_fp$(EXEEXT)
     45bin_PROGRAMS = oa_fp$(EXEEXT)
    4646@COIN_HAS_CPX_TRUE@am__append_1 = \
    4747@COIN_HAS_CPX_TRUE@     $(OSIOBJDIR)/src/OsiCpx/libOsiCpx.la \
  • branches/devel/Bonmin/experimental/FP/OAFeasibilityPump.cpp

    r1 r26  
    272272    CbcStrategyDefault defaultStrategy;
    273273    mip.setStrategy(defaultStrategy);
     274    mip.solver()->messageHandler()->setLogLevel(0);
    274275
    275276    //Add some heuristics to get feasible solutions
    276     //       CbcGreedyCover greed(mip);
    277     CbcHeuristicFPump fp(mip);
    278     //       mip.addHeuristic(&greed);
    279     //        mip.addHeuristic(&fp);
    280     //      mip.setMaximumNodes(nMaxNodes - nTotalNodes);
    281277    mip.setMaximumSeconds(maxTime - CoinCpuTime() - info.time);
    282278    mip.setMaximumSolutions(1);
     
    535531    mip.setStrategy(defaultStrategy);
    536532
    537     //Add some heuristics to get feasible solutions
    538     //       CbcGreedyCover greed(mip);
    539     CbcHeuristicFPump fp(mip);
    540     //       mip.addHeuristic(&greed);
    541     mip.addHeuristic(&fp);
    542     //      mip.setMaximumNodes(nMaxNodes - nTotalNodes);
    543533    mip.setMaximumSeconds(params.maxTime_ - CoinCpuTime() + BeginTimeGLOB);
    544534    mip.setMaximumSolutions(3);
     
    791781  bool solved = 0;
    792782  double firstIterationTime;
    793   solver.messageHandler()->setLogLevel(1);
     783  solver.messageHandler()->setLogLevel(0);
    794784  int numNotFound = 0;
    795785
     
    821811#ifndef COIN_HAS_CPX
    822812      solver.initialSolve();
     813      solver.messageHandler()->setLogLevel(0);
     814
    823815      CbcStrategyDefault defaultStrategy;
    824816      CbcModel mip(solver);
    825817      mip.setStrategy(defaultStrategy);
    826818      mip.solver()->messageHandler()->setLogLevel(0);
    827       mip.setLogLevel(1);
    828       CbcHeuristicFPump fp(mip);
    829       //       mip.addHeuristic(&greed);
    830       //mip.addHeuristic(&fp);
    831 
    832       //                mip.setMaximumNodes(nMaxNodes - nTotalNodes);
     819      mip.setLogLevel(0);
    833820      mip.setMaximumSeconds(params.maxTime_ - CoinCpuTime() - BeginTimeGLOB);
    834821      mip.setMaximumSolutions(1);
     
    10271014#ifndef COIN_HAS_CPX
    10281015
     1016    solver.messageHandler()->setLogLevel(0);
    10291017    CbcModel mip(solver);
    10301018    //  solver.writeMps("oa");
    1031     mip.solver()->messageHandler()->setLogLevel(0);
    10321019    CbcStrategyDefault defaultStrategy(1,8,4);
    10331020    mip.setStrategy(defaultStrategy);
    10341021
    1035     //Add some heuristics to get feasible solutions
    1036     //       CbcGreedyCover greed(mip);
    1037     CbcHeuristicFPump fp(mip);
    1038     //       mip.addHeuristic(&greed);
    1039     mip.addHeuristic(&fp);
    1040     //      mip.setMaximumNodes(nMaxNodes - nTotalNodes);
    10411022    mip.setMaximumSeconds(params.maxTime_ - CoinCpuTime() + BeginTimeGLOB);
    10421023    mip.setMaximumSolutions(3);
     
    12421223#endif
    12431224
    1244   solver.messageHandler()->setLogLevel(3);
     1225  solver.messageHandler()->setLogLevel(0);
    12451226
    12461227  //Setup timers since an nlp is solved to extract the linear relaxation
     
    12941275
    12951276#ifndef COIN_HAS_CPX
    1296 
     1277 
    12971278        solver.initialSolve();
    12981279        CbcModel mip(solver);
    12991280        CbcStrategyDefault defaultStrategy;
    13001281        mip.setStrategy(defaultStrategy);
     1282        mip.solver()->messageHandler()->setLogLevel(0);
    13011283
    13021284        //Add some heuristics to get feasible solutions
    1303         //       CbcGreedyCover greed(mip);
    1304         CbcHeuristicFPump fp(mip);
    1305         fp.setMaximumPasses(1000);
    1306         //       mip.addHeuristic(&greed);
    1307         mip.addHeuristic(&fp);
    1308         //              mip.setMaximumNodes(nMaxNodes - nTotalNodes);
    13091285        mip.setMaximumSeconds(params.maxTime_ - CoinCpuTime() +beginTime);
    13101286        mip.setMaximumSolutions(1);
     
    15771553    CbcStrategyDefault defaultStrategy;
    15781554    mip.setStrategy(defaultStrategy);
    1579 
    1580     //Add some heuristics to get feasible solutions
    1581     //       CbcGreedyCover greed(mip);
    1582     CbcHeuristicFPump fp(mip);
    1583     //       mip.addHeuristic(&greed);
    1584     mip.addHeuristic(&fp);
    1585     //      mip.setMaximumNodes(nMaxNodes - nTotalNodes);
     1555    mip.solver()->messageHandler()->setLogLevel(0);
     1556
    15861557    mip.setMaximumSeconds(maxTime - CoinCpuTime() + time);
    15871558    mip.setMaximumSolutions(1);
  • branches/devel/Bonmin/src/Apps/bonmin.cpp

    r1 r26  
    143143    std::cout<<pbName<<" \t";
    144144    std::string message;
     145    std::string status;
    145146    if(bb.mipStatus()==BonminBB::FeasibleOptimal) {
    146       std::cout<<"\t\"Finished\"\t";
     147      status = "\t\"Finished\"";
    147148      message = "\nbonmin: Optimal";
    148149    }
    149150    else if(bb.mipStatus()==BonminBB::ProvenInfeasible) {
    150       std::cout<<"\t\"Finished\"\t";
     151      status = "\t\"Finished\"";
    151152      message = "\nbonmin: Infeasible problem";
    152153    }
    153154    else if(bb.mipStatus()==BonminBB::Feasible) {
    154       std::cout<<"\t\"Not finished\""<<"\t";
     155      status = "\t\"Not finished\"";
    155156      message = "\n Optimization not finished.";
    156157    }
    157158    else if(bb.mipStatus()==BonminBB::NoSolutionKnown) {
    158       std::cout<<"\t\"Not finished\""<<"\t";
     159      status = "\t\"Not finished\"";
    159160      message = "\n Optimization not finished.";
    160161    }
    161     std::cout<<CoinCpuTime()-time1<<"\t"
     162
     163  if(0)// To output a line for building tables
     164    std::cout<<status<<"\t"<<CoinCpuTime()-time1<<"\t"
    162165             <<bb.bestObj()<<"\t"
    163166             <<bb.numNodes()<<"\t"
  • branches/devel/Bonmin/src/BonminAmplInterface/AmplTMINLP.cpp

    r1 r26  
    302302
    303303  bool AmplTMINLP::get_starting_point(Index n, bool init_x, Number* x,
     304                                    bool init_z, Number* z_L, Number* z_U,
    304305      Index m, bool init_lambda, Number* lambda)
    305306  {
    306307    return ampl_tnlp_->get_starting_point(n, init_x, x,
    307         false, NULL, NULL,
     308        init_z, z_L, z_U,
    308309        m, init_lambda, lambda);
    309310  }
  • branches/devel/Bonmin/src/BonminAmplInterface/AmplTMINLP.hpp

    r1 r26  
    9090    from TMINLP */
    9191    virtual bool get_starting_point(Index n, bool init_x, Number* x,
     92                                    bool init_z, Number* z_L, Number* z_U,
    9293        Index m, bool init_lambda, Number* lambda);
    9394
  • branches/devel/Bonmin/src/BonminAmplInterface/Makefile.am

    r1 r26  
    4040        -I`$(CYGPATH_W) $(CLPOBJDIR)/inc` \
    4141        -I`$(CYGPATH_W) $(CLPSRCDIR)/src` \
    42         -I`$(CYGPATH_W) $(srcdir)/../IpoptInterface` \
    43         $(ASL_CPPFLAGS)
     42        -I`$(CYGPATH_W) $(srcdir)/../IpoptInterface`
     43
     44AM_CPPFLAGS += $(ASL_CPPFLAGS)
     45
    4446
    4547# This line is necessary to allow VPATH compilation with MS compilers
  • branches/devel/Bonmin/src/BonminAmplInterface/Makefile.in

    r1 r26  
    318318# Here list all include flags, relative to this "srcdir" directory.  This
    319319# "cygpath" stuff is necessary to compile with native compilers on Windows
    320 AM_CPPFLAGS = \
    321         -I`$(CYGPATH_W) $(IPOPTOBJDIR)/inc` \
    322         -I`$(CYGPATH_W) $(IPOPTSRCDIR)/src/Common` \
    323         -I`$(CYGPATH_W) $(IPOPTSRCDIR)/src/LinAlg` \
    324         -I`$(CYGPATH_W) $(IPOPTSRCDIR)/src/Algorithm` \
    325         -I`$(CYGPATH_W) $(IPOPTSRCDIR)/src/Interfaces` \
    326         -I`$(CYGPATH_W) $(IPOPTSRCDIR)/src/Apps/AmplSolver` \
    327         -I`$(CYGPATH_W) $(COINUTILSSRCDIR)/src` \
    328         -I`$(CYGPATH_W) $(COINUTILSOBJDIR)/inc` \
    329         -I`$(CYGPATH_W) $(OSISRCDIR)/src` \
    330         -I`$(CYGPATH_W) $(OSISRCDIR)/src/OsiClp` \
    331         -I`$(CYGPATH_W) $(CLPOBJDIR)/inc` \
    332         -I`$(CYGPATH_W) $(CLPSRCDIR)/src` \
    333         -I`$(CYGPATH_W) $(srcdir)/../IpoptInterface` \
    334         $(ASL_CPPFLAGS)
    335 
     320AM_CPPFLAGS = -I`$(CYGPATH_W) $(IPOPTOBJDIR)/inc` -I`$(CYGPATH_W) \
     321        $(IPOPTSRCDIR)/src/Common` -I`$(CYGPATH_W) \
     322        $(IPOPTSRCDIR)/src/LinAlg` -I`$(CYGPATH_W) \
     323        $(IPOPTSRCDIR)/src/Algorithm` -I`$(CYGPATH_W) \
     324        $(IPOPTSRCDIR)/src/Interfaces` -I`$(CYGPATH_W) \
     325        $(IPOPTSRCDIR)/src/Apps/AmplSolver` -I`$(CYGPATH_W) \
     326        $(COINUTILSSRCDIR)/src` -I`$(CYGPATH_W) \
     327        $(COINUTILSOBJDIR)/inc` -I`$(CYGPATH_W) $(OSISRCDIR)/src` \
     328        -I`$(CYGPATH_W) $(OSISRCDIR)/src/OsiClp` -I`$(CYGPATH_W) \
     329        $(CLPOBJDIR)/inc` -I`$(CYGPATH_W) $(CLPSRCDIR)/src` \
     330        -I`$(CYGPATH_W) $(srcdir)/../IpoptInterface` $(ASL_CPPFLAGS)
    336331
    337332# This line is necessary to allow VPATH compilation with MS compilers
  • branches/devel/Bonmin/src/IpoptInterface/IpoptInterface.cpp

    r1 r26  
    4242  roptions->AddBoundedIntegerOption("bb_log_level",
    4343      "specify main branch-and-bound log level.",
    44       0,5,1,
     44      0,3,1,
    4545      "Set the level of output of the branch-and-bound : "
    46       "0 - none, 1 - minimal, 2 - normal low, 3 - normal high, 4 - verbose"
     46      "0 - none, 1 - minimal, 2 - normal low, 3 - normal high"
    4747                                   );
    4848
     
    5555  roptions->AddBoundedIntegerOption("lp_log_level",
    5656      "specify LP log level.",
    57       0,5,0,
     57      0,4,0,
    5858      "Set the level of output of the linear programming sub-solver in B-Hyb or B-QG : "
    5959      "0 - none, 1 - minimal, 2 - normal low, 3 - normal high, 4 - verbose"
     
    6262  roptions->AddBoundedIntegerOption("milp_log_level",
    6363      "specify MILP subsolver log level.",
    64       0,5,0,
     64      0,3,0,
    6565      "Set the level of output of the MILP subsolver in OA : "
    66       "0 - none, 1 - minimal, 2 - normal low, 3 - normal high, 4 - verbose"
     66      "0 - none, 1 - minimal, 2 - normal low, 3 - normal high"
    6767                                   );
    6868
     
    425425    nnz_jac(0),
    426426    constTypes_(NULL),
    427     constTypesNum_(NULL),
     427//    constTypesNum_(NULL),
    428428    nLinear_(0),
    429429    nNonLinear_(0),
    430430    tiny_(1e-8),
    431     veryTiny_(1e-20)
     431    veryTiny_(1e-20),
     432    infty_(1e100)
    432433{}
    433434
     
    468469    nnz_jac(0),
    469470    constTypes_(NULL),
    470     constTypesNum_(NULL),
     471//    constTypesNum_(NULL),
    471472    nLinear_(0),
    472473    nNonLinear_(0),
    473474    tiny_(1e-08),
    474     veryTiny_(1e-17)
     475    veryTiny_(1e-17),
     476    infty_(1e100)
    475477{
    476478  assert(IsValid(tminlp));
     
    512514    app_->Options()->GetNumericValue("tiny_element",tiny_,"bonmin.");
    513515    app_->Options()->GetNumericValue("very_tiny_element",veryTiny_,"bonmin.");
     516    double lower_infty, upper_infty;
     517    app_->Options()->GetNumericValue("nlp_lower_bound_inf",lower_infty,"");
     518    app_->Options()->GetNumericValue("nlp_upper_bound_inf",upper_infty,"");
     519    infty_ = min(fabs(lower_infty), fabs(upper_infty));
    514520  }
    515521}
     
    560566    nnz_jac(source.nnz_jac),
    561567    constTypes_(NULL),
    562     constTypesNum_(NULL),
     568//    constTypesNum_(NULL),
    563569    nLinear_(0),
    564570    nNonLinear_(0),
    565571    tiny_(source.tiny_),
    566     veryTiny_(source.veryTiny_)
     572    veryTiny_(source.veryTiny_),
     573    infty_(source.infty_)
    567574{
    568575  // Copy options from old application
     
    610617      CoinCopyN(source.constTypes_, getNumRows(), constTypes_);
    611618    }
    612     if(source.constTypesNum_ != NULL) {
    613       constTypesNum_ = new int[getNumRows()];
    614       CoinCopyN(source.constTypesNum_, getNumRows(), constTypesNum_);
    615     }
     619//    if(source.constTypesNum_ != NULL) {
     620//      constTypesNum_ = new int[getNumRows()];
     621//      CoinCopyN(source.constTypesNum_, getNumRows(), constTypesNum_);
     622//    }
    616623  }
    617624  else if(nnz_jac > 0) {
     
    666673        CoinCopyN(rhs.constTypes_, getNumRows(), constTypes_);
    667674      }
    668 
     675/*
    669676      if(constTypesNum_ != NULL) {
    670677        delete [] constTypesNum_;
     
    675682        CoinCopyN(rhs.constTypesNum_, getNumRows(), constTypesNum_);
    676683      }
    677 
     684*/
    678685      if(rhs.jValues_!=NULL && rhs.jRow_ != NULL && rhs.jCol_ != NULL && nnz_jac>0) {
    679686        jValues_ = new double [nnz_jac];
     
    691698      tiny_ = rhs.tiny_;
    692699      veryTiny_ = rhs.veryTiny_;
     700      infty_ = rhs.infty_;
    693701
    694702
     
    747755  delete [] jValues_;
    748756  delete [] constTypes_;
    749   delete [] constTypesNum_;
     757//  delete [] constTypesNum_;
    750758}
    751759
     
    14871495IpoptInterface::getInfinity() const
    14881496{
    1489   return 1e100;
     1497  return infty_;
    14901498}
    14911499
     
    19371945
    19381946  if(constTypes_ != NULL) delete [] constTypes_;
    1939   if(constTypesNum_ != NULL) delete [] constTypesNum_;
     1947//  if(constTypesNum_ != NULL) delete [] constTypesNum_;
    19401948
    19411949  constTypes_ = new Ipopt::TMINLP::ConstraintType[getNumRows()];
    19421950  tminlp_->get_constraints_types(getNumRows(), constTypes_);
    1943   constTypesNum_ = new int[getNumRows()];
     1951//  constTypesNum_ = new int[getNumRows()];
    19441952  for(int i = 0; i < getNumRows() ; i++) {
    19451953    if(constTypes_[i]==Ipopt::TMINLP::LINEAR) {
    1946       constTypesNum_[i] = nLinear_++;
     1954      //constTypesNum_[i] =
     1955      nLinear_++;
    19471956    }
    19481957    else if(constTypes_[i]==Ipopt::TMINLP::NON_LINEAR) {
    1949       constTypesNum_[i] = nNonLinear_++;
     1958      //constTypesNum_[i] =
     1959      nNonLinear_++;
    19501960    }
    19511961  }
     
    20492059  double * lb = new double[nNonLinear_ + 1];
    20502060  double * ub = new double[nNonLinear_ + 1];
     2061  int * binding = new int[nNonLinear_ + 1];//store binding constraints at current opt (which are added to OA) -1 if constraint is not binding, otherwise index in subset of binding constraints
     2062  int numBindings = 0;
     2063   
    20512064  const double * rowLower = getRowLower();
    20522065  const double * rowUpper = getRowUpper();
    20532066  const double * colLower = getColLower();
    20542067  const double * colUpper = getColUpper();
    2055 
     2068  const double * duals = getRowPrice();
     2069  double infty = 1e100 *getInfinity();
     2070 
    20562071  for(int i = 0; i< m ; i++) {
    20572072    if(constTypes_[i] == Ipopt::TMINLP::NON_LINEAR) {
    2058       lb[constTypesNum_[i]] = rowLower[i] - g[i];
    2059       ub[constTypesNum_[i]] = rowUpper[i] - g[i];
    2060     }
    2061   }
    2062 //double infty = getInfinity();
     2073      if(rowLower[i] > -infty && rowUpper[i] < infty && fabs(duals[i]) == 0.)
     2074      {
     2075        binding[i] = -1;
     2076        std::cerr<<"non binding constraint"<<std::endl;
     2077        continue;
     2078      }
     2079      binding[i] = numBindings;
     2080      if(rowLower[i] > - infty_)
     2081        lb[numBindings] = rowLower[i] - g[i];
     2082      else
     2083        lb[numBindings] = - infty;
     2084      if(rowUpper[i] < infty_)
     2085        ub[numBindings] = rowUpper[i] - g[i];
     2086      else
     2087        ub[numBindings] = infty_;
     2088      if(rowLower[i] > -infty && rowUpper[i] < infty)
     2089      {
     2090        if(duals[i] >= 0)// <= inequality
     2091          lb[numBindings] = - infty;
     2092        if(duals[i] <= 0)// >= inequality
     2093          ub[numBindings] = infty;
     2094      }
     2095     
     2096      numBindings++;
     2097    }
     2098  }
     2099
    20632100  for(int i = 0 ; i < nnz_jac_g ; i++) {
    20642101    if(constTypes_[jRow_[i] - 1] == Ipopt::TMINLP::NON_LINEAR) {
     
    20672104          rowLower[jRow_[i] - 1], rowUpper[jRow_[i] - 1],
    20682105          getColSolution()[jCol_[i] - 1],
    2069           lb[constTypesNum_[jRow_[i] - 1]],
    2070           ub[constTypesNum_[jRow_[i] - 1]], tiny_, veryTiny_)) {
    2071         cuts[constTypesNum_[jRow_[i] - 1]].insert(jCol_[i]-1,jValues_[i]);
    2072         lb[constTypesNum_[jRow_[i] - 1]] += jValues_[i] * getColSolution()[jCol_ [i] - 1];
    2073         ub[constTypesNum_[jRow_[i] - 1]] += jValues_[i] * getColSolution()[jCol_ [i] - 1];
     2106          lb[binding[jRow_[i] - 1]],
     2107          ub[binding[jRow_[i] - 1]], tiny_, veryTiny_)) {
     2108        cuts[binding[jRow_[i] - 1]].insert(jCol_[i]-1,jValues_[i]);
     2109        if(lb[binding[jRow_[i] - 1]] > - infty_)
     2110          lb[binding[jRow_[i] - 1]] += jValues_[i] * getColSolution()[jCol_ [i] - 1];
     2111        if(ub[binding[jRow_[i] - 1]] < infty_)
     2112        ub[binding[jRow_[i] - 1]] += jValues_[i] * getColSolution()[jCol_ [i] - 1];
    20742113      }
    20752114    }
    20762115  }
    20772116
    2078   for(int i = 0; i< nNonLinear_ ; i++) {
     2117  for(int i = 0; i< numBindings ; i++) {
    20792118    OsiRowCut newCut;
    20802119    //    if(lb[i]>-1e20) assert (ub[i]>1e20);
     
    21292168  }
    21302169
    2131   // setColSolution(problem()->x_sol());
    2132   //  setRowPrice(problem()->duals_sol());
    21332170  delete []lb;
    21342171  delete[]ub;
     
    21872224  rowLow = new double[m];
    21882225  rowUp = new double[m];
     2226  int * binding = new int[m];//store binding constraints at current opt (which are added to OA) -1 if constraint is not binding, otherwise index in subset of binding constraints
     2227  int numBindings = 0;
    21892228  const double * rowLower = getRowLower();
    21902229  const double * rowUpper = getRowUpper();
    21912230  const double * colLower = getColLower();
    21922231  const double * colUpper = getColUpper();
     2232  const double * duals = getRowPrice();
    21932233  assert(m==getNumRows());
     2234  double infty = getInfinity() * 1e100;
    21942235  for(int i = 0 ; i < m ; i++) {
    21952236    {
    21962237      if(constTypes_[i] == Ipopt::TMINLP::NON_LINEAR) {
    2197         rowLow[i] = (rowLower[i] - g[i]) - 1e-07;
    2198         rowUp[i] =  (rowUpper[i] - g[i]) + 1e-07;
     2238        //If constraint is equality not binding do not add
     2239        if(rowLower[i] > -infty && rowUpper[i] < infty && fabs(duals[i]) == 0.)
     2240        {
     2241            binding[i] = -1;
     2242            continue;
     2243        }
     2244        else
     2245          binding[i] = numBindings;
     2246        if(rowLower[i] > - infty_)
     2247          rowLow[numBindings] = (rowLower[i] - g[i]) - 1e-07;
     2248        else
     2249          rowLow[numBindings] = - infty_;
     2250        if(rowUpper[i] < infty_)
     2251          rowUp[numBindings] =  (rowUpper[i] - g[i]) + 1e-07;
     2252        else
     2253          rowUp[numBindings] = infty_;
     2254       
     2255        //If equality or ranged constraint only add one side by looking at sign of dual multiplier
     2256        if(rowLower[i] > -infty && rowUpper[i] < infty)
     2257        {
     2258          if(duals[i] >= 0)// <= inequality
     2259            rowLow[numBindings] = - infty;
     2260          if(duals[i] <= 0)// >= inequality
     2261            rowUp[numBindings] = infty;
     2262        }
     2263        numBindings++;
    21992264      }
    22002265      else {
    2201         rowLow[i] = (rowLower[i] - g[i]);
    2202         rowUp[i] =  (rowUpper[i] - g[i]);
     2266        binding[i] = numBindings;//All are considered as bindings
     2267        rowLow[numBindings] = (rowLower[i] - g[i]);
     2268        rowUp[numBindings] =  (rowUpper[i] - g[i]);
     2269        numBindings++;
    22032270      }
    22042271    }
     
    22062273
    22072274  //Then convert everything to a CoinPackedMatrix (col ordered)
    2208   CoinBigIndex * inds = new CoinBigIndex[nnz_jac_g];
    2209   double * vals = new double [nnz_jac_g];
     2275  CoinBigIndex * inds = new CoinBigIndex[nnz_jac_g + 1];
     2276  double * vals = new double [nnz_jac_g + 1];
    22102277  int * start = new int[n+1];
    22112278  int * length = new int[n];
    22122279  bool needOrder = false;
    22132280  int nnz = 0;
     2281  if(nnz_jac_g > 0)
     2282  {
    22142283  for(int k = 0; k < jCol_[0]; k++) {
    22152284    start[k] = nnz;
     
    22272296              rowLower[jRow_[i] - 1], rowUpper[jRow_[i] - 1],
    22282297              getColSolution()[jCol_[i] - 1],
    2229               rowLow[jRow_[i] - 1],
    2230               rowUp[jRow_[i] -1], tiny_, veryTiny_)) {
     2298              rowLow[binding[jRow_[i] - 1]],
     2299              rowUp[binding[jRow_[i] -1]], tiny_, veryTiny_)) {
     2300        if(binding[jRow_[i] - 1] == -1) continue;
    22312301        vals[nnz] = jValues_[i];
    2232         rowLow[jRow_[i] - 1] += jValues_[i] * getColSolution()[jCol_ [i] - 1];
    2233         rowUp[jRow_[i] -1] += jValues_[i] *getColSolution()[jCol_[i] -1];
    2234         inds[nnz] = jRow_[i ] - 1;
     2302        if(rowLow[binding[jRow_[i] - 1]] > - infty_)
     2303          rowLow[binding[jRow_[i] - 1]] += jValues_[i] * getColSolution()[jCol_ [i] - 1];
     2304        if(rowUp[binding[jRow_[i] - 1]] < infty_)
     2305          rowUp[binding[jRow_[i] -1]] += jValues_[i] *getColSolution()[jCol_[i] -1];
     2306        inds[nnz] = binding[jRow_[i] - 1];//jRow_[i ] - 1;
    22352307        length[jCol_[i] - 1]++;
    22362308        nnz++;
     
    22482320      length[jCol_[nnz_jac_g -1] - 1]++;
    22492321      vals[nnz] = jValues_[nnz_jac_g - 1];
    2250       rowLow[jRow_[nnz_jac_g - 1] - 1] += jValues_[nnz_jac_g - 1] * getColSolution()[jCol_ [nnz_jac_g - 1] - 1];
    2251       rowUp[jRow_[nnz_jac_g - 1] -1] += jValues_[nnz_jac_g - 1] *getColSolution()[jCol_[nnz_jac_g - 1] -1];
    2252       inds[nnz++] = jRow_[nnz_jac_g - 1] - 1;
     2322      rowLow[binding[jRow_[nnz_jac_g - 1] - 1]] += jValues_[nnz_jac_g - 1] * getColSolution()[jCol_ [nnz_jac_g - 1] - 1];
     2323      rowUp[binding[jRow_[nnz_jac_g - 1] -1]] += jValues_[nnz_jac_g - 1] *getColSolution()[jCol_[nnz_jac_g - 1] -1];
     2324      inds[nnz++] = binding[jRow_[nnz_jac_g - 1] - 1];
    22532325    }
    22542326    for(int i = jCol_[nnz_jac_g -1] ; i < n ; i++) {
     
    22572329    }
    22582330    start[n]=nnz;
    2259     mat.assignMatrix(false, m, n, nnz, vals, inds, start, length);
    22602331  }
    22612332  else {
     
    22642335  }
    22652336  delete [] g;
     2337  }
     2338  else {
     2339   for (int i = 0 ; i < n ; i++)
     2340   {
     2341     length[i] = 0;
     2342     start[i] = 0;
     2343   }
     2344   start[n]=0;
     2345 }
     2346 mat.assignMatrix(false, m, n, nnz, vals, inds, start, length);
    22662347  int numcols=getNumCols();
    22672348  double *obj = new double[numcols];
     
    22692350    obj[i] = 0;
    22702351  mat.transpose();
     2352 
    22712353#if 0
    22722354  std::cout<<"Mat is ordered by "<<
     
    22742356  <<std::endl;
    22752357#endif
     2358 
    22762359  si.loadProblem(mat, getColLower(), getColUpper(), obj, rowLow, rowUp);
    22772360  delete [] rowLow;
    22782361  delete [] rowUp;
     2362  delete [] binding;
    22792363  for(int i = 0 ; i < getNumCols() ; i++) {
    22802364    if(isInteger(i))
     
    22982382    v->reserve(n);
    22992383    for(int i = 0; i<n ; i++) {
     2384     if(nnz_jac_g)
     2385     {
    23002386      if(cleanNnz(obj[i],colLower[i], colUpper[i],
    23012387          -getInfinity(), 0,
     
    23072393        ub += obj[i] * getColSolution()[i];
    23082394      }
     2395     }
     2396     else //Unconstrained problem can not put clean coefficient
     2397     {
     2398         if(cleanNnz(obj[i],colLower[i], colUpper[i],
     2399          -getInfinity(), 0,
     2400          getColSolution()[i],
     2401          lb,
     2402          ub, 1e-03, 1e-08)) {
     2403        v->insert(i,obj[i]);
     2404        lb += obj[i] * getColSolution()[i];
     2405        ub += obj[i] * getColSolution()[i];
     2406         }
     2407     }
    23092408    }
    23102409    v->insert(n,-1);
     
    23132412  }
    23142413
    2315 // si.writeMps("init");
     2414si.writeMps("init");
    23162415
    23172416  setWarmStartOptions();
  • branches/devel/Bonmin/src/IpoptInterface/IpoptInterface.hpp

    r1 r26  
    957957  ///Store the types of the constraints (linear and nonlinear).
    958958  Ipopt::TMINLP::ConstraintType * constTypes_;
    959   /** Numerotation of linear/nonlinear constraints
     959  /* Numerotation of linear/nonlinear constraints
    960960   * Perform independent numerotation of linear (resp. nonlinear constraints)
    961961   * so that constraints of each type are numeroted consecutively */
    962   int * constTypesNum_;
     962 // int * constTypesNum_;
    963963  /** Number of linear constraints */
    964964  int nLinear_;
     
    970970  /** Value for small non-zero element which we will take the risk to ignore in OA cuts.*/
    971971  double veryTiny_;
    972 
     972  /** Value for infinity. */
     973  double infty_;
    973974
    974975};
  • branches/devel/Bonmin/src/IpoptInterface/TMINLP.hpp

    r1 r26  
    244244     */
    245245    virtual bool get_starting_point(Index n, bool init_x, Number* x,
     246                                    bool init_z, Number* z_L, Number* z_U,
    246247        Index m, bool init_lambda,
    247248        Number* lambda)=0;
  • branches/devel/Bonmin/src/IpoptInterface/TMINLP2TNLP.cpp

    r1 r26  
    7777    // Allocate space for the initial point
    7878    x_init_ = new Number[3*n_ + m_];
    79     tminlp_->get_starting_point(n_, true, x_init_,
     79    tminlp_->get_starting_point(n_, true, x_init_, false, NULL, NULL,
    8080        m_, false, NULL);
    8181    x_init_user_ = new Number[n_];
  • branches/devel/Bonmin/src/OaInterface/IpCbcOACutGenerator2.cpp

    r1 r26  
    77//
    88// Date : 05/26/2005
    9 #define OA_DEBUG
     9//#define OA_DEBUG
    1010
    1111#include "BonminConfig.h"
     
    522522        value = max(saveColLb[i],value);
    523523        value = min(value, saveColUb[i]);
     524        if(fabs(value) > 1e10) { std::cerr<<"FATAL ERROR: Variable taking a big value ("<<value
     525                                 <<") at optimium of LP relaxation, can not construct outer approximation. You should try running the problem with B-BB"<<std::endl;
     526         throw -1;
     527        }
    524528#ifdef OA_DEBUG
    525529        //         printf("xx %d at %g (bounds %g, %g)",i,value,nlp_->getColLower()[i],
     
    661665          !si_->isDualObjectiveLimitReached() && (objvalue<cutoff)) ;
    662666      //if value of integers are unchanged then we have to get out
    663       bool changed = !nlp_->isProvenOptimal()//if nlp_ is infeasible solution has necessarily changed
    664           && feasible;//if lp is infeasible we don't have to check anything
     667      bool changed = //!nlp_->isProvenOptimal()//if nlp_ is infeasible solution has necessarily changed
     668          !feasible;//if lp is infeasible we don't have to check anything
    665669      const double * nlpSol = nlp_->getColSolution();
    666670      const double * lpSol = si_->getColSolution();
    667671      for(int i = 0; i < numcols && !changed; i++) {
    668         if(nlp_->isInteger(i) && fabs(nlpSol[i] - lpSol[i])>cbcIntegerTolerance_)
     672        if(nlp_->isInteger(i) && fabs(nlpSol[i] - lpSol[i])>0.001)
    669673          changed = 1;
    670674      }
     
    696700          localSearchNodeLimit_ > 0 &&
    697701          CoinCpuTime() - timeBegin_ < maxLocalSearchTime_) {
     702         std::cout<<"Perform new local search"<<std::endl;
    698703        if(clp==NULL) {
    699704          nLocalSearch_++;
     
    712717          if(changed) {
    713718            feasible = (milpBound < cutoff);
     719            std::cout<<"milp bound "<<milpBound<<" cutoff "<<cutoff<<std::endl;
    714720          }
    715721          else
     
    745751          milpBound = siBestObj(model);
    746752          handler_->message(SOLVED_LOCAL_SEARCH, messages_)<<model->getNodeCount()<<model->getIterationCount()<<CoinMessageEol;
    747 
    748753          feasible =  (milpBound < cutoff);
    749           milpFeasible = feasible;
    750754          isInteger = model->getSolutionCount();
    751755          if(model->isProvenOptimal() || model->isProvenInfeasible()) {
    752             bool feasible = model->isProvenOptimal();
    753 
    754756            bool changed = 0;             //If integer solution is the same as nlp solution problem is solved
    755757            for(int i = 0; feasible && isInteger && i < numcols && !changed; i++) {
     
    771773
    772774        }/** endif solved by clp/cbc*/
     775
    773776        if(milpBound < cutoff)
    774777          handler_->message(UPDATE_LB, messages_)
     
    776779          <<CoinMessageEol;
    777780        else
     781        {
     782          milpBound = 1e50;
     783          feasible = 0;
    778784          handler_->message(OASUCCESS, messages_)
    779785          <<CoinCpuTime() - timeBegin_ <<CoinMessageEol;
     786        }
    780787      }/** endif localSearch*/
    781788      else if(model!=NULL)/** have to delete model for next iteration*/
Note: See TracChangeset for help on using the changeset viewer.