Crevice
0.1
Xypron
>
Projects
>
Crevice
> Doxygen
Main Page
Classes
Files
File List
All
Classes
Functions
Variables
Pages
src
problem
TermConstant.cc
1
/*
2
* File: TermConstant.cc
3
*
4
* Copyright 2012 Heinrich Schuchardt <xypron.glpk@gmx.de>
5
*
6
* Licensed under the Apache License, Version 2.0 (the "License");
7
* you may not use this file except in compliance with the License.
8
* You may obtain a copy of the License at
9
*
10
* http://www.apache.org/licenses/LICENSE-2.0
11
*
12
* Unless required by applicable law or agreed to in writing, software
13
* distributed under the License is distributed on an "AS IS" BASIS,
14
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
* See the License for the specific language governing permissions and
16
* limitations under the License.
17
*/
18
19
#include "TermConstant.h"
20
#include "Problem.h"
21
#include <sstream>
22
28
TermConstant::TermConstant
(
Problem
* problem,
const
double
value) :
29
Term
::
Term
(problem) {
30
value_ = value;
31
}
32
36
TermConstant::~TermConstant
() {
37
}
38
45
TermConstant
*
TermConstant::create
(
Problem
* problem,
const
double
value)
throw
46
(
ProblemMismatchException
) {
47
TermConstant
* term =
new
TermConstant
(problem, value);
48
term =
static_cast<
TermConstant
*
>
(problem->addTerm(term));
49
return
term;
50
}
51
52
Term
*
TermConstant::differentiate
(
TermVariable
* variable)
throw
53
(
ProblemMismatchException
) {
54
return
TermConstant::create
(this->getProblem(), 0);
55
}
56
57
double
TermConstant::evaluate() {
58
return
value_;
59
}
60
61
double
TermConstant::eval
(
62
const
DoubleVector* variableValues,
63
TermValueSet* termValues) {
64
return
value_;
65
}
66
67
bool
TermConstant::less
(
const
Term
* term)
const
{
68
if
(this->
Term::less
(term)) {
69
return
true
;
70
}
else
if
(term->Term::less(
this
)) {
71
return
false
;
72
}
else
{
73
const
TermConstant
* term_constant;
74
term_constant =
static_cast<
const
TermConstant
*
>
(term);
75
return
this->value_ < term_constant->value_;
76
}
77
}
78
79
std::string
TermConstant::toString
()
const
{
80
std::ostringstream os;
81
os << value_;
82
return
os.str();
83
};
Generated on Sat Feb 1 2014 14:50:30 for Crevice by
1.8.1.2