Crevice  0.1
 All Classes Functions Variables Pages
Problem.h
1 /*
2  * File: Problem.h
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 #ifndef PROBLEM_H
20 #define PROBLEM_H
21 
22 #include "TermComperator.h"
23 #include <set>
24 #include <vector>
25 #include <iostream>
26 #include <cstring>
27 
28 typedef std::set<Term*, TermComperator > TermSet;
29 typedef std::set<TermVariable*, TermComperator > VariableSet;
30 
34 class Problem {
35 public:
36  Problem();
37  virtual ~Problem();
40  Term* addTerm(Term* term);
42  TermPointerVector *getGradient();
43  TermPointerVector *getHessian();
44  TermVariablePointerVector *getVariables();
45  bool gradient(const DoubleVector* values,
46  DoubleVector** gradient);
47  bool hessian(const DoubleVector* values,
48  DoubleVector** hessian);
49  size_t numberOfTerms();
50  size_t numberOfVariables();
51  bool objective(const DoubleVector* values,
52  double* obj);
53 private:
54  Problem(const Problem&);
55  Term* objectiveFunction_;
56  TermPointerVector* gradient_;
57  TermPointerVector* hessian_;
58  bool prepareGradient();
59  bool prepareHessian();
60  bool prepareVariables();
61  TermVariablePointerVector* variables_;
62  TermSet* terms;
63  VariableSet* variablesSet_;
64 };
65 
66 #endif /* PROBLEM_H */
67