Changeset 610


Ignore:
Timestamp:
Jun 7, 2011 3:19:42 PM (9 years ago)
Author:
pbelotti
Message:

faster division differentiation. set sb option to true. checking CouenneTNLP for use in FP

Location:
trunk/Couenne/src
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/Couenne/src/expression/operators/exprDiv.cpp

    r560 r610  
    1 /* $Id$ */
    2 /*
     1/* $Id$
     2 *
    33 * Name:    exprDiv.cpp
    44 * Author:  Pietro Belotti
    55 * Purpose: definition of divisions
    66 *
    7  * (C) Carnegie-Mellon University, 2006-08.
     7 * (C) Carnegie-Mellon University, 2006-11.
    88 * This file is licensed under the Eclipse Public License (EPL)
    99 */
     
    1515#include "CouenneExprClone.hpp"
    1616#include "CouenneExprMul.hpp"
     17#include "CouenneExprPow.hpp"
    1718#include "CouenneExprInv.hpp"
    1819#include "CouenneExprSub.hpp"
     
    8990    return new exprConst (0.);
    9091
    91   expression **alm2 = new expression * [3];
    92 
    93   exprInv *invg = new exprInv (arglist_ [1] -> clone ());
    94 
    95   alm2 [0] = arglist_ [0] -> clone ();
    96   alm2 [1] = arglist_ [1] -> differentiate (index);
    97   alm2 [2] = new exprClone (invg);
    98 
    99   return new exprMul (invg, new exprSub (arglist_ [0] -> differentiate (index),
    100                                          new exprMul (alm2, 3)));
     92  // expression **alm2 = new expression * [3];
     93
     94  // exprInv *invg = new exprInv (arglist_ [1] -> clone ());
     95
     96  // alm2 [0] = arglist_ [0] -> clone ();
     97  // alm2 [1] = arglist_ [1] -> differentiate (index);
     98  // alm2 [2] = new exprClone (invg);
     99
     100  // return new exprMul (invg, new exprSub (arglist_ [0] -> differentiate (index),
     101  //                                     new exprMul (alm2, 3)));
     102
     103  // in alternative:
     104
     105  return new exprDiv (new exprSub (new exprMul (arglist_ [1] -> differentiate (index),
     106                                                arglist_ [0] -> clone ()),
     107                                   new exprMul (arglist_ [1] -> clone (),
     108                                                arglist_ [0] -> differentiate (index))),
     109                      new exprPow (arglist_ [1] -> clone (), new exprConst (2.)));
    101110}
    102111
  • trunk/Couenne/src/expression/partial/CouenneExprHess.cpp

    r490 r610  
    1919using namespace Couenne;
    2020
    21 //#define DEBUG
     21#define DEBUG
    2222
    2323ExprHess::ExprHess ():
  • trunk/Couenne/src/expression/partial/CouenneExprHess.hpp

    r490 r610  
    1616  class CouenneProblem;
    1717
    18   /// expression matrices
     18  /// expression matrices. Used to evaluate the Hessian of the
     19  /// Lagrangian function at an optimal solution of the NLP
     20
    1921  class ExprHess {
    2022
    2123  private:
    2224
    23     int           nnz_;  ///< number of (symbolic) nonzeroes
    24     int          *iRow_; ///< col indices
    25     int          *jCol_; ///< row starts
     25    int   nnz_;  ///< number of (symbolic) nonzeroes
     26    int  *iRow_; ///< col indices
     27    int  *jCol_; ///< row starts
    2628
    27     /// there are m+1 (m constraints + 1 obj).
     29    /// There are m+1 (m constraints + 1 obj).
    2830    ///
    2931    /// Implementing a FP requires adding one for gg', the gradient
     
    3840    /// with sum (objective, norm, gg')
    3941
    40     int          *numL_; ///< size of each lamI_
     42    int  *numL_; ///< size of each lamI_
    4143
    42     int         **lamI_; ///< vector of indices in the lambda vector
    43                         ///< whose constraint has nonzero entry in
    44                         ///< this position of the hessian
     44    int **lamI_; ///< vector of indices in the lambda vector
     45                ///< whose constraint has nonzero entry in
     46                ///< this position of the hessian
    4547
    4648    expression ***expr_; ///< list of lists of pointers to expression
  • trunk/Couenne/src/expression/partial/CouenneExprJac.cpp

    r490 r610  
    1717using namespace Couenne;
    1818
    19 //#define DEBUG
     19#define DEBUG
    2020
    2121ExprJac::ExprJac ():
     
    6363  nRows_ (0) {
    6464
     65#ifdef DEBUG
     66  printf ("domain %x, x array: %x\n",
     67          p -> domain (), p -> domain () -> x ());
     68#endif
     69
    6570  /// constraints:
    6671  ///
    67   /// If they are of the form a <= x <= b, they should be ignored and
    68   /// be replaced by variable bound (simply ask the problem)
     72  /// If they are variable constraints, i.e., of the form a <= x <= b,
     73  /// they should be ignored and be replaced by variable bound (simply
     74  /// ask the problem).
    6975  ///
    7076  /// All other constraints should be part of the jacobian
     
    146152      continue;
    147153
    148     // this is a variable definition of the form y = f(x). Find out
    149     // the variables (original or aux) it depends on, directly
     154    printf ("domain of this variable: %x\n", e -> domain ());
     155
     156    // this is a variable definition of the form y </>/= f(x). Find
     157    // out the variables (original or aux) it depends on, directly
    150158    // (STOP_AT_AUX)
    151159
  • trunk/Couenne/src/expression/partial/CouenneExprJac.hpp

    r490 r610  
    1616  class CouenneProblem;
    1717
    18   /// expression Jacobian
     18  /// Jacobian of the problem (computed through Couenne expression
     19  /// classes).
     20
    1921  class ExprJac {
    2022
  • trunk/Couenne/src/heuristics/CouenneFPSolveNLP.cpp

    r609 r610  
    6666                                 false);
    6767
    68   printf ("FP: created TNLP\n");
     68  printf ("FP: created TNLP on problem (domain: %x):\n", problem_ -> domain ());
     69  problem_ -> print ();
    6970
    7071  // set new objective
     
    8283
    8384  SmartPtr <IpoptApplication> app = IpoptApplicationFactory ();
    84 
    8585  ApplicationReturnStatus status = app -> Initialize ();
    8686
     
    102102
    103103  if (nlp_ -> getSolution ()) // check if non-NULL
    104     nSol = CoinCopyOfArray (nlp_ -> getSolution (), problem_ -> nVars ());
     104    nSol = CoinCopyOfArray (nlp_ -> getSolution (),
     105                            problem_ -> nVars ());
    105106
    106107  // integer solution with nlp cuts
  • trunk/Couenne/src/interfaces/CouenneTNLP.cpp

    r560 r610  
    7777    exprVar *e = problem_ -> Var (i);
    7878
    79     if ((e -> Type         () != AUX) ||
    80         (e -> Multiplicity () <= 0)  ||
    81         (e -> Linearity    () <= LINEAR))
     79    if ((e -> Type         () != AUX)    ||
     80        (e -> Linearity    () <= LINEAR) ||
     81        (e -> Multiplicity () <= 0))
    8282      continue;
    8383
     
    313313                                        // don't know when to pop
    314314
     315  //problem_ -> domain () -> push (n, x, NULL, NULL);
     316
     317  printf ("Domain: %x\n", problem_ -> domain ());
     318
    315319  if (values == NULL &&
    316320      iRow   != NULL &&
     
    330334    printf ("filling in jacobian values:\n");
    331335
    332     expression **e = Jac_. expr ();
    333 
    334     for (int i=0; i<nele_jac; i++) {
     336    register expression **e = Jac_. expr ();
     337
     338    for (register int i=0; i<nele_jac; i++) {
    335339      printf ("%d: ", i); fflush (stdout);
    336       (*e) -> print ();
    337       printf ("\n");
     340      if (*e)
     341        (*e) -> print ();
     342      fflush (stdout);
     343      const exprVar *var = dynamic_cast <const exprVar *> ((*e) -> Original ());
     344      if (var)
     345        printf (" [addr %x]", var);
     346      printf ("..\n");
    338347      *values++ = (**(e++)) ();
    339348    }
    340349  }
     350
     351  //problem_ -> domain () -> pop ();
    341352
    342353  return true;
  • trunk/Couenne/src/interfaces/CouenneTNLP.hpp

    r490 r610  
    159159    virtual Index get_number_of_nonlinear_variables ();
    160160
    161 
    162161    /// get real list
    163162    virtual bool get_list_of_nonlinear_variables (Index num_nonlin_vars,
  • trunk/Couenne/src/main/BonCouenne.cpp

    r588 r610  
    5454#include "CoinSignal.hpp"
    5555
     56#if 0
    5657extern "C" {
    5758
     
    6667  }
    6768}
     69#endif
    6870
    6971//#define FM_FRES
     
    115117
    116118    CouenneSetup couenne;
     119
    117120    if (!couenne.InitializeCouenne (argv, p, NULL, ci, &bb))
    118121      throw infeasible;
  • trunk/Couenne/src/main/BonCouenneSetup.cpp

    r607 r610  
    105105  readOptionsFile();
    106106 
     107  // Suppress iteration output from nonlinear solver
     108  options () -> SetStringValue ("sb", "yes", false, true);
     109
    107110  // in check mode, avoid pop-up error message (there are quite a few messages)
    108111  options_ -> GetStringValue ("test_mode", s, "couenne.");
Note: See TracChangeset for help on using the changeset viewer.