Changeset 340


Ignore:
Timestamp:
Feb 18, 2007 6:36:33 PM (13 years ago)
Author:
pbelotti
Message:

modified branch point, now solve ex3_1_1. Cut most of the output

Location:
branches/Couenne/Couenne/src
Files:
25 edited

Legend:

Unmodified
Added
Removed
  • branches/Couenne/Couenne/src/branch/CouenneBranchingObject.cpp

    r335 r340  
    11/*
    22 * Name:    CouenneBranchingObject.cpp
    3  * Author:  Pietro Belotti
     3 * Authors: Pierre Bonami, IBM Corp.
     4 *          Pietro Belotti, Carnegie Mellon University
    45 * Purpose: Branching object for auxiliary variables
    56 *
     
    1011
    1112
     13/// make branching point $\alpha$ away from current point:
     14/// bp = alpha * current + (1-alpha) * midpoint
     15
     16CouNumber CouenneBranchingObject::alpha_ = 0.9;
     17
     18
    1219/** \brief Constructor. Get a variable as an argument and set value_
    1320           through a call to operator () of that exprAux.
     
    1522
    1623CouenneBranchingObject::CouenneBranchingObject (expression *var):
    17   reference_ (var)
    18   {
    19     value_ = expression::Variable (reference_->Index());
    20   } // set the branching value at the current point
     24  reference_ (var) {
     25
     26  // set the branching value at the current point
     27  //  value_ = expression::Variable (reference_ -> Index ());
     28
     29  int index = reference_ -> Index ();
     30
     31  CouNumber
     32    x = expression::Variable (index),   // current solution
     33    l = expression::Lbound   (index),   //         lower bound
     34    u = expression::Ubound   (index),   //         upper
     35
     36    alpha = CouenneBranchingObject::Alpha ();
     37
     38  if ((l > - COUENNE_INFINITY + 1) &&
     39      (u <   COUENNE_INFINITY - 1))
     40    // finite bounds, apply midpoint rule
     41    value_ = alpha * x + (1-alpha) * (l+u) / 2.;
     42  else
     43    if ((fabs (x-l) > COUENNE_EPS) &&
     44        (fabs (x-u) > COUENNE_EPS))
     45      // infinite (at least on one side) bound interval, but x is not
     46      // at the boundary
     47      value_ = x;
     48    else
     49      // infinite bound interval, x is at the boundary
     50      // push it inwards
     51      // TODO: look for a proper value for the displacement
     52      if (fabs (x-l) < COUENNE_EPS) value_ += fabs (l) / 2.;
     53      else                          value_ -= fabs (u) / 2.;
     54}
    2155
    2256
     
    4074    solver -> setColUpper (reference_ -> Index(),
    4175                           reference_ -> isInteger() ? floor (value_) : value_);
    42   printf("Branching on %d, way %d, changing %s bound to %f.",
    43          reference_ -> Index(), way, (way)?"lower":"upper", value_);
     76
     77  printf ("Branch: x%d %c= %.12f\n", reference_ -> Index(), way ? '>' : '<', value_);
    4478
    4579  branchIndex_++;
  • branches/Couenne/Couenne/src/branch/CouenneBranchingObject.hpp

    r330 r340  
    11/*
    22 * Name:    CouenneBranchingObject.hpp
    3  * Author:  Pietro Belotti
     3 * Authors: Pierre Bonami, IBM Corp.
     4 *          Pietro Belotti, Carnegie Mellon University
    45 * Purpose: Branching object for auxiliary variables
    56 *
     
    1819
    1920public:
     21
     22  /// return global value for convex combination between current point
     23  /// and midpoint
     24  static CouNumber Alpha () {return alpha_;}
    2025
    2126  /// Constructor
     
    3742  /// the variable which this branching object refers to
    3843  expression *reference_;
     44
     45  /// global value for convex combination between current point and
     46  /// midpoint
     47  static CouNumber alpha_;
    3948};
    4049
  • branches/Couenne/Couenne/src/branch/CouenneChooseVariable.cpp

    r335 r340  
    11/*
    22 * Name:    CouenneChooseVariable.cpp
    3  * Author:  Pietro Belotti
     3 * Authors: Pierre Bonami, IBM Corp.
     4 *          Pietro Belotti, Carnegie Mellon University
    45 * Purpose: Branching object for choosing branching auxiliary variable
    56 *
     
    4344int CouenneChooseVariable::setupList (OsiBranchingInformation *info, bool initialize) {
    4445
    45   std::cout<<"Branching on :"<<std::endl;
     46  /*  std::cout<<"Branching on :"<<std::endl;
    4647  for(int kk = 0 ; kk < info -> numberColumns_ ; kk++)
    4748    {
     
    4950    }
    5051  std::cout<<std::endl;
     52  */
    5153  problem_ -> update ((CouNumber *) (info -> solution_),
    5254                      (CouNumber *) (info -> lower_),
  • branches/Couenne/Couenne/src/branch/CouenneChooseVariable.hpp

    r330 r340  
    11/*
    22 * Name:    CouenneChooseVariable.hpp
    3  * Author:  Pietro Belotti
     3 * Authors: Pierre Bonami, IBM Corp.
     4 *          Pietro Belotti, Carnegie Mellon University
    45 * Purpose: Branching object for choosing branching auxiliary variable
    56 *
  • branches/Couenne/Couenne/src/branch/CouenneObject.cpp

    r335 r340  
    11/*
    22 * Name:    CouenneObject.cpp
    3  * Author:  Pietro Belotti
     3 * Authors: Pierre Bonami, IBM Corp.
     4 *          Pietro Belotti, Carnegie Mellon University
    45 * Purpose: Base object for variables (to be used in branching)
    56 *
     
    1617    const double & expr = (*(reference_ -> Image ())) ();
    1718    const double & var = expression::Variable (reference_ -> Index ());
    18     bool verbose = 1;
     19    bool verbose = 0;
    1920    if(verbose){
    2021      reference_->print(std::cout);
     
    3233
    3334  //
    34   int index = reference_ -> getFixVar () -> Index ();
     35  int    index = reference_ -> getFixVar () -> Index ();
     36  double val   = info -> solution_ [index];
    3537
    3638  //
    37   solver -> setColLower (index, info -> solution_ [index]);
    38   solver -> setColUpper (index, info -> solution_ [index]);
     39  solver -> setColLower (index, val);
     40  solver -> setColUpper (index, val);
    3941
    4042  return 0.;
     
    4648                                                 const OsiBranchingInformation *,
    4749                                                 int) const {
     50  /*  printf ("create branch for aux x%d (branch on x%d)\n",
     51          reference_ -> Index(),
     52          reference_ -> Image() -> getFixVar () ->Index());
     53  */
    4854  return new CouenneBranchingObject (reference_ -> Image () -> getFixVar ());
    4955}
  • branches/Couenne/Couenne/src/branch/CouenneObject.hpp

    r330 r340  
    11/*
    22 * Name:    CouenneObject.hpp
    3  * Author:  Pietro Belotti
     3 * Authors: Pierre Bonami, IBM Corp.
     4 *          Pietro Belotti, Carnegie Mellon University
    45 * Purpose: Object for auxiliary variables
    56 *
  • branches/Couenne/Couenne/src/branch/getFixVarBinFun.cpp

    r330 r340  
    1515expression *getFixVarBinFun (expression *arg0, expression *arg1) {
    1616
    17   if      (arg0 -> Type () == CONST) return arg1; // Case c*y
    18   else if (arg1 -> Type () == CONST) return arg0; // Case x*d
     17  if      (arg0 -> Type () == CONST) return arg1; // Case c*y or c/y
     18  else if (arg1 -> Type () == CONST) return arg0; // Case x*d or x/d
    1919  else {
    2020
    21     // Case x*y: return variable closest to midpoint in bound interval
     21    // Case x*y, x/y: return variable closest to midpoint in bound interval
    2222
    2323    // get variables' indices
  • branches/Couenne/Couenne/src/convex/CouenneCutGenerator.cpp

    r335 r340  
    1515
    1616
    17 // constructor
     17/// constructor
    1818
    1919CouenneCutGenerator::CouenneCutGenerator (const ASL_pfgh *asl, bool addviolated,
     
    4444
    4545
    46 // destructor
     46/// destructor
    4747
    4848CouenneCutGenerator::~CouenneCutGenerator () {
     
    6060
    6161
    62 // clone method
     62/// clone method
    6363
    6464CouenneCutGenerator *CouenneCutGenerator::clone () const
     
    6666
    6767
    68 // copy constructor
     68/// copy constructor
    6969
    7070CouenneCutGenerator::CouenneCutGenerator (const CouenneCutGenerator &src):
    7171  CglCutGenerator (),
    72   ncuts_       (src.getncuts ()),
     72  ncuts_       (src. getncuts ()),
    7373  pool_        (new OsiRowCut * [ncuts_]),
    7474  bonCs_       (new OsiCuts (*(src.getBonCs ()))),
    75   bonOs_       (src.getBonOs () -> clone ()),
    76   firstcall_   (src.isFirst ()),
     75  bonOs_       (src. getBonOs () -> clone ()),
     76  firstcall_   (src. isFirst ()),
    7777  addviolated_ (src. addViolated ()),
    7878  convtype_    (src. ConvType ()),
    7979  nSamples_    (src. nSamples ()),
    80   problem_     (src.Problem() -> clone ()) {
     80  problem_     (src. Problem() -> clone ()) {
    8181
    8282  for (int i=0; i<ncuts_; i++)
     
    8585
    8686
    87 // add half-space through two points (x1,y1) and (x2,y2)
     87/// add half-space through two points (x1,y1) and (x2,y2)
    8888
    8989void CouenneCutGenerator::addSegment (OsiCuts &cs, int wi, int xi,
     
    9191                                      CouNumber x2, CouNumber y2, int sign) const {
    9292
    93   if (fabs (x2-x1) < COUENNE_EPS) {
    94     fprintf (stderr, "CouenneCutGenerator::addSegment(): warning, x1=x2\n");
    95     return;
     93  OsiRowCut *cut = NULL;
     94
     95  if (fabs (x2-x1) < COUENNE_EPS)
     96    // well, we suppose that y1=y2...
     97    cut = createCut (y2, 0, wi, CouNumber (1.));
     98  else {
     99
     100    CouNumber oppslope = (y1-y2) / (x2-x1);
     101
     102    cut = createCut (y1 + oppslope * x1, sign,
     103                     wi, CouNumber (1.),
     104                     xi, oppslope);
    96105  }
    97 
    98   CouNumber oppslope = (y1-y2) / (x2-x1);
    99 
    100   OsiRowCut *cut = createCut (y1 + oppslope * x1, sign,
    101                               wi, CouNumber (1.),
    102                               xi, oppslope);
    103 
    104   //  if (cut) {printf ("Segment: "); cut -> print ();}
    105106
    106107  if (cut)
     
    108109}
    109110
     111
     112/// update auxiliary variables from original
     113
    110114void CouenneCutGenerator::updateAuxs (CouNumber *x, CouNumber *l, CouNumber *u) {
    111115
    112   problem_ -> update (x,l,u);
     116  problem_ -> update (x, l, u);
    113117
    114   for (int i=0, j=problem_->nVars(); i<problem_ -> nAuxs (); i++, j++) {
    115     x [j] = (*(problem_ -> Aux (i))) ();
    116     l [j] = (*(problem_ -> Aux (i) -> Lb ())) ();
    117     u [j] = (*(problem_ -> Aux (i) -> Ub ())) ();
     118  int nAux = problem_ -> nAuxs ();
     119
     120  for (int i = 0, j = problem_ -> nVars (); i < nAux; i++, j++) {
     121
     122    exprAux *aux = problem_ -> Aux (i);
     123
     124    x [j] = (*aux)            ();
     125    l [j] = (*(aux -> Lb ())) ();
     126    u [j] = (*(aux -> Ub ())) ();
    118127  }
    119128}
  • branches/Couenne/Couenne/src/convex/conv-exprOp.cpp

    r296 r340  
    11/*
    2  * Name:    conv-exprOp.C
     2 * Name:    conv-exprOp.cpp
    33 * Author:  Pietro Belotti
    44 * Purpose: methods to convexify n-ary operators
  • branches/Couenne/Couenne/src/convex/conv-exprUnary.cpp

    r296 r340  
    11/*
    2  * Name:    conv-exprUnary.C
     2 * Name:    conv-exprUnary.cpp
    33 * Author:  Pietro Belotti
    44 * Purpose: methods to convexify n-ary operators
     
    99#include <CouenneTypes.h>
    1010#include <exprUnary.h>
    11 #include <exprSum.h>
    12 #include <exprSub.h>
    1311#include <exprClone.h>
    14 #include <exprOpp.h>
    15 #include <exprDiv.h>
    16 #include <exprMul.h>
    1712
    1813#include <CouenneProblem.h>
  • branches/Couenne/Couenne/src/convex/generateCuts.cpp

    r335 r340  
    8181
    8282    problem_ ->  update (x,l,u);
    83     //    expression:: update (x,l,u);
    8483  }
    8584
     
    9291  // end of generateCuts
    9392
    94   if (cs.sizeRowCuts ())
    95     printf ("Couenne: %d convexifier cuts\n", cs.sizeRowCuts ());
     93  //  if (cs.sizeRowCuts ())
     94  //    printf ("Couenne: %d convexifier cuts\n", cs.sizeRowCuts ());
    9695
    97   for (int i = cs.sizeRowCuts (); i--;)
    98     cs.rowCutPtr (i) -> print ();
    99 
    100   printf ("==============================================\n");
    10196  if (firstcall_)
    10297    firstcall_ = false;
  • branches/Couenne/Couenne/src/expression/expression.cpp

    r335 r340  
    118118  //  image_ -> print (std::cout); printf("\n");
    119119
    120   int j=cs.sizeRowCuts ();
     120  int j = cs.sizeRowCuts ();
    121121
    122122  image_ -> generateCuts (this, si, cs, cg);
    123123
    124  
    125124  //  if (!(cg -> isFirst ()))
    126   {
    127     printf ("----------------Generated cut for ");
    128     print (std::cout);  printf (" := ");
    129     image_ -> print (std::cout); printf("\n");
    130     for (;j < cs.sizeRowCuts ();j++)
    131       cs.rowCutPtr (j) -> print ();
    132   }
    133  
     125  //  if (j < cs.sizeRowCuts ())
     126  if (0)
     127    {
     128      printf ("----------------Generated cut for ");
     129      print (std::cout);  printf (" := ");
     130      image_ -> print (std::cout); printf("\n");
     131      for (;j < cs.sizeRowCuts ();j++)
     132        cs.rowCutPtr (j) -> print ();
     133    }
    134134}
    135135
  • branches/Couenne/Couenne/src/expression/operators/exprExp.cpp

    r298 r340  
    88
    99#include <exprExp.h>
    10 #include <exprCopy.h>
     10#include <exprClone.h>
    1111#include <exprMul.h>
    1212
     
    1818  expression **arglist = new expression * [2];
    1919
    20   arglist [0] = new exprExp (new exprCopy (argument_));
     20  arglist [0] = new exprExp (new exprClone (argument_));
    2121  arglist [1] = argument_ -> differentiate (index);
    2222
  • branches/Couenne/Couenne/src/expression/operators/exprLog.cpp

    r304 r340  
    4343  expression **arglist = new expression * [2];
    4444
    45   arglist [0] = new exprInv (new exprCopy (argument_));
     45  arglist [0] = new exprInv (new exprClone (argument_));
    4646  arglist [1] = argument_ -> differentiate (index);
    4747
  • branches/Couenne/Couenne/src/expression/operators/exprMul.cpp

    r335 r340  
    1414
    1515
    16 // simplify multiplications
     16/// simplify multiplications
    1717
    1818expression *exprMul::simplify () {
     
    103103
    104104
    105 // print
     105/// print
    106106
    107107void exprMul::print (std::ostream& out) const
     
    140140// in a branching rule for solving a nonconvexity gap
    141141expression *exprMul::getFixVar ()
    142 {printf ("...................using correct getFixVar for" );
    143  print(std::cout); std::cout << " ---> ";
    144  expression *ret =  getFixVarBinFun (arglist_ [0], arglist_ [1]);
    145  ret -> print (std::cout);
    146  return ret;
    147 }
     142{return getFixVarBinFun (arglist_ [0], arglist_ [1]);}
  • branches/Couenne/Couenne/src/include/exprClone.h

    r310 r340  
    1717
    1818
    19 // expression clone (points to VALUE and EXPRESSION of another expression)
     19/// expression clone (points to VALUE and EXPRESSION of another expression)
    2020
    2121class exprClone: public exprCopy {
     
    2323 public:
    2424
    25   // Constructor, destructor
     25  /// Constructor
    2626  exprClone  (expression *copy):
    2727    exprCopy (copy) {}
     28
     29  /// destructor
    2830  ~exprClone () {}
    2931
    30   // copy constructor
     32  /// copy constructor
    3133  exprClone (const exprClone &e):
    3234    exprCopy (e) {}
    3335
    34   // cloning method
     36  /// cloning method
    3537  exprClone *clone () const
    3638  {return new exprClone (*this);}
    3739
    38   // I/O
     40  /// I/O
    3941  void print (std::ostream &out) const
    40     //  {out << "{"; copy_ -> Original () -> print (out); out << "}";}
    41   {copy_ -> Original () -> print (out);}
     42    //{out << "{"; copy_ -> Original () -> print (out); out << "}";}
     43    {copy_ -> Original () -> print (out);}
     44    //{copy_ -> print (out);}
     45    //{out << ",";}
    4246
    43   // value (empty)
     47  /// value
    4448  inline CouNumber Value () const
    4549    {return copy_ -> Value ();}
    4650
    47   // null function for evaluating the expression
     51  /// null function for evaluating the expression
    4852  inline CouNumber operator () ()
    4953    {return (currValue_ = (*copy_) ());}
  • branches/Couenne/Couenne/src/include/exprConst.h

    r298 r340  
    1414#include <CouenneTypes.h>
    1515#include <expression.h>
    16 #include <exprCopy.h>
     16#include <exprClone.h>
    1717
    1818
     
    8080  // Get lower and upper bound of an expression (if any)
    8181  inline void getBounds (expression *&lower, expression *&upper) {
    82     lower = new exprCopy (this);
    83     upper = new exprCopy (this);
     82    lower = new exprClone (this);
     83    upper = new exprClone (this);
    8484  }
    85 
    86   // construct linear under-estimator for expression within problem *p
    87   // (p is used to add convexification constraints)
    88   //  int lowerLinearHull (exprAux *, int *&, expression ***&,
    89   //                   int **&, expression **&, enum con_sign *&);
    9085
    9186  // Create standard formulation of this expression
  • branches/Couenne/Couenne/src/include/exprCopy.h

    r330 r340  
    8686  // simplify expression (useful for derivatives)
    8787  inline expression *simplify ()
    88     {return NULL;}
     88    {return copy_ -> simplify ();}
    8989
    9090  // get a measure of "how linear" the expression is:
  • branches/Couenne/Couenne/src/include/exprOp.h

    r335 r340  
    106106  // return an index to the variable's argument that is better fixed
    107107  // in a branching rule for solving a nonconvexity gap
    108   virtual expression *getFixVar () {printf ("////////////////////////\n\n");return arglist_ [0];}
     108  virtual expression *getFixVar () {return arglist_ [0];}
    109109};
    110110
  • branches/Couenne/Couenne/src/include/operators/exprMax.h

    r304 r340  
    1111
    1212#include <exprOp.h>
    13 #include <exprCopy.h>
    1413
    1514
     
    2625  exprMax  (expression *el0, expression *el1):
    2726    exprOp (new expression * [4], 4) {
    28     arglist_ [0] = el0; arglist_ [1] = new exprCopy (el0);
    29     arglist_ [2] = el1; arglist_ [3] = new exprCopy (el1);
     27    arglist_ [0] = el0; arglist_ [1] = new exprClone (el0);
     28    arglist_ [2] = el1; arglist_ [3] = new exprClone (el1);
    3029  }
    3130
  • branches/Couenne/Couenne/src/include/operators/exprMin.h

    r330 r340  
    2525  exprMin  (expression *el0, expression *el1):
    2626    exprOp (new expression * [4], 4) {
    27     arglist_ [0] = el0; arglist_ [1] = new exprCopy (el0);
    28     arglist_ [2] = el1; arglist_ [3] = new exprCopy (el1);
     27    arglist_ [0] = el0; arglist_ [1] = new exprClone (el0);
     28    arglist_ [2] = el1; arglist_ [3] = new exprClone (el1);
    2929  }
    3030
  • branches/Couenne/Couenne/src/problem/problem.cpp

    r312 r340  
    5555void CouenneProblem::addEQConstraint (expression *body, expression *rhs = NULL) {
    5656  if (!rhs) rhs = new exprConst (0);
    57   constraints_ . push_back (new CouenneConstraint (body, rhs, new exprCopy (rhs)));
     57  constraints_ . push_back (new CouenneConstraint (body, rhs, new exprClone (rhs)));
    5858}
    5959
     
    208208
    209209  if (curr_size < nvars) {
     210
    210211    x_   = (CouNumber *) realloc (x_,  nvars * sizeof (CouNumber));
    211212    lb_  = (CouNumber *) realloc (lb_, nvars * sizeof (CouNumber));
     
    215216  }
    216217
    217   register int i;
    218 
    219   for (i=nvars; i--;) {
     218  for (register int i=nvars; i--;) {
    220219    x_  [i] = x [i];
    221220    lb_ [i] = l [i];
  • branches/Couenne/Couenne/src/readnl/nl2e.cpp

    r318 r340  
    3535
    3636
     37// warning for non-implemented functions -- return 0 constant expression
     38
     39expression *notimpl (const std::string &fname) {
     40  std::cerr << "*** Warning: " << fname << " not implemented" << std::endl;
     41  return new exprConst (0);
     42}
     43
     44
    3745// converts an AMPL expression (sub)tree into an expression* (sub)tree
    3846
     
    4250  expr **ep;
    4351  expression *arg;
     52  int j;
    4453
    4554  switch (getOperator (e -> op)) {
     
    4958  case OPMULT:   return new exprMul (nl2e (e -> L.e), nl2e (e -> R.e));
    5059  case OPDIV:    return new exprDiv (nl2e (e -> L.e), nl2e (e -> R.e));
    51   case OPREM:   printf ("remainder not implemented\n"); return new exprConst (0);
     60  case OPREM:   return notimpl ("remainder");
    5261  case OPPOW:    return new exprPow (nl2e (e -> L.e), nl2e (e -> R.e));
    53   case OPLESS:  printf ("less not implemented\n"); return new exprConst (0);
    54   case MINLIST: printf ("min not implemented\n"); return new exprConst (0);
    55   case MAXLIST: printf ("max not implemented\n"); return new exprConst (0);
    56   case FLOOR:   printf ("floor not implemented\n"); return new exprConst (0);
    57   case CEIL:    printf ("ceil not implemented\n"); return new exprConst (0);
     62  case OPLESS:  return notimpl ("less");
     63  case MINLIST: return notimpl ("min");
     64  case MAXLIST: return notimpl ("max");
     65  case FLOOR:   return notimpl ("floor");
     66  case CEIL:    return notimpl ("ceil");
    5867  case ABS:     return new exprAbs (nl2e (e -> L.e));
    5968    //  case OPUMINUS:return new exprOpp (nl2e (e -> L.e -> L.e));
    6069  case OPUMINUS:return new exprOpp (nl2e (e -> L.e));
    61   case OPIFnl:  printf ("ifnl not implemented\n"); return new exprConst (0);
    62   case OP_tanh: printf ("tanh not implemented\n"); return new exprConst (0);
     70  case OPIFnl:  return notimpl ("ifnl");
     71  case OP_tanh: return notimpl ("tanh");
    6372  case OP_tan: 
    6473    arg = nl2e (e -> L.e);
     
    7887
    7988  case OP_cos:     return new exprCos (nl2e (e -> L.e));
    80   case OP_atanh: printf ("atanh not implemented\n"); return new exprConst (0);
    81   case OP_atan2: printf ("atan2 not implemented\n"); return new exprConst (0);
    82   case OP_atan:  printf ("atan not implemented\n"); return new exprConst (0);
    83   case OP_asinh: printf ("asinh not implemented\n"); return new exprConst (0);
    84   case OP_asin:  printf ("asin not implemented\n"); return new exprConst (0);
    85   case OP_acosh: printf ("acosh not implemented\n"); return new exprConst (0);
    86   case OP_acos:  printf ("acos not implemented\n"); return new exprConst (0);
     89  case OP_atanh: return notimpl ("atanh");
     90  case OP_atan2: return notimpl ("atan2");
     91  case OP_atan:  return notimpl ("atan");
     92  case OP_asinh: return notimpl ("asinh");
     93  case OP_asin:  return notimpl ("asin");
     94  case OP_acosh: return notimpl ("acosh");
     95  case OP_acos:  return notimpl ("acos");
    8796  case OPSUMLIST: {
    8897    register int i=0;
     
    92101    return new exprSum (al, i);
    93102  }
    94   case OPintDIV: printf ("intdiv not implemented\n"); return new exprConst (0);
    95   case OPprecision: printf ("precision not implemented\n"); return new exprConst (0);
    96   case OPround:  printf ("round not implemented\n"); return new exprConst (0);
    97   case OPtrunc:  printf ("trunc not implemented\n"); return new exprConst (0);
     103  case OPintDIV: return notimpl ("intdiv");
     104  case OPprecision: return notimpl ("precision");
     105  case OPround:  return notimpl ("round");
     106  case OPtrunc:  return notimpl ("trunc");
    98107
    99108  case OP1POW: return new exprPow (nl2e (e -> L.e),
     
    103112  case OPCPOW: return new exprPow (new exprConst (((expr_n *)e->L.e)->v),
    104113                                   nl2e (e -> R.e));
    105   case OPFUNCALL: printf ("function call not implemented\n"); return new exprConst (0);
     114  case OPFUNCALL: return notimpl ("function call");
    106115  case OPNUM:   return new exprConst (((expr_n *)e)->v);
    107   case OPPLTERM:  printf ("plterm not implemented\n"); return new exprConst (0);
    108   case OPIFSYM:   printf ("ifsym not implemented\n"); return new exprConst (0);
    109   case OPHOL:     printf ("hol not implemented\n"); return new exprConst (0);
    110   case OPVARVAL: return new exprClone (variables_ [e->a]);
     116  case OPPLTERM:  return notimpl ("plterm");
     117  case OPIFSYM:   return notimpl ("ifsym");
     118  case OPHOL:     return notimpl ("hol");
     119  case OPVARVAL: 
     120    // check if index is above number of variables
     121    // (should never happen, but it depends on some map [] in pfg_read.c)
     122    if ((j = ((expr2_v *) e) -> a) >= nVars ())
     123      for (int i=nVars(); i<=j; i++)
     124        addVariable (false);
     125    return new exprClone (variables_ [j]);
    111126
    112127  case -1:
  • branches/Couenne/Couenne/src/readnl/readnl.cpp

    r331 r340  
    104104        nterms++;
    105105
    106     if (   (OBJ_DE [i] . e)
    107            && (!is_expr_zero (OBJ_DE [i] . e)))
     106    if ((OBJ_DE [i] . e) && (!is_expr_zero (OBJ_DE [i] . e)))
    108107      nterms++;
     108
     109    if (!nterms) // strange, but no (linear or nonlinear) terms in here
     110      continue;
    109111
    110112    // now we can fill in the objective function terms
     
    145147    // ThirdParty/ASL/solvers/asl.h, line 336: 0 is minimization, 1 is maximization
    146148    addObjective (body, (OBJ_sense [i] == 0) ? "min" : "max");
    147 
    148     //    delete [] al;
    149149  }
    150150
     
    264264
    265265      expression *subst = body -> simplify ();
    266 
    267266      if (subst) body = subst;
    268267
  • branches/Couenne/Couenne/src/simplify/simplify.cpp

    r293 r340  
    11/*
    2  * Name:    simplify.C
     2 * Name:    simplify.cpp
    33 * Author:  Pietro Belotti
    44 * Purpose: symbolic expression simplifier
Note: See TracChangeset for help on using the changeset viewer.