ROL
Toggle main menu visibility
Loading...
Searching...
No Matches
src
sol
function
progressivehedging
ROL_PH_Objective.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
10
#ifndef PH_OBJECTIVE_H
11
#define PH_OBJECTIVE_H
12
13
#include "
ROL_PH_RiskObjective.hpp
"
14
#include "
ROL_PH_DeviationObjective.hpp
"
15
#include "
ROL_PH_RegretObjective.hpp
"
16
#include "
ROL_PH_ErrorObjective.hpp
"
17
#include "
ROL_PH_ProbObjective.hpp
"
18
#include "
ROL_PH_bPOEObjective.hpp
"
19
26
namespace
ROL
{
27
28
template
<
class
Real>
29
class
PH_Objective
:
public
Objective
<Real> {
30
private
:
31
Ptr<Objective<Real>>
obj_
;
32
Ptr<const Vector<Real>>
xbar_
,
w_
;
33
Ptr<Vector<Real>>
xprimal_
;
34
Real
penaltyParam_
;
35
36
public
:
37
38
PH_Objective
(
const
Ptr<
Objective<Real>
> &obj,
39
const
Ptr<
Vector<Real>
> &x,
40
const
Real penaltyParam,
41
ParameterList &parlist)
42
:
xbar_
(nullPtr),
w_
(nullPtr),
xprimal_
(nullPtr),
43
penaltyParam_
(penaltyParam) {
44
xprimal_
= x->clone();
45
std::string type = parlist.sublist(
"SOL"
).get(
"Type"
,
"Risk Neutral"
);
46
if
(type ==
"Risk Averse"
) {
47
obj_
= makePtr<PH_RiskObjective<Real>>(obj,parlist);
48
}
49
else
if
(type ==
"Deviation"
) {
50
obj_
= makePtr<PH_DeviationObjective<Real>>(obj,parlist);
51
}
52
else
if
(type ==
"Regret"
) {
53
obj_
= makePtr<PH_RegretObjective<Real>>(obj,parlist);
54
}
55
else
if
(type ==
"Error"
) {
56
obj_
= makePtr<PH_ErrorObjective<Real>>(obj,parlist);
57
}
58
else
if
(type ==
"Probability"
) {
59
std::string prob = parlist.sublist(
"SOL"
).sublist(
"Probability"
).get(
"Name"
,
"bPOE"
);
60
if
(prob ==
"Smoothed POE"
) {
61
obj_
= makePtr<PH_ProbObjective<Real>>(obj,parlist);
62
}
63
else
if
(prob ==
"bPOE"
) {
64
obj_
= makePtr<PH_bPOEObjective<Real>>(obj,parlist);
65
}
66
else
{
67
ROL_TEST_FOR_EXCEPTION(
true
,std::invalid_argument,
68
"Invalid probability type "
<< prob <<
"!"
);
69
}
70
}
71
else
if
(type ==
"Risk Neutral"
) {
72
obj_
= obj;
73
}
74
else
{
75
ROL_TEST_FOR_EXCEPTION(
true
,std::invalid_argument,
76
"Invalid stochastic component type "
<< type <<
"!"
);
77
}
78
}
79
80
void
setData
(
const
Ptr<
const
Vector<Real>
> &xbar,
81
const
Ptr<
const
Vector<Real>
> &w,
82
const
Real penaltyParam) {
83
xbar_
= xbar;
84
w_
= w;
85
penaltyParam_
= penaltyParam;
86
}
87
88
void
update
(
const
Vector<Real>
&x,
bool
flag =
true
,
int
iter = -1 ) {
89
obj_
->update(x,flag,iter);
90
}
91
92
Real
value
(
const
Vector<Real>
&x, Real &tol ) {
93
const
Real half(0.5), one(1);
94
Real val =
obj_
->value(x,tol);
95
Real wx = x.
dot
(*
w_
);
96
xprimal_
->set(x);
97
xprimal_
->axpy(-one,*
xbar_
);
98
Real xx =
xprimal_
->dot(*
xprimal_
);
99
return
val + wx + half*
penaltyParam_
*xx;
100
}
101
102
void
gradient
(
Vector<Real>
&g,
const
Vector<Real>
&x, Real &tol ) {
103
obj_
->gradient(g,x,tol);
104
xprimal_
->set(*
w_
);
105
xprimal_
->axpy(
penaltyParam_
,x);
106
xprimal_
->axpy(-
penaltyParam_
,*
xbar_
);
107
g.
plus
(
xprimal_
->dual());
108
}
109
110
void
hessVec
(
Vector<Real>
&hv,
const
Vector<Real>
&v,
const
Vector<Real>
&x, Real &tol ) {
111
obj_
->hessVec(hv,v,x,tol);
112
hv.
axpy
(
penaltyParam_
,v.
dual
());
113
}
114
115
void
setParameter
(
const
std::vector<Real> ¶m) {
116
obj_
->setParameter(param);
117
Objective<Real>::setParameter
(param);
118
}
119
120
};
121
122
}
123
#endif
ROL_PH_DeviationObjective.hpp
ROL_PH_ErrorObjective.hpp
ROL_PH_ProbObjective.hpp
ROL_PH_RegretObjective.hpp
ROL_PH_RiskObjective.hpp
ROL_PH_bPOEObjective.hpp
ROL::Objective::setParameter
virtual void setParameter(const std::vector< Real > ¶m)
Definition
ROL_Objective.hpp:509
ROL::PH_Objective::gradient
void gradient(Vector< Real > &g, const Vector< Real > &x, Real &tol)
Definition
ROL_PH_Objective.hpp:102
ROL::PH_Objective::xprimal_
Ptr< Vector< Real > > xprimal_
Definition
ROL_PH_Objective.hpp:33
ROL::PH_Objective::penaltyParam_
Real penaltyParam_
Definition
ROL_PH_Objective.hpp:34
ROL::PH_Objective::hessVec
void hessVec(Vector< Real > &hv, const Vector< Real > &v, const Vector< Real > &x, Real &tol)
Definition
ROL_PH_Objective.hpp:110
ROL::PH_Objective::obj_
Ptr< Objective< Real > > obj_
Definition
ROL_PH_Objective.hpp:31
ROL::PH_Objective::update
void update(const Vector< Real > &x, bool flag=true, int iter=-1)
Definition
ROL_PH_Objective.hpp:88
ROL::PH_Objective::w_
Ptr< const Vector< Real > > w_
Definition
ROL_PH_Objective.hpp:32
ROL::PH_Objective::setData
void setData(const Ptr< const Vector< Real > > &xbar, const Ptr< const Vector< Real > > &w, const Real penaltyParam)
Definition
ROL_PH_Objective.hpp:80
ROL::PH_Objective::setParameter
void setParameter(const std::vector< Real > ¶m)
Definition
ROL_PH_Objective.hpp:115
ROL::PH_Objective::xbar_
Ptr< const Vector< Real > > xbar_
Definition
ROL_PH_Objective.hpp:32
ROL::PH_Objective::value
Real value(const Vector< Real > &x, Real &tol)
Definition
ROL_PH_Objective.hpp:92
ROL::PH_Objective::PH_Objective
PH_Objective(const Ptr< Objective< Real > > &obj, const Ptr< Vector< Real > > &x, const Real penaltyParam, ParameterList &parlist)
Definition
ROL_PH_Objective.hpp:38
ROL::ROL::Objective::Objective
Objective()
Definition
ROL_Constraint_SerialSimOpt.hpp:53
ROL::Vector
Defines the linear algebra or vector space interface.
Definition
ROL_Vector.hpp:51
ROL::Vector::dual
virtual const Vector & dual() const
Return dual representation of , for example, the result of applying a Riesz map, or change of basis,...
Definition
ROL_Vector.hpp:193
ROL::Vector::plus
virtual void plus(const Vector &x)=0
Compute , where .
ROL::Vector::axpy
virtual void axpy(const Real alpha, const Vector &x)
Compute where .
Definition
ROL_Vector.hpp:120
ROL::Vector::dot
virtual Real dot(const Vector &x) const =0
Compute where .
ROL
Definition
ROL_ElementwiseVector.hpp:27
Generated by
1.17.0