ROL
Toggle main menu visibility
Loading...
Searching...
No Matches
src
zoo
testproblems
ROL_TestProblem.hpp
Go to the documentation of this file.
1
// @HEADER
2
// *****************************************************************************
3
// Rapid Optimization Library (ROL) Package
4
//
5
// Copyright 2014 NTESS and the ROL contributors.
6
// SPDX-License-Identifier: BSD-3-Clause
7
// *****************************************************************************
8
// @HEADER
9
14
15
#ifndef ROL_TESTPROBLEMS_HPP
16
#define ROL_TESTPROBLEMS_HPP
17
18
#include "
ROL_OptimizationProblem.hpp
"
19
#include "
ROL_Bounds.hpp
"
20
#include "
ROL_RandomVector.hpp
"
21
22
namespace
ROL
{
23
24
template
<
class
Real>
25
class
TestProblem
{
26
public
:
27
virtual
~TestProblem
(
void
) {}
28
TestProblem
(
void
) {}
29
virtual
Ptr<Objective<Real>>
getObjective
(
void
)
const
= 0;
30
virtual
Ptr<Vector<Real>>
getInitialGuess
(
void
)
const
= 0;
31
virtual
Ptr<Vector<Real>>
getSolution
(
const
int
i = 0)
const
= 0;
32
virtual
int
getNumSolutions
(
void
)
const
{
33
return
1;
34
}
35
virtual
Ptr<BoundConstraint<Real>>
getBoundConstraint
(
void
)
const
{
36
return
nullPtr;
37
}
38
virtual
Ptr<Constraint<Real>>
getEqualityConstraint
(
void
)
const
{
39
return
nullPtr;
40
}
41
virtual
Ptr<Vector<Real>>
getEqualityMultiplier
(
void
)
const
{
42
return
nullPtr;
43
}
44
virtual
Ptr<Constraint<Real>>
getInequalityConstraint
(
void
)
const
{
45
return
nullPtr;
46
}
47
virtual
Ptr<Vector<Real>>
getInequalityMultiplier
(
void
)
const
{
48
return
nullPtr;
49
}
50
virtual
Ptr<BoundConstraint<Real>>
getSlackBoundConstraint
(
void
)
const
{
51
return
nullPtr;
52
}
53
54
void
get
(Ptr<
OptimizationProblem<Real>
> &problem,
55
Ptr<
Vector<Real>
> &x0,
56
std::vector<Ptr<
Vector<Real>
>> &x)
const
{
57
x0 =
getInitialGuess
()->clone(); x0->set(*
getInitialGuess
());
58
x.resize(
getNumSolutions
());
59
for
(
int
i = 0; i <
getNumSolutions
(); ++i) {
60
x[i] =
getSolution
(i)->clone(); x[i]->set(*
getSolution
(i));
61
}
62
63
problem = makePtr<OptimizationProblem<Real>>(
getObjective
(),
64
x0,
65
getBoundConstraint
(),
66
getEqualityConstraint
(),
67
getEqualityMultiplier
(),
68
getInequalityConstraint
(),
69
getInequalityMultiplier
(),
70
getSlackBoundConstraint
());
71
}
72
};
73
}
// namespace ROL
74
75
#endif
ROL_Bounds.hpp
ROL_OptimizationProblem.hpp
ROL_RandomVector.hpp
ROL::OptimizationProblem
Definition
ROL_OptimizationProblem.hpp:54
ROL::TestProblem::getInitialGuess
virtual Ptr< Vector< Real > > getInitialGuess(void) const =0
ROL::TestProblem::getEqualityMultiplier
virtual Ptr< Vector< Real > > getEqualityMultiplier(void) const
Definition
ROL_TestProblem.hpp:41
ROL::TestProblem::getSlackBoundConstraint
virtual Ptr< BoundConstraint< Real > > getSlackBoundConstraint(void) const
Definition
ROL_TestProblem.hpp:50
ROL::TestProblem::getInequalityConstraint
virtual Ptr< Constraint< Real > > getInequalityConstraint(void) const
Definition
ROL_TestProblem.hpp:44
ROL::TestProblem::TestProblem
TestProblem(void)
Definition
ROL_TestProblem.hpp:28
ROL::TestProblem::getBoundConstraint
virtual Ptr< BoundConstraint< Real > > getBoundConstraint(void) const
Definition
ROL_TestProblem.hpp:35
ROL::TestProblem::getEqualityConstraint
virtual Ptr< Constraint< Real > > getEqualityConstraint(void) const
Definition
ROL_TestProblem.hpp:38
ROL::TestProblem::getObjective
virtual Ptr< Objective< Real > > getObjective(void) const =0
ROL::TestProblem::getSolution
virtual Ptr< Vector< Real > > getSolution(const int i=0) const =0
ROL::TestProblem::getNumSolutions
virtual int getNumSolutions(void) const
Definition
ROL_TestProblem.hpp:32
ROL::TestProblem::~TestProblem
virtual ~TestProblem(void)
Definition
ROL_TestProblem.hpp:27
ROL::TestProblem::get
void get(Ptr< OptimizationProblem< Real > > &problem, Ptr< Vector< Real > > &x0, std::vector< Ptr< Vector< Real > > > &x) const
Definition
ROL_TestProblem.hpp:54
ROL::TestProblem::getInequalityMultiplier
virtual Ptr< Vector< Real > > getInequalityMultiplier(void) const
Definition
ROL_TestProblem.hpp:47
ROL::Vector
Defines the linear algebra or vector space interface.
Definition
ROL_Vector.hpp:51
ROL
Definition
ROL_ElementwiseVector.hpp:27
Generated by
1.17.0