20 #include "TermConstant.h"
22 #include "TermVariable.h"
35 if (summand1->
less(summand2)) {
36 this->summand1_ = summand1;
37 this->summand2_ = summand2;
39 this->summand1_ = summand2;
40 this->summand2_ = summand1;
62 (static_cast<TermConstant *> (summand1))->
evaluate() == 0) {
66 (static_cast<TermConstant *> (summand2))->
evaluate() == 0) {
72 (static_cast<TermConstant *> (summand1))->
evaluate() +
73 (static_cast<TermConstant *> (summand2))->
evaluate());
76 term =
new TermSum(problem, summand1, summand2);
83 if (this->getProblem() != variable->getProblem()) {
85 throw problem_mismatch_exception;
88 this->summand1_->differentiate(variable),
89 this->summand2_->differentiate(variable)
94 TermValueSet* termValues) {
95 return this->summand1_->
evaluate(variableValues, termValues) +
96 this->summand2_->
evaluate(variableValues, termValues);
103 }
else if (term->Term::less(
this)) {
106 term_product =
static_cast<const TermSum *
> (term);
107 if (this->summand1_ < term_product->summand1_) {
109 }
else if (term_product->summand1_ < this->summand1_) {
112 if (this->summand2_ < term_product->summand2_) {
120 std::ostringstream os;
121 os <<
"(" << this->summand1_ <<
" + " << this->summand2_ <<
")";