Changeset 485


Ignore:
Timestamp:
Jan 9, 2011 6:25:17 PM (9 years ago)
Author:
pbelotti
Message:

saving minor changes before merging branches/split

Location:
trunk/Couenne/src
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/Couenne/src/crossconv/CouenneCrossConv.hpp

    r412 r485  
    166166
    167167    /// Set up data structure to detect redundancies
    168     void setup (CouenneProblem *p);
     168    void setup ();
    169169
    170170  protected:
  • trunk/Couenne/src/crossconv/CrossConvConstructors.cpp

    r394 r485  
    2121                                    JnlstPtr,
    2222                                    const Ipopt::SmartPtr <Ipopt::OptionsList>) {
    23 
    24   setup (p);
     23  setup ();
    2524}
    2625
  • trunk/Couenne/src/crossconv/CrossConvSetup.cpp

    r394 r485  
    1414
    1515/// the main CglCutGenerator
    16 void CouenneCrossConv::setup (CouenneProblem *p) {
     16void CouenneCrossConv::setup () {
    1717
    1818}
  • trunk/Couenne/src/problem/CouenneProblem.cpp

    r414 r485  
    137137  } else {  // otherwise, just return the entry's pointer
    138138
    139     w->Image(NULL); // otherwise "delete w" will also delete user given expression "symbolic"
     139    w -> Image(NULL); // otherwise "delete w" will also delete user given expression "symbolic"
    140140    delete w;
    141141    w = *i;
  • trunk/Couenne/src/standardize/flattenMul.cpp

    r462 r485  
    136136        indices.insert (std::pair <int, CouNumber> (ind, 1));
    137137      else ++ (where -> second);
    138 
    139138    }
    140139    }
  • trunk/Couenne/src/standardize/linStandardize.cpp

    r414 r485  
    128128  if (jnlst_ -> ProduceOutput (Ipopt::J_ALL, J_REFORMULATE)) {
    129129    printf ("\nlinstand (addaux = %d) ==> ", addAux);
    130     ret -> print (); printf ("\n");
    131     //  ret -> Image () -> print (); printf ("\n");
     130    ret -> print (); printf ("\n");
     131    //printf (": "); fflush (stdout);
     132    //ret -> Image () -> print ();     
    132133  }
    133134
  • trunk/Couenne/src/standardize/splitAux.cpp

    r463 r485  
    1919#include "CouenneExprSum.hpp"
    2020#include "CouenneExprMul.hpp"
     21#include "CouenneExprOpp.hpp"
    2122#include "CouenneExprGroup.hpp"
    2223#include "CouenneLQelems.hpp"
     
    4243
    4344  if (jnlst_ -> ProduceOutput (Ipopt::J_ALL, J_REFORMULATE)) {
    44     printf ("|||||||||| Splitting "); body -> print (); printf ("\n");
     45    printf ("  Splitting expression: "); body -> print (); printf ("\n");
    4546  }
    4647
     
    5960    auxInd = (*alist) -> Index ();
    6061
    61     if (auxInd < 0)
     62    if (auxInd < 0) // first argument is not a variable
    6263      elementBreak (*alist, auxInd, coeff); // check first element
    6364
    64     if ((auxInd < 0) ||
    65         wentAux [auxInd] ||
     65    if ((auxInd < 0) ||       // first argument is not a variable
     66        wentAux [auxInd] ||   // it was, and it already became an auxiliary
    6667        (alist [1] -> dependsOn (auxInd, TAG_AND_RECURSIVE) >= 1)) {
     68                              // it is not an auxiliary, but the remaining
     69                              // expression depends on it
    6770
    6871      auxInd = (alist [1]) -> Index ();
     
    8689    expression *clone = alist [1 - pos] -> clone (&domain_);
    8790
    88     expression *auxdef =
    89       (fabs (coeff - 1) < COUENNE_EPS) ?          // if coefficient is 1
    90       (clone) :                                   //     do nothing
    91       new exprMul (new exprConst (coeff), clone); //     else multiply it by coefficient
    92 
    93     rest = (fabs (rhs) < COUENNE_EPS) ?                              // no extra constant?
     91    expression *auxdef;
     92
     93    if      (coeff ==  1.) auxdef =                                     clone;  // if coefficient is  1, do nothing     
     94    else if (coeff == -1.) auxdef = new exprOpp                        (clone); // if coefficient is -1, return -f(x)
     95    else                   auxdef = new exprMul (new exprConst (coeff), clone); // else multiply it by coefficient
     96
     97    rest = (rhs == 0.) ?                                             // no extra constant?
    9498      (auxdef) :                                                     // just put other argument
    9599      (new exprSum (auxdef, new exprConst ((pos==1) ? -rhs : rhs))); // otherwise sum it with \pm rhs
     
    119123    bool which_was_set = false;
    120124
    121     // check indices of linear part /////////////////////////////////
     125    // check indices of linear/quadratic part /////////////////////////////////
    122126
    123127    if (code != COU_EXPRSUM) {
     
    261265                                                      body -> Copy () :
    262266                                                      body);
     267
    263268      exprGroup::lincoeff &lcoe = egBody -> lcoeff ();
    264269
     
    415420      } else auxDef = new exprSum (newarglist, nargs);
    416421
    417       if (fabs (auxcoe + 1) < COUENNE_EPS)
     422      if (auxcoe == -1.)
    418423        rest = auxDef;
    419       else if ((fabs (auxcoe - 1) < COUENNE_EPS) &&
     424      else if ((auxcoe == 1.) &&
    420425               (auxDef -> code () == COU_EXPROPP))
    421426        rest = auxDef -> Argument ();
     
    435440          }
    436441
     442          // TODO: if it's a c*(ax+b) return new exprGroup with (c*a, c*b)
     443
    437444          rest = new exprMul (new exprConst (-1./auxcoe),
    438445                              ((auxDef -> Type () == AUX) ||
     
    447454
    448455    if (jnlst_ -> ProduceOutput (Ipopt::J_ALL, J_REFORMULATE)) {
    449       printf ("generated "); rest -> print (); printf ("\n");
     456      printf ("  Generated "); rest -> print (); printf ("\n");
    450457    }
    451458
     
    460467
    461468  default: break;
    462   } // end switch () ////////////////////////////////////////////////////////
     469  }
    463470
    464471  if ((auxInd < 0) || (wentAux [auxInd]))
     
    471478
    472479  if (jnlst_ -> ProduceOutput (Ipopt::J_ALL, J_REFORMULATE)) {
    473     printf ("standardize rest (2nd level) "); fflush (stdout);
    474     rest -> print (); printf (" [body = ");
    475     body -> print (); printf ("]");
     480    printf   ("  Standardize rest (2nd level). Rest: "); fflush (stdout); rest -> print ();
     481    printf ("\n                                Body: "); fflush (stdout); body -> print (); printf ("]\n");
    476482  }
    477483
     
    482488
    483489  if (jnlst_ -> ProduceOutput (Ipopt::J_ALL, J_REFORMULATE)) {
    484     printf (" {body = "); body -> print (); printf ("} ");
     490
    485491    if (aux) {
    486       printf (" --- aux = ");
    487       aux -> print ();
    488       printf (" := ");
    489       aux -> Image () -> print ();
     492      printf ("  Aux: "); aux -> print ();
     493      printf (" := ");    aux -> Image () -> print ();
    490494    }
    491495  }
     
    494498    //delete rest;
    495499    //rest = aux -> Image () -> clone (&domain_);
    496     rest = aux -> Image ();// -> clone (&domain_);
     500    rest = aux -> Image (); // -> clone (&domain_);
    497501    aux -> Image (NULL);
    498502    delete aux;
  • trunk/Couenne/src/standardize/standardize.cpp

    r457 r485  
    3030
    3131  if (jnlst_ -> ProduceOutput (J_ALL, J_REFORMULATE)) {
    32     printf ("START: current point: %d vars -------------------\n",
     32    printf ("Reformulation. current point: %d vars -------------------\n",
    3333            domain_.current () -> Dimension ());
    3434    for (int i=0; i<domain_.current () -> Dimension (); i++)
     
    151151
    152152    if (jnlst_ -> ProduceOutput (J_ALL, J_REFORMULATE)) {
    153       printf ("############# problem status now:\n");
    154       print ();
    155       printf ("############# Constraint ");
     153      //printf ("############# problem status now:\n");
     154      //print ();
     155      printf ("\nReformulating constraint: ");
    156156      (*i) -> print ();
    157157    }
     
    204204      // depends on it as it is the lhs of a constraint.
    205205      aux -> top_level () = true;
     206
     207
     208      // this constraint f(x)<=b is therefore replaced by w<=b, where
     209      // w is the top-level auxiliary associated with f(x)
    206210
    207211      //printf ("delete %x: ", ((*i) -> Body ())); ((*i) -> Body ()) -> print ();
Note: See TracChangeset for help on using the changeset viewer.