Changeset 61


Ignore:
Timestamp:
Dec 13, 2008 4:52:42 PM (13 years ago)
Author:
pbelotti
Message:

fixed some method for quadratic functions. Deleted useless problem print.

Location:
trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/Couenne/src/convex/operators/alphaConvexify.cpp

    r1 r61  
    8181      delete [] indexmap;
    8282      delete [] indices;
     83
     84#ifdef DEBUG
     85      printf ("unbounded, bailing out\n");
     86#endif
    8387
    8488      return false;
  • trunk/Couenne/src/convex/operators/conv-exprMul.cpp

    r39 r61  
    44 * Purpose: utility methods to convexify multiplications
    55 *
    6  * (C) Carnegie-Mellon University, 2006.
     6 * (C) Carnegie-Mellon University, 2006-08.
    77 * This file is licensed under the Common Public License (CPL)
    88 */
     
    4141     return aux;
    4242     } */
     43
     44  // check if it is a product of binary variables
     45  bool isBinProd = true;
     46  for (int i=nargs_; i--;) {
     47
     48    expression *arg = arglist_ [i];
     49    if (arg -> isInteger ()) {
     50
     51      CouNumber lb, ub;
     52      arg -> getBounds (lb, ub);
     53      if ((fabs (lb)      > 0.) ||
     54          (fabs (ub - 1.) > 0.)) { // if not all conditions hold,
     55        isBinProd = false;
     56        break;
     57      }
     58    } else {
     59      isBinProd = false;
     60      break;
     61    }
     62  }
     63
     64  if (isBinProd) {
     65
     66    //printf ("found a BinProd!\n");
     67
     68  }
    4369
    4470  //expression *aux = arglist_ [0]; // why not this one?
  • trunk/Couenne/src/convex/operators/conv-exprQuad.cpp

    r1 r61  
    66 * Purpose: implementation of convexification methods for exprQuad
    77 *
    8  * (C) Carnegie-Mellon University, 2006.
     8 * (C) Carnegie-Mellon University, 2006-08.
    99 * This file is licensed under the Common Public License (CPL)
    1010 */
     
    2626  /*printf ("generated quad bounds:\n  ");
    2727  lb -> print (); printf (" [%g]\n  ", (*lb) ());
    28   ub -> print (); printf (" [%g]\n", (*ub) ());*/
     28  ub -> print (); printf (" [%g]\n",   (*ub) ());*/
    2929}
     30
     31
     32/// Get lower and upper bound of an expression (if any)
     33void exprQuad::getBounds (CouNumber &lb, CouNumber &ub) {
     34  expression::getBounds (lb, ub);
     35}
     36
    3037
    3138
  • trunk/Couenne/src/expression/operators/exprQuad.cpp

    r1 r61  
    441441
    442442  exprGroup::replace (x, w);
    443   int index = x -> Index ();
     443  int xind = x -> Index ();
     444  int wind = w -> Index ();
    444445
    445446  for (sparseQ::iterator row = matrix_.begin (); row != matrix_.end (); ++row) {
    446447
    447448    exprVar * &vr = row -> first;
    448     if ((vr -> Index () == index)) {
    449 
    450       fprintf (stderr, "Didn't fix exprQuad::replace() yet");
    451       exit (-1);
     449    if ((vr -> Index () == xind)) {
     450
     451      //fprintf (stderr, "Didn't fix exprQuad::replace() yet");
     452      //exit (-1);
    452453      vr = w;
    453454    }
     
    456457
    457458      exprVar * &vc = col -> first;
    458       if ((vc -> Index () == index)) {
    459 
    460         fprintf (stderr, "Didn't fix exprQuad::replace() yet");
    461         exit (-1);
     459      if ((vc -> Index () == wind)) {
     460
     461        //fprintf (stderr, "Didn't fix exprQuad::replace() yet");
     462        //exit (-1);
    462463        vc = w;
    463464      }
     
    479480CouNumber exprQuad::gradientNorm (const double *x) {
    480481
    481   assert (false);
    482   return 0.;
    483 }
     482  CouNumber grad = 0.;
     483
     484  for (sparseQ::iterator row = matrix_.begin (); row != matrix_.end (); ++row) {
     485
     486    CouNumber gradEl = 0.;
     487    for (sparseQcol::iterator col = row -> second.begin (); col != row -> second.end (); ++col)
     488      gradEl += col -> second * x [col -> first -> Index ()];
     489
     490    grad += gradEl * gradEl;
     491  }
     492
     493  return sqrt (grad);
     494}
  • trunk/Couenne/src/expression/operators/exprQuad.hpp

    r1 r61  
    130130  virtual void getBounds (expression *&, expression *&);
    131131
     132  /// Get lower and upper bound of an expression (if any)
     133  virtual void getBounds (CouNumber &, CouNumber &);
     134
    132135  /// Generate cuts for the quadratic expression, which are supporting
    133136  /// hyperplanes of the concave upper envelope and the convex lower
  • trunk/Couenne/src/problem/CouenneProblem.cpp

    r40 r61  
    121121  }
    122122
    123   print ();
    124 
    125123  // link initial variables to problem's domain
    126124  for (std::vector <exprVar *>::iterator i = variables_.begin ();
  • trunk/Couenne/src/problem/problem.cpp

    r39 r61  
    9090
    9191      CouNumber l, u;
     92
    9293      variables_ [ord] -> Image () -> getBounds (l, u);
    9394
     95      /*printf ("printing bounds: [%g %g]\n", Lb (ord), Ub (ord));
     96      variables_ [ord] -> Lb () -> print (); printf ("\n");
     97      variables_ [ord] -> Ub () -> print (); printf ("\n");*/
     98
    9499      Jnlst () -> Printf (Ipopt::J_MOREMATRIX, J_PROBLEM,
    95                           " [ --> w_%04d [%10g,%10g] ]", ord, l, u);
     100                          " [ --> w_%04d [%10g,%10g] ] vs [%10g %10g]",
     101                          ord, l, u, Lb (ord), Ub (ord));
    96102
    97103      // set bounds
  • trunk/doxydoc/doxygen.conf.in

    r58 r61  
    118118WARN_LOGFILE           =
    119119
    120 INPUT                  = @abs_source_dir@/Couenne/src
    121 
    122 FILE_PATTERNS          = *.hpp *.h
     120INPUT                  = @abs_source_dir@/Couenne/src @abs_source_dir@/Couenne/doc
     121
     122FILE_PATTERNS          = *.hpp *.h *.dox
    123123
    124124RECURSIVE              = YES
Note: See TracChangeset for help on using the changeset viewer.