00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #include "exprOpp.hpp"
00012 #include "exprConst.hpp"
00013
00014
00015
00016 void exprOpp::getBounds (expression *&lb, expression *&ub) {
00017
00018 expression *lba, *uba;
00019 argument_ -> getBounds (lba, uba);
00020
00021 lb = new exprOpp (uba);
00022 ub = new exprOpp (lba);
00023 }
00024
00025
00026
00027 void exprOpp::getBounds (CouNumber &lb, CouNumber &ub) {
00028
00029 CouNumber lba, uba;
00030 argument_ -> getBounds (lba, uba);
00031
00032 lb = -uba;
00033 ub = -lba;
00034 }
00035
00036
00037
00038 inline expression *exprOpp::differentiate (int index)
00039 {return new exprOpp (argument_ -> differentiate (index));}
00040
00041
00044 bool exprOpp::impliedBound (int wind, CouNumber *l, CouNumber *u, t_chg_bounds *chg) {
00045
00046 int ind = argument_ -> Index ();
00047
00048 bool
00049 res = false,
00050 argInt = argument_ -> isInteger ();
00051
00052 if (updateBound (-1, l + ind, argInt ? ceil (- u [wind] - COUENNE_EPS) : - u [wind])) {
00053 res = true;
00054 chg [ind].setLower(t_chg_bounds::CHANGED);
00055 }
00056
00057 if (updateBound ( 1, u + ind, argInt ? floor (- l [wind] + COUENNE_EPS) : - l [wind])) {
00058 res = true;
00059 chg [ind].setUpper(t_chg_bounds::CHANGED);
00060 }
00061
00062 return res;
00063 }
00064
00065
00067
00068 expression *exprOpp::simplify () {
00069
00070 exprUnary::simplify ();
00071
00072
00073 if (argument_ -> code () == COU_EXPROPP) {
00074 expression *ret = argument_ -> Argument () -> clone ();
00075 delete argument_;
00076 return ret;
00077 }
00078
00079
00080 if (argument_ -> Type () == CONST) {
00081 expression *ret = new exprConst (- argument_ -> Value ());
00082 delete argument_;
00083 return ret;
00084 }
00085
00086 return NULL;
00087 }
00088
00089
00090 void exprOpp::print (std::ostream &out,
00091 bool descend) const {
00092
00093
00094 out << "(-";
00095 argument_ -> print (out, descend);
00096 out << ")";
00097
00098 }