Changeset 98


Ignore:
Timestamp:
Apr 6, 2009 9:50:17 PM (13 years ago)
Author:
pbelotti
Message:

fixed dynamic_cast on wrong pointer, and made all other dynamic_cast's safe. Included readnl.cpp in Couenne executable to make it build in debug as well.

Location:
trunk/Couenne/src
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/Couenne/src/branch/feasibleRegion.cpp

    r39 r98  
    7676      (expr -> code () == COU_EXPRQUAD)) {
    7777
    78     exprGroup *e = dynamic_cast <exprGroup *> (expr);
     78    exprGroup *e = dynamic_cast <exprGroup *> (expr -> isaCopy () ?
     79                                               expr -> Copy () :
     80                                               expr);
    7981
    8082    exprGroup::lincoeff &lcoe = e -> lcoeff ();
     
    9092    if (expr -> code () == COU_EXPRQUAD) {
    9193
    92       exprQuad *e = dynamic_cast <exprQuad *> (expr);
     94      exprQuad *e = dynamic_cast <exprQuad *> (expr -> isaCopy () ?
     95                                               expr -> Copy () :
     96                                               expr);
    9397
    9498      exprQuad::sparseQ q = e -> getQ ();
  • trunk/Couenne/src/expression/operators/bounds/exprBQuad.hpp

    r1 r98  
    3030  /// copy constructor
    3131  exprLBQuad (const exprLBQuad &src, Domain *d = NULL):
    32     ref_ (dynamic_cast <exprQuad *> (src.ref_ -> clone (d))) {}
     32    ref_ (dynamic_cast <exprQuad *> (src.ref_ -> isaCopy () ?
     33                                     src.ref_ -> Copy () -> clone (d) :
     34                                     src.ref_ -> clone (d))) {}
    3335
    3436  /// destructor
     
    6668  /// copy constructor
    6769  exprUBQuad (const exprUBQuad &src, Domain *d = NULL):
    68     ref_ (dynamic_cast <exprQuad *> (src.ref_ -> clone (d))) {}
     70    ref_ (dynamic_cast <exprQuad *> (src.ref_ -> isaCopy () ?
     71                                     src.ref_ -> Copy () -> clone (d) :
     72                                     src.ref_ -> clone (d))) {}
    6973
    7074  /// destructor
  • trunk/Couenne/src/main/Makefile.am

    r97 r98  
    5656        ../libCouenne.la
    5757
    58 couenne_SOURCES = BonCouenne.cpp
     58couenne_SOURCES = \
     59        ../readnl/readnl.cpp \
     60        BonCouenne.cpp
    5961
    6062couenne_LDADD += \
  • trunk/Couenne/src/main/Makefile.in

    r97 r98  
    7676binPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
    7777PROGRAMS = $(bin_PROGRAMS)
    78 am_couenne_OBJECTS = BonCouenne.$(OBJEXT)
     78am_couenne_OBJECTS = readnl.$(OBJEXT) BonCouenne.$(OBJEXT)
    7979couenne_OBJECTS = $(am_couenne_OBJECTS)
    8080@COIN_HAS_CPX_TRUE@am__DEPENDENCIES_1 =  \
     
    321321        ../libCouenne.la
    322322
    323 couenne_SOURCES = BonCouenne.cpp
     323couenne_SOURCES = \
     324        ../readnl/readnl.cpp \
     325        BonCouenne.cpp
     326
    324327
    325328# Finally, the -rpath flag is used by libtool to make sure that the shared
     
    483486@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/BonInitHeuristic.Plo@am__quote@
    484487@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/BonNlpHeuristic.Plo@am__quote@
     488@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/readnl.Po@am__quote@
    485489
    486490.cpp.o:
     
    504508@AMDEP_TRUE@@am__fastdepCXX_FALSE@      DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
    505509@am__fastdepCXX_FALSE@  $(LTCXXCOMPILE) -c -o $@ $<
     510
     511readnl.o: ../readnl/readnl.cpp
     512@am__fastdepCXX_TRUE@   if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT readnl.o -MD -MP -MF "$(DEPDIR)/readnl.Tpo" -c -o readnl.o `test -f '../readnl/readnl.cpp' || echo '$(srcdir)/'`../readnl/readnl.cpp; \
     513@am__fastdepCXX_TRUE@   then mv -f "$(DEPDIR)/readnl.Tpo" "$(DEPDIR)/readnl.Po"; else rm -f "$(DEPDIR)/readnl.Tpo"; exit 1; fi
     514@AMDEP_TRUE@@am__fastdepCXX_FALSE@      source='../readnl/readnl.cpp' object='readnl.o' libtool=no @AMDEPBACKSLASH@
     515@AMDEP_TRUE@@am__fastdepCXX_FALSE@      DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     516@am__fastdepCXX_FALSE@  $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o readnl.o `test -f '../readnl/readnl.cpp' || echo '$(srcdir)/'`../readnl/readnl.cpp
     517
     518readnl.obj: ../readnl/readnl.cpp
     519@am__fastdepCXX_TRUE@   if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT readnl.obj -MD -MP -MF "$(DEPDIR)/readnl.Tpo" -c -o readnl.obj `if test -f '../readnl/readnl.cpp'; then $(CYGPATH_W) '../readnl/readnl.cpp'; else $(CYGPATH_W) '$(srcdir)/../readnl/readnl.cpp'; fi`; \
     520@am__fastdepCXX_TRUE@   then mv -f "$(DEPDIR)/readnl.Tpo" "$(DEPDIR)/readnl.Po"; else rm -f "$(DEPDIR)/readnl.Tpo"; exit 1; fi
     521@AMDEP_TRUE@@am__fastdepCXX_FALSE@      source='../readnl/readnl.cpp' object='readnl.obj' libtool=no @AMDEPBACKSLASH@
     522@AMDEP_TRUE@@am__fastdepCXX_FALSE@      DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     523@am__fastdepCXX_FALSE@  $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o readnl.obj `if test -f '../readnl/readnl.cpp'; then $(CYGPATH_W) '../readnl/readnl.cpp'; else $(CYGPATH_W) '$(srcdir)/../readnl/readnl.cpp'; fi`
    506524
    507525mostlyclean-libtool:
  • trunk/Couenne/src/problem/CouenneProblem.cpp

    r78 r98  
    324324void CouenneProblem::addObjective (expression *newobj, const std::string &sense = "min") {
    325325  objectives_ . push_back
    326     (new CouenneObjective ((sense == "min") ? newobj : new exprOpp (new exprClone (newobj))));//, MINIMIZE));
     326    (new CouenneObjective ((sense == "min") ?
     327                           newobj : new exprOpp (new exprClone (newobj))));
    327328}
    328329
  • trunk/Couenne/src/problem/CouenneSOS.cpp

    r39 r98  
    3535        ((*v) -> Image () -> code () == COU_EXPRGROUP)) {
    3636
    37       exprGroup *group = dynamic_cast <exprGroup *> ((*v) -> Image ());
     37      expression *img = (*v) -> Image ();
    3838
     39      exprGroup *group = dynamic_cast <exprGroup *> (img -> isaCopy () ?
     40                                                     img -> Copy () :
     41                                                     img);
    3942      if (!group)
    4043        continue;
  • trunk/Couenne/src/problem/problem.cpp

    r79 r98  
    192192  case COU_EXPRGROUP: { //
    193193
    194     exprGroup *eg    = dynamic_cast <exprGroup *> (body);
     194    exprGroup *eg    = dynamic_cast <exprGroup *> (body -> isaCopy () ?
     195                                                   body -> Copy () :
     196                                                   body);
    195197
    196198    const exprGroup::lincoeff &lcoe = eg -> lcoeff ();
  • trunk/Couenne/src/readnl/readnl.cpp

    r80 r98  
    255255
    256256    expression *subst = body -> simplify ();
     257
    257258    if (subst) {
    258259      delete body; // VALGRIND
  • trunk/Couenne/src/standardize/decomposeTerm.cpp

    r1 r98  
    5656  case COU_EXPRQUAD: { /// a quadratic form
    5757
    58     exprQuad *t = dynamic_cast <exprQuad *> (term);
     58    exprQuad *t = dynamic_cast <exprQuad *> (term -> isaCopy () ?
     59                                             term -> Copy () :
     60                                             term);
    5961    exprQuad::sparseQ &M = t -> getQ ();
    6062
     
    7375  case COU_EXPRGROUP: { /// a linear term
    7476
    75     exprGroup *t = dynamic_cast <exprGroup *> (term);
     77    exprGroup *t = dynamic_cast <exprGroup *> (term -> isaCopy () ?
     78                                               term -> Copy () :
     79                                               term);
    7680    exprGroup::lincoeff &lcoe = t -> lcoeff ();
    7781
  • trunk/Couenne/src/standardize/splitAux.cpp

    r91 r98  
    114114    if (code != COU_EXPRSUM) {
    115115
    116       exprGroup *egBody = dynamic_cast <exprGroup *> (body);
     116      exprGroup *egBody = dynamic_cast <exprGroup *> (body -> isaCopy () ?
     117                                                      body -> Copy () :
     118                                                      body);
    117119      exprGroup::lincoeff &lcoe = egBody -> lcoeff ();
    118120
     
    244246    if (nlin > 0) { // there is an element in the linear sum to be drawn
    245247
    246       exprGroup *egBody = dynamic_cast <exprGroup *> (body);
     248      exprGroup *egBody = dynamic_cast <exprGroup *> (body -> isaCopy () ?
     249                                                      body -> Copy () :
     250                                                      body);
    247251      exprGroup::lincoeff &lcoe = egBody -> lcoeff ();
    248252
     
    273277      if (code == COU_EXPRQUAD) { // copy quadratic elements
    274278
    275         exprQuad *eq = dynamic_cast <exprQuad *> (body);
     279        exprQuad *eq = dynamic_cast <exprQuad *> (body -> isaCopy () ?
     280                                                  body -> Copy () :
     281                                                  body);
    276282
    277283        int nqt = eq -> getnQTerms (), j=0;
Note: See TracChangeset for help on using the changeset viewer.