Couenne  0.5.7
CouenneExprUnary.hpp
Go to the documentation of this file.
1 /* $Id: CouenneExprUnary.hpp 1147 2015-05-04 14:01:51Z stefan $
2  *
3  * Name: exprUnary.hpp
4  * Author: Pietro Belotti
5  * Purpose: definition of the class for univariate functions
6  *
7  * (C) Carnegie-Mellon University, 2006-08.
8  * This file is licensed under the Eclipse Public License (EPL)
9  */
10 
11 #ifndef COUENNE_EXPRUNARY_HPP
12 #define COUENNE_EXPRUNARY_HPP
13 
14 #include <iostream>
15 
16 #include "CouenneExpression.hpp"
17 #include "CouenneTypes.hpp"
18 
19 namespace Couenne {
20 
23 {return 0.;}
24 
25 
32 
33 class exprUnary: public expression {
34 
35  protected:
36 
39 
40  public:
41 
43  virtual inline enum nodeType Type () const
44  {return UNARY;}
45 
47  exprUnary (expression *argument):
48  argument_ (argument) //< non-leaf expression, with argument list
49  {}
50 
52  virtual inline unary_function F ()
53  {return zero_fun;}
54 
56  virtual ~exprUnary ()
57  {if (argument_) delete argument_;}
58 
60  inline int nArgs () const
61  {return 1;}
62 
64  virtual inline expression *Argument () const
65  {return argument_;}
66 
68  virtual inline expression **ArgPtr ()
69  {return &argument_;}
70 
72  virtual void print (std::ostream &out = std::cout, bool = false) const;
73 
75  virtual enum pos printPos () const
76  {return PRE;}
77 
79  virtual std::string printOp () const
80  {return "?";}
81 
83  virtual inline CouNumber operator () ()
84  {return (F ()) ((*argument_) ());}
85 
88  virtual inline int DepList (std::set <int> &deplist, enum dig_type type = ORIG_ONLY)
89  {return argument_ -> DepList (deplist, type);}
90 
92  expression *simplify ();
93 
96  virtual inline int Linearity ()
97  {return NONLINEAR;}
98 
101  virtual exprAux *standardize (CouenneProblem *, bool addAux = true);
102 
104  virtual inline enum expr_type code ()
105  {return COU_EXPRUNARY;}
106 
108  virtual bool isInteger ();
109 
111  virtual int compare (exprUnary &);
112 
114  virtual inline int rank ()
115  {return (argument_ -> rank ());}
116 
118  virtual inline void fillDepSet (std::set <DepNode *, compNode> *dep, DepGraph *g)
119  {argument_ -> fillDepSet (dep, g);}
120 
122  virtual void replace (exprVar *, exprVar *);
123 
125  virtual inline void realign (const CouenneProblem *p)
126  {argument_ -> realign (p);}
127 };
128 
129 }
130 
131 #endif
virtual expression * Argument() const
return argument
variable-type operator
int nArgs() const
return number of arguments
pos
position where the operator should be printed when printing the expression
virtual int rank()
used in rank-based branching variable choice
expr_type
code returned by the method expression::code()
CouNumber(* unary_function)(CouNumber)
unary function, used in all exprUnary
virtual enum nodeType Type() const
node type
virtual exprAux * standardize(CouenneProblem *, bool addAux=true)
reduce expression in standard form, creating additional aux variables (and constraints)
Number Number * g
exprUnary(expression *argument)
Constructor.
expression * simplify()
simplification
CouNumber zero_fun(CouNumber x)
zero function (used by default by exprUnary)
virtual enum pos printPos() const
print position (PRE, INSIDE, POST)
virtual int DepList(std::set< int > &deplist, enum dig_type type=ORIG_ONLY)
fill in the set with all indices of variables appearing in the expression
double CouNumber
main number type in Couenne
expression class for unary functions (sin, log, etc.)
virtual CouNumber operator()()
compute value of unary operator
virtual bool isInteger()
is this expression integer?
virtual enum expr_type code()
type of operator
virtual int compare(exprUnary &)
compare two unary functions
Class for MINLP problems with symbolic information.
virtual expression ** ArgPtr()
return pointer to argument
virtual void realign(const CouenneProblem *p)
empty function to redirect variables to proper variable vector
dig_type
type of digging when filling the dependence list
nodeType
type of a node in an expression tree
expression * argument_
single argument taken by this expression
virtual void replace(exprVar *, exprVar *)
replace variable with other
virtual int Linearity()
get a measure of "how linear" the expression is (see CouenneTypes.h) for general univariate functions...
Expression base class.
virtual void print(std::ostream &out=std::cout, bool=false) const
print this expression to iostream
virtual ~exprUnary()
Destructor.
virtual std::string printOp() const
print operator
virtual void fillDepSet(std::set< DepNode *, compNode > *dep, DepGraph *g)
fill in dependence structure
Dependence graph.
virtual unary_function F()
the operator itself (e.g. sin, log...)
Auxiliary variable.
general include file for different compilers