Changeset 543


Ignore:
Timestamp:
May 20, 2007 9:07:09 PM (12 years ago)
Author:
pbelotti
Message:

changed print methods to create extended formulations. Created extended formulations both with and without auxiliary variables

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

Legend:

Unmodified
Added
Removed
  • branches/Couenne/Couenne/src/convex/CouenneCutGenerator.cpp

    r540 r543  
    6666  //problem_ -> print (std::cout);
    6767  //  printf ("======================================\n");
    68   //  problem_ -> writeMod ("extended.mod");
     68  problem_ -> writeMod ("extended-aw.mod", true);
     69  problem_ -> writeMod ("extended-pb.mod", false);
    6970}
    7071
  • branches/Couenne/Couenne/src/expression/exprAux.cpp

    r537 r543  
    3030  //  image_ -> getBounds (lb_, ub_);
    3131  getBounds (lb_, ub_);
     32}
     33
     34
     35/// I/O
     36void exprAux::print (std::ostream &out, bool descend, CouenneProblem *p) const {
     37
     38  if (descend)
     39    image_ -> print (out, descend, p);
     40  else out << "w_" << varIndex_;
    3241}
    3342
  • branches/Couenne/Couenne/src/expression/exprAux.h

    r534 r543  
    8585
    8686  /// I/O
    87   void print (std::ostream &out) const
    88     {out << "w_" << varIndex_;}
     87  virtual void print (std::ostream & = std::cout, bool = false, CouenneProblem * = NULL) const;
    8988
    9089  /// The expression associated with this auxiliary variable
  • branches/Couenne/Couenne/src/expression/exprBound.h

    r534 r543  
    4343
    4444  /// I/O
    45   void print (std::ostream &out) const
     45  void print (std::ostream &out = std::cout, bool = false, CouenneProblem * = NULL) const
    4646    {out << "l_" << varIndex_;}
    4747
     
    8383
    8484  /// I/O
    85   void print (std::ostream &out) const
     85  void print (std::ostream &out = std::cout, bool = false, CouenneProblem * = NULL) const
    8686    {out << "u_" << varIndex_;}
    8787
  • branches/Couenne/Couenne/src/expression/exprClone.h

    r534 r543  
    3636
    3737  /// I/O
    38   void print (std::ostream &out) const
    39     {copy_ -> Original () -> print (out);}
     38  void print (std::ostream &out = std::cout,
     39              bool descend      = false,
     40              CouenneProblem *p = NULL) const
     41    {copy_ -> Original () -> print (out, descend, p);}
    4042
    4143  /// value
  • branches/Couenne/Couenne/src/expression/exprConst.h

    r534 r543  
    4444
    4545  /// I/O
    46   inline void print (std::ostream &out) const
     46  void print (std::ostream &out = std::cout, bool = false, CouenneProblem * = NULL) const
    4747    {out << currValue_;}
    4848
  • branches/Couenne/Couenne/src/expression/exprCopy.h

    r534 r543  
    5555
    5656  /// I/O
    57   virtual void print (std::ostream &out) const
    58   {out << "["; copy_ -> Original () -> print (out); out << "]";}
     57  virtual void print (std::ostream &out = std::cout,
     58                      bool descend      = false,
     59                      CouenneProblem *p = NULL) const
     60    {copy_ -> Original () -> print (out, descend, p);}
    5961
    6062  /// value (empty)
  • branches/Couenne/Couenne/src/expression/exprIVar.h

    r534 r543  
    4040
    4141  /// print
    42   virtual void print (std::ostream &out) const
     42  virtual void print (std::ostream &out = std::cout, bool = false, CouenneProblem * = NULL) const
    4343    {out << "y_" << varIndex_;}
    4444
  • branches/Couenne/Couenne/src/expression/exprOp.cpp

    r480 r543  
    4242// print expression
    4343
    44 void exprOp::print (std::ostream      &out = std::cout,
     44void exprOp::print (std::ostream &out,
     45                    bool descend,
     46                    CouenneProblem *p) const {
     47 
     48  if (printPos () == PRE)
     49    out << printOp ();
     50
     51  out << "("; fflush (stdout);
     52  for (int i=0; i<nargs_; i++) {
     53    if (arglist_ [i])
     54      arglist_ [i] -> print (out, descend, p);
     55    fflush (stdout);
     56    if (i < nargs_ - 1) {
     57      if (printPos () == INSIDE) out << printOp ();
     58      else                       out << ",";
     59    }
     60    fflush (stdout);
     61  }
     62  out << ")";
     63  fflush (stdout);
     64}
     65
     66/*void exprOp::print (std::ostream      &out = std::cout,
    4567                    const std::string &op  = "unknown",
    4668                    enum pos           pos = PRE)        const
     
    6385  fflush (stdout);
    6486}
    65 
     87*/
    6688
    6789// does this expression depend on variables in varlist?
  • branches/Couenne/Couenne/src/expression/exprOp.h

    r534 r543  
    7070
    7171  /// I/O
    72   virtual void print (std::ostream &, const std::string &, enum pos) const;
     72  virtual void print (std::ostream &out = std::cout, bool = false, CouenneProblem * = NULL) const;
     73  //  virtual void print (std::ostream &out = std::cout, bool = false, CouenneProblem * = NULL) const
     74  //  virtual void print (std::ostream &, const std::string &, enum pos) const;
     75
     76  /// print position (PRE, INSIDE, POST)
     77  virtual enum pos printPos () const
     78    {return INSIDE;}
     79
     80  /// print operator
     81  virtual std::string printOp () const
     82    {return "??";}
    7383
    7484  /// function for the evaluation of the expression
  • branches/Couenne/Couenne/src/expression/exprUnary.cpp

    r480 r543  
    2525// print unary expression
    2626
     27
     28void exprUnary::print (std::ostream &out,
     29                       bool descend,
     30                       CouenneProblem *p) const {
     31
     32  if (printPos () == PRE)  out << printOp ();
     33  out << "(";
     34  argument_ -> print (out, descend, p);
     35  out << ")";
     36  if (printPos () == POST) out << printOp ();
     37}
     38
     39/*
    2740void exprUnary::print (std::ostream      &out = std::cout,
    2841                       const std::string &op  = "unknown",
     
    3548  if (pos == POST) out << op;
    3649}
    37 
     50*/
    3851
    3952/// comparison when looking for duplicates
  • branches/Couenne/Couenne/src/expression/exprUnary.h

    r534 r543  
    6464
    6565  /// I/O
    66   virtual void print (std::ostream &, const std::string &, enum pos) const;
     66  virtual void print (std::ostream &out = std::cout, bool = false, CouenneProblem * = NULL) const;
     67  //  virtual void print (std::ostream &, const std::string &, enum pos) const;
     68
     69  /// print position (PRE, INSIDE, POST)
     70  virtual enum pos printPos () const
     71    {return PRE;}
     72
     73  /// print operator
     74  virtual std::string printOp () const
     75    {return "?";}
    6776
    6877  /// compute value of unary operator
  • branches/Couenne/Couenne/src/expression/exprVar.h

    r534 r543  
    5454
    5555  /// print
    56   virtual void print (std::ostream &out) const
     56  virtual void print (std::ostream &out = std::cout, bool = false, CouenneProblem * = NULL) const
    5757    {out << "x_" << varIndex_;}
    5858
  • branches/Couenne/Couenne/src/expression/expression.h

    r537 r543  
    140140
    141141  /// I/O
    142   virtual void print (std::ostream &s) const {s << '?';}
     142  virtual void print (std::ostream &s = std::cout,    /// output stream
     143                      bool = false,                   /// descend into auxiliaries' image?
     144                      CouenneProblem * = NULL) const  /// problem pointer (in exprGroup)
     145    {s << '?';}
    143146
    144147  /// null function for evaluating the expression
  • branches/Couenne/Couenne/src/expression/operators/exprAbs.cpp

    r441 r543  
    5757/// printing
    5858
    59 void exprAbs::print (std::ostream& out) const {
    60   exprUnary::print (out, "abs", PRE);
     59//void exprAbs::print (std::ostream& out) const {
     60//  exprUnary::print (out, "abs", PRE);
    6161  /*
    6262  out << "|";
     
    6464  out << "|";
    6565  */
    66 }
     66//}
    6767
    6868
  • branches/Couenne/Couenne/src/expression/operators/exprAbs.h

    r537 r543  
    3333    {return new exprAbs (argument_ -> clone ());}
    3434
     35  std::string printOp () const
     36    {return "abs";}
     37
    3538  /// I/O
    36   void print (std::ostream&) const;
     39  //  void print (std::ostream&) const;
    3740
    3841  /// differentiation
  • branches/Couenne/Couenne/src/expression/operators/exprBCos.h

    r534 r543  
    3636  CouNumber operator () ();
    3737
     38  /// print position (PRE, INSIDE, POST)
     39  enum pos printPos () const
     40    {return PRE;}
     41
     42  /// print operator
     43  std::string printOp ()
     44    {return "LB_Cos";}
     45
    3846  // output
    39   void print (std::ostream &out = std::cout)
    40     {exprOp::print (out, "LB_Cos", PRE);}
     47  //  void print (std::ostream &out = std::cout)
     48  //  {exprOp::print (out, "LB_Cos", PRE);}
    4149};
    4250
     
    8189  CouNumber operator () ();
    8290
     91  /// print position (PRE, INSIDE, POST)
     92  virtual enum pos printPos ()
     93    {return PRE;}
     94
     95  /// print operator
     96  virtual const std::string printOp ()
     97    {return "UB_Cos";}
     98
    8399  // output
    84   void print (std::ostream &out = std::cout)
    85     {exprOp::print (out, "UB_Cos", PRE);}
     100  //  void print (std::ostream &out = std::cout)
     101  //  {exprOp::print (out, "UB_Cos", PRE);}
    86102};
    87103
  • branches/Couenne/Couenne/src/expression/operators/exprBDiv.h

    r534 r543  
    4747  CouNumber operator () ();
    4848
     49  /// print position (PRE, INSIDE, POST)
     50  enum pos printPos () const
     51    {return PRE;}
     52
     53  /// print operator
     54  std::string printOp () const
     55    {return "LB_Div";}
     56
    4957  /// I/O
    50   void print (std::ostream &) const;
     58  //  void print (std::ostream &) const;
    5159};
    5260
    5361
    5462/// output
    55 inline void exprLBDiv::print (std::ostream &out = std::cout) const
    56 {exprOp::print (out, "LB_div", PRE);}
     63//inline void exprLBDiv::print (std::ostream &out = std::cout) const
     64//{exprOp::print (out, "LB_div", PRE);}
    5765
    5866
     
    94102  CouNumber operator () ();
    95103
     104  /// print position (PRE, INSIDE, POST)
     105  enum pos printPos () const
     106    {return PRE;}
     107
     108  /// print operator
     109  std::string printOp () const
     110    {return "UB_Div";}
     111
    96112  /// output
    97   void print (std::ostream &) const;
     113  //  void print (std::ostream &) const;
    98114};
    99115
     
    119135
    120136/// output
    121 void exprUBDiv::print (std::ostream &out = std::cout) const
    122 {exprOp::print (out, "UB_div", PRE);}
     137//void exprUBDiv::print (std::ostream &out = std::cout) const
     138//{exprOp::print (out, "UB_div", PRE);}
    123139
    124140#endif
  • branches/Couenne/Couenne/src/expression/operators/exprBMul.h

    r537 r543  
    4040  CouNumber operator () ();
    4141
     42  /// print position (PRE, INSIDE, POST)
     43  enum pos printPos () const
     44    {return PRE;}
     45
     46  /// print operator
     47  std::string printOp () const
     48    {return "LB_Mul";}
    4249  // output
    43   void print (std::ostream &) const;
     50  //  void print (std::ostream &) const;
    4451};
    4552
     
    7178
    7279// output
    73 inline void exprLBMul::print (std::ostream &out = std::cout) const
    74 {exprOp::print (out, "LB_mul", PRE);}
     80//inline void exprLBMul::print (std::ostream &out = std::cout) const
     81//{exprOp::print (out, "LB_mul", PRE);}
    7582
    7683
     
    93100  CouNumber operator () ();
    94101
     102  /// print position (PRE, INSIDE, POST)
     103  virtual enum pos printPos ()
     104    {return PRE;}
     105
     106  /// print operator
     107  virtual const std::string printOp ()
     108    {return "UB_Mul";}
     109
    95110  // output
    96   void print (std::ostream &) const;
     111  //  void print (std::ostream &) const;
    97112};
    98113
     
    135150// output
    136151
    137 void exprUBMul::print (std::ostream &out = std::cout) const
    138 {exprOp::print (out, "UB_mul", PRE);}
     152//void exprUBMul::print (std::ostream &out = std::cout) const
     153//{exprOp::print (out, "UB_mul", PRE);}
    139154
    140155#endif
  • branches/Couenne/Couenne/src/expression/operators/exprBSin.h

    r534 r543  
    3636  CouNumber operator () ();
    3737
     38  /// print operator
     39  std::string printOp () const
     40    {return "LB_Sin";}
     41
     42  /// print position
     43  enum pos printPos () const
     44    {return PRE;}
     45
    3846  // output
    39   void print (std::ostream &out = std::cout)
    40     {exprOp::print (out, "LB_Sin", PRE);}
     47  //  void print (std::ostream &out = std::cout)
     48  //    {exprOp::print (out, "LB_Sin", PRE);}
    4149};
    4250
     
    8290  CouNumber operator () ();
    8391
     92  /// print operator
     93  std::string printOp () const
     94    {return "UB_Sin";}
     95
     96  /// print position
     97  enum pos printPos () const
     98    {return PRE;}
     99
    84100  // output
    85   void print (std::ostream &out = std::cout)
    86     {exprOp::print (out, "UB_Sin", PRE);}
     101  //  void print (std::ostream &out = std::cout)
     102  //    {exprOp::print (out, "UB_Sin", PRE);}
    87103};
    88104
  • branches/Couenne/Couenne/src/expression/operators/exprCos.cpp

    r521 r543  
    2929
    3030// I/O
    31 void exprCos::print (std::ostream& out) const
    32   {exprUnary::print (out, "cos", PRE);}
     31//void exprCos::print (std::ostream& out) const
     32//  {exprUnary::print (out, "cos", PRE);}
    3333
    3434// compute bounds of sin x given bounds of x
  • branches/Couenne/Couenne/src/expression/operators/exprCos.h

    r534 r543  
    3434  inline unary_function F () {return cos;}
    3535
     36  /// print operator
     37  std::string printOp () const
     38    {return "cos";}
     39
     40  /// print position
     41  //  virtual const std::string printPos ()
     42  //    {return PRE;}
     43
     44
    3645  /// print "cos" and argument
    37   void print (std::ostream&) const;
     46  //  void print (std::ostream&) const;
    3847
    3948  /// obtain derivative of expression
  • branches/Couenne/Couenne/src/expression/operators/exprDiv.cpp

    r405 r543  
    9595// output
    9696
    97 void exprDiv::print (std::ostream& out) const
    98   {exprOp::print (out, "/", INSIDE);}
     97//void exprDiv::print (std::ostream& out) const
     98//  {exprOp::print (out, "/", INSIDE);}
    9999
    100100
  • branches/Couenne/Couenne/src/expression/operators/exprDiv.h

    r537 r543  
    3131    {return new exprDiv (clonearglist (), nargs_);}
    3232
     33  /// print operator
     34  std::string printOp () const
     35    {return "/";}
     36
     37  /// print position
     38  //  virtual enum pos printPos ()
     39  //    {return INSIDE;}
     40
    3341  // I/O
    34   void print (std::ostream&) const;
     42  //  void print (std::ostream&) const;
    3543
    3644  // function for the evaluation of the expression
  • branches/Couenne/Couenne/src/expression/operators/exprExp.cpp

    r441 r543  
    2727// printing
    2828
    29 void exprExp::print (std::ostream& out) const
    30   {exprUnary::print (out, "exp", PRE);}
     29//void exprExp::print (std::ostream& out) const
     30//  {exprUnary::print (out, "exp", PRE);}
    3131
    3232
  • branches/Couenne/Couenne/src/expression/operators/exprExp.h

    r537 r543  
    3030  inline unary_function F () {return exp;}
    3131
     32  /// print operator
     33  std::string printOp () const
     34    {return "exp";}
     35
     36  /// print position
     37  //  virtual const std::string printPos ()
     38  //    {return PRE;}
     39
     40
    3241  // output
    33   void print (std::ostream&) const;
     42  //  void print (std::ostream&) const;
    3443
    3544  // differentiation
  • branches/Couenne/Couenne/src/expression/operators/exprGroup.cpp

    r467 r543  
    6565
    6666/// I/O
    67 void exprGroup::print (std::ostream &out) const {
    68 
    69   exprSum::print (out);
     67void exprGroup::print (std::ostream &out, bool descend, CouenneProblem *p) const {
     68//void exprGroup::print (std::ostream &out, CouenneProblem *p = NULL) const {
     69
     70  if (nargs_ && ((nargs_ > 1) ||
     71                 ((*arglist_) -> Type () != CONST) ||
     72                 (fabs ((*arglist_) -> Value ()) > COUENNE_EPS)))
     73    exprSum::print (out, descend, p);
     74
     75  int nOrig = p ? (p -> nVars ()) : -1;
    7076
    7177  if      (c0_ >   COUENNE_EPS) out << '+' << c0_;
    7278  else if (c0_ < - COUENNE_EPS) out        << c0_;
    7379
    74   for (register int *ind=index_, i=0; *ind>=0;) {
     80  for (register int *ind=index_, i=0; *ind>=0; ind++) {
    7581
    7682    CouNumber coeff = coeff_ [i++];
     
    7884    out << ' ';
    7985
    80     if      (coeff >   COUENNE_EPS) out << '+' << coeff;
    81     else if (coeff < - COUENNE_EPS) out        << coeff;
    82 
    83     out << " x_" << *ind++;
     86    if      (coeff >   COUENNE_EPS) out << '+' << coeff << "*";
     87    else if (coeff < - COUENNE_EPS) out        << coeff << "*";
     88    else continue;
     89
     90    if (nOrig < 0) out << "x_" << *ind;
     91    else {
     92      //      out << "(";
     93      if (*ind < nOrig) p -> Var (*ind)       -> print (out, descend, p);
     94      else              p -> Aux (*ind-nOrig) -> print (out, descend, p);
     95      //      out << ")";
     96    }
    8497  }
    8598}
  • branches/Couenne/Couenne/src/expression/operators/exprGroup.h

    r534 r543  
    5050
    5151  /// I/O
    52   virtual void print (std::ostream &) const;
     52  //  virtual void print (std::ostream &, CouenneProblem *) const;
     53  virtual void print (std::ostream & = std::cout, bool = false, CouenneProblem * = NULL) const;
    5354
    5455  /// function for the evaluation of the expression
  • branches/Couenne/Couenne/src/expression/operators/exprInv.cpp

    r403 r543  
    2929// printing
    3030
    31 void exprInv::print (std::ostream& out) const
    32 {exprUnary::print (out, "1/", PRE);}
     31void exprInv::print (std::ostream &out,
     32                     bool descend,
     33                     CouenneProblem *p) const {
     34//void exprInv::print (std::ostream& out) const
     35  out << "(1/(";
     36  argument_ -> print (out, descend, p);
     37  out << ")";
     38}
     39//  exprUnary::print (out, "1/", PRE);}
    3340
    3441
  • branches/Couenne/Couenne/src/expression/operators/exprInv.h

    r537 r543  
    4545
    4646  /// output "1/argument"
    47   void print (std::ostream&) const;
     47  virtual void print (std::ostream &out = std::cout, bool = false, CouenneProblem * = NULL) const;
     48  //  void print (std::ostream&) const;
    4849
    4950  /// differentiation
  • branches/Couenne/Couenne/src/expression/operators/exprLog.cpp

    r525 r543  
    6363/// printing
    6464
    65 void exprLog::print (std::ostream& out) const
    66 {exprUnary::print (out, "log", PRE);}
     65//void exprLog::print (std::ostream& out) const
     66//{exprUnary::print (out, "log", PRE);}
    6767
    6868
  • branches/Couenne/Couenne/src/expression/operators/exprLog.h

    r537 r543  
    3232  inline unary_function F () {return log;}
    3333
     34  /// print operator
     35  std::string printOp () const
     36    {return "log";}
     37
     38  /// print position
     39  //virtual const std::string printPos ()
     40  //{return PRE;}
     41
     42
    3443  // I/O
    35   void print (std::ostream&) const;
     44  //  void print (std::ostream&) const;
    3645
    3746  // differentiation
  • branches/Couenne/Couenne/src/expression/operators/exprMax.h

    r534 r543  
    3434    {return new exprMax (clonearglist (), nargs_);}
    3535
     36  /// print operator
     37  std::string printOp () const
     38    {return "max";}
     39
     40  /// print position
     41  enum pos printPos () const
     42    {return PRE;}
     43
    3644  // I/O
    37   void print (std::ostream &out) const
    38     {exprOp:: print (out, "max", PRE);}
     45  //  void print (std::ostream &out) const
     46  //    {exprOp:: print (out, "max", PRE);}
    3947
    4048  // function for the evaluation of the expression
  • branches/Couenne/Couenne/src/expression/operators/exprMin.h

    r534 r543  
    3333    {return new exprMin (clonearglist (), nargs_);}
    3434
     35  /// print operator
     36  std::string printOp () const
     37    {return "min";}
     38
     39  /// print operator
     40  enum pos printPos () const
     41    {return PRE;}
     42
    3543  /// I/O
    36   void print (std::ostream &out) const
    37     {exprOp:: print (out, "min", PRE);}
     44  //  void print (std::ostream &out) const
     45  //    {exprOp:: print (out, "min", PRE);}
    3846
    3947  /// function for the evaluation of the expression
  • branches/Couenne/Couenne/src/expression/operators/exprMul.cpp

    r524 r543  
    128128
    129129/// print
    130 void exprMul::print (std::ostream& out) const
    131   {exprOp::print (out, "*", INSIDE);}
     130//void exprMul::print (std::ostream& out) const
     131//  {exprOp::print (out, "*", INSIDE);}
    132132
    133133
  • branches/Couenne/Couenne/src/expression/operators/exprMul.h

    r537 r543  
    2929    {return new exprMul (clonearglist (), nargs_);}
    3030
     31  /// print operator
     32  std::string printOp () const
     33    {return "*";}
     34
    3135  /// print expression
    32   void print (std::ostream&) const;
     36  //  void print (std::ostream&) const;
    3337
    3438  /// function for the evaluation of the expression
  • branches/Couenne/Couenne/src/expression/operators/exprOpp.cpp

    r400 r543  
    3030// printing
    3131
    32 void exprOpp::print (std::ostream& out) const
    33 {exprUnary::print (out, "-", PRE);}
     32//void exprOpp::print (std::ostream& out) const
     33//{exprUnary::print (out, "-", PRE);}
    3434
    3535
  • branches/Couenne/Couenne/src/expression/operators/exprOpp.h

    r534 r543  
    3636  inline unary_function F () {return opp;}
    3737
     38  /// print operator
     39  std::string printOp () const
     40    {return "-";}
     41
    3842  // I/O
    39   void print (std::ostream&) const;
     43  //  void print (std::ostream&) const;
    4044
    4145  // differentiation
  • branches/Couenne/Couenne/src/expression/operators/exprPow.cpp

    r525 r543  
    100100/// output
    101101
    102 void exprPow::print (std::ostream& out) const
    103   {exprOp::print (out, "^", INSIDE);}
     102//void exprPow::print (std::ostream& out) const
     103//  {exprOp::print (out, "^", INSIDE);}
    104104
    105105
  • branches/Couenne/Couenne/src/expression/operators/exprPow.h

    r537 r543  
    3535    {return new exprPow (clonearglist (), nargs_);}
    3636
     37  /// print operator
     38  std::string printOp () const
     39    {return "^";}
     40
    3741  // I/O
    38   void print (std::ostream&) const;
     42  //  void print (std::ostream&) const;
    3943
    4044  // function for the evaluation of the expression
  • branches/Couenne/Couenne/src/expression/operators/exprSin.cpp

    r521 r543  
    2929// printing
    3030
    31 void exprSin::print (std::ostream& out) const {
    32   exprUnary::print (out, "sin", PRE);
    33 }
     31//void exprSin::print (std::ostream& out) const {
     32//  exprUnary::print (out, "sin", PRE);
     33//}
    3434
    3535
  • branches/Couenne/Couenne/src/expression/operators/exprSin.h

    r534 r543  
    3737  inline unary_function F () {return sin;}
    3838
     39  /// print operator
     40  std::string printOp () const
     41    {return "sin";}
     42
    3943  /// I/O
    40   void print (std::ostream&) const;
     44  //  void print (std::ostream&) const;
    4145
    4246  /// differentiation
  • branches/Couenne/Couenne/src/expression/operators/exprSub.cpp

    r525 r543  
    7171
    7272// print
    73 void exprSub::print (std::ostream& out) const
    74   {exprOp::print (out, "-", INSIDE);}
     73//void exprSub::print (std::ostream& out) const
     74//  {exprOp::print (out, "-", INSIDE);}
    7575
    7676
  • branches/Couenne/Couenne/src/expression/operators/exprSub.h

    r534 r543  
    3131    {return new exprSub (clonearglist (), nargs_);}
    3232
     33  /// print operator
     34  std::string printOp () const
     35    {return "-";}
     36
     37
    3338  // I/O
    34   void print (std::ostream&) const;
     39  //  void print (std::ostream&) const;
    3540
    3641  // function for the evaluation of the expression
  • branches/Couenne/Couenne/src/expression/operators/exprSum.cpp

    r450 r543  
    9999/// print
    100100
    101 void exprSum::print (std::ostream& out) const
    102   {exprOp::print (out, "+", INSIDE);}
     101//void exprSum::print (std::ostream& out) const
     102//  {exprOp::print (out, "+", INSIDE);}
    103103
    104104
  • branches/Couenne/Couenne/src/expression/operators/exprSum.h

    r534 r543  
    2929    {return new exprSum (clonearglist (), nargs_);}
    3030
     31  /// print operator
     32  std::string printOp () const
     33    {return "+";}
     34
    3135  /// I/O
    32   virtual void print (std::ostream &) const;
     36  //  virtual void print (std::ostream &) const;
    3337
    3438  /// function for the evaluation of the expression
  • branches/Couenne/Couenne/src/problem/CouenneProblem.h

    r534 r543  
    127127  /// store nonlinear problem into a .mod file (with lots of defined
    128128  /// variables)
    129   void writeMod (char *);
     129  ///
     130  /// @aux controls the use of auxiliaries. If true, a problem is
     131  /// written with auxiliary variables written with their associated
     132  /// expression, i.e. w_i = h_i(x,y,w) and bounds l_i <= w_i <= u_i,
     133  /// while if false these constraints are written in the form l_i <=
     134  /// h_i (x,y) <= u_i
     135  ///
     136  void writeMod (char *filename,  /// Name of the .mod file to be written
     137                 bool  aux);      /// true: with aux, false: without.
    130138
    131139  /// initialize auxiliary variables and their bounds from original
  • branches/Couenne/Couenne/src/problem/problemIO.cpp

    r542 r543  
    1414#include <expression.h>
    1515#include <exprConst.h>
     16#include <exprGroup.h>
    1617#include <exprAux.h>
    1718
     
    4041    out << " [" << (*i) -> rank (NULL)
    4142        << ","  << (*i) -> Multiplicity () << "] := ";
    42     (*i) -> Image () -> print (out);
     43    (*i) -> Image () -> print (out, false, this);
    4344    out << " [ " << (*((*i) -> Lb ())) (); //-> print (out);
    4445    out << " , " << (*((*i) -> Ub ())) (); //-> print (out);
     
    5253
    5354void CouenneProblem::writeMod (char *fname,  /// name of the mod file
    54                                bool aux) {   ///
     55                               bool aux) {   /// with or without auxiliaries?
    5556
    5657  std::ofstream f (fname);
     
    8283    for (std::vector <exprAux *>::iterator i = auxiliaries_.begin ();
    8384         i != auxiliaries_.end ();
    84          i++) {
     85         i++)
    8586
    86       f << "var "; (*i) -> print (f);
    87       //    f << " = ";  (*i) -> Image () -> print (f);
    88       CouNumber bound;
     87      if ((*i) -> Multiplicity () > 0) {
    8988
    90       if ((bound = (*((*i) -> Lb ())) ()) > - COUENNE_INFINITY) f << " >= " << bound;
    91       if ((bound = (*((*i) -> Ub ())) ()) <   COUENNE_INFINITY) f << " <= " << bound;
    92       if ((*i) -> isInteger ()) f << " integer";
    93       f << ';' << std::endl;
    94     }
     89        f << "var "; (*i) -> print (f, false, this);
     90        //    f << " = ";  (*i) -> Image () -> print (f);
     91        CouNumber bound;
     92
     93        if ((bound = (*((*i) -> Lb ())) ()) > - COUENNE_INFINITY) f << " >= " << bound;
     94        if ((bound = (*((*i) -> Ub ())) ()) <   COUENNE_INFINITY) f << " <= " << bound;
     95        if ((*i) -> isInteger ()) f << " integer";
     96        f << ';' << std::endl;
     97      }
    9598  }
    9699
     
    103106  else                                         f << "maximize";
    104107
    105   f << " obj: ";  objectives_ [0] -> Body () -> print (f); f << ';' << std::endl;
     108  f << " obj: "; 
     109  objectives_ [0] -> Body () -> print (f, !aux, this);
     110  f << ';' << std::endl;
    106111
    107112
    108113  // defined (aux) variables, with formula ///////////////////////////////////////////
    109114
    110   f << std::endl << "# aux. variables defined" << std::endl << std::endl;
     115  if (aux) {
     116    f << std::endl << "# aux. variables defined" << std::endl << std::endl;
    111117
    112   for (int i=0; i < nAuxs (); i++) {
     118    for (int i=0; i < nAuxs (); i++)
     119      if (auxiliaries_ [i] -> Multiplicity () > 0) {
    113120
    114     f << "aux" << i << ": "; auxiliaries_ [i] -> print (f);
    115     f << " = ";  auxiliaries_ [i] -> Image () -> print (f);
    116     f << ';' << std::endl;
     121        f << "aux" << i << ": "; auxiliaries_ [i] -> print (f, false, this);
     122        f << " = "; 
     123
     124        //      if (auxiliaries_ [i] -> Image () -> code () == COU_EXPRGROUP)
     125          //      dynamic_cast <exprGroup *> (auxiliaries_ [i] -> Image ()) -> print (f, this);
     126          //    else
     127        auxiliaries_ [i] -> Image () -> print (f, false, this);
     128        f << ';' << std::endl;
     129      }
    117130  }
    118131
     
    121134
    122135  f << std::endl << "# constraints" << std::endl << std::endl;
     136
     137  if (!aux) // print h_i(x,y) <= ub, >= lb
     138    for (std::vector <exprAux *>::iterator i = auxiliaries_.begin ();
     139         i != auxiliaries_.end ();
     140         i++)
     141
     142      if ((*i) -> Multiplicity () > 0) {
     143       
     144        //      f << "conAux"; (*i) -> print (f);
     145        //    f << " = ";  (*i) -> Image () -> print (f);
     146        CouNumber bound;
     147
     148        if ((bound = (*((*i) -> Lb ())) ()) > - COUENNE_INFINITY) {
     149          f << "conAuxLb" << (*i) -> Index () << ": ";
     150          (*i) -> print (f, true, this);
     151          f << ">= " << bound << ';' << std::endl;
     152        }
     153
     154        if ((bound = (*((*i) -> Ub ())) ()) <   COUENNE_INFINITY) {
     155          f << "conAuxUb" << (*i) -> Index () << ": ";
     156          (*i) -> print (f, true, this);
     157          f << "<= " << bound << ';' << std::endl;
     158        }
     159
     160        //      if ((bound = (*((*i) -> Ub ())) ()) <   COUENNE_INFINITY) f << " <= " << bound;
     161        //      if ((*i) -> isInteger ()) f << " integer";
     162        //      f << ';' << std::endl;
     163      }
     164
    123165
    124166  for (int i=0; i < nNLCons (); i++) {
     
    129171
    130172    f << "con" << i << ": ";
    131     constraints_ [i] -> Body () -> print (f);
     173    constraints_ [i] -> Body () -> print (f, !aux, this);
    132174
    133175    if (lb > - COUENNE_INFINITY + 1) {
     
    146188
    147189      f << "con" << i << "_rng: ";
    148       constraints_ [i] -> Body () -> print (f);
     190      constraints_ [i] -> Body () -> print (f, !aux, this);
    149191      f << " <= " << ub << ';' << std::endl;
    150192    }
Note: See TracChangeset for help on using the changeset viewer.