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