Couenne  0.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 void replace(exprVar *, exprVar *)
replace variable with other
virtual enum expr_type code()
type of operator
pos
position where the operator should be printed when printing the expression
virtual bool isInteger()
is this expression integer?
exprUnary(expression *argument)
Constructor.
expression * argument_
single argument taken by this expression
virtual unary_function F()
the operator itself (e.g. sin, log...)
virtual int Linearity()
get a measure of &quot;how linear&quot; the expression is (see CouenneTypes.h) for general univariate functions...
virtual void realign(const CouenneProblem *p)
empty function to redirect variables to proper variable vector
expression class for unary functions (sin, log, etc.)
virtual int compare(exprUnary &)
compare two unary functions
virtual void fillDepSet(std::set< DepNode *, compNode > *dep, DepGraph *g)
fill in dependence structure
virtual CouNumber operator()()
compute value of unary operator
virtual ~exprUnary()
Destructor.
CouNumber(* unary_function)(CouNumber)
unary function, used in all exprUnary
virtual enum pos printPos() const
print position (PRE, INSIDE, POST)
expression * simplify()
simplification
Class for MINLP problems with symbolic information.
virtual std::string printOp() const
print operator
virtual expression * Argument() const
return argument
virtual void print(std::ostream &out=std::cout, bool=false) const
print this expression to iostream
double CouNumber
main number type in Couenne
virtual expression ** ArgPtr()
return pointer to argument
nodeType
type of a node in an expression tree
Dependence graph.
Auxiliary variable.
dig_type
type of digging when filling the dependence list
variable-type operator
expr_type
code returned by the method expression::code()
CouNumber zero_fun(CouNumber x)
zero function (used by default by exprUnary)
Expression base class.
virtual enum nodeType Type() const
node type
int nArgs() const
return number of arguments
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
virtual int rank()
used in rank-based branching variable choice
virtual exprAux * standardize(CouenneProblem *, bool addAux=true)
reduce expression in standard form, creating additional aux variables (and constraints) ...