ROL
ROL_OptimizationProblem.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 ROL_OPTIMIZATIONPROBLEM_HPP
11 #define ROL_OPTIMIZATIONPROBLEM_HPP
12 
13 #include <utility>
14 
17 
18 // Stochastic Includes
19 #include "ROL_SampleGenerator.hpp"
20 #include "ROL_RiskVector.hpp"
22 // Objective includes
26 // Constraint includes
30 // Almost sure constraint includes
33 #include "ROL_SimulatedVector.hpp"
34 
35 namespace ROL {
36 
37 template <class Real>
39  std::vector<Real> checkSolutionVector;
40  std::vector<std::vector<Real>> checkGradient;
41  std::vector<std::vector<Real>> checkHessVec;
42  std::vector<Real> checkHessSym;
43  std::vector<Real> checkMultiplierVector;
44  std::vector<std::vector<Real>> checkApplyJacobian;
45  std::vector<std::vector<Real>> checkApplyAdjointJacobian;
46  std::vector<std::vector<Real>> checkApplyAdjointHessian;
48 };
49 
50 /* Represents optimization problems in Type-EB form
51  */
52 
53 template<class Real>
55 private:
56  Ptr<Objective<Real>> INPUT_obj_;
57  Ptr<Vector<Real>> INPUT_sol_;
58  Ptr<BoundConstraint<Real>> INPUT_bnd_;
59  std::vector<Ptr<Constraint<Real>>> INPUT_econ_;
60  std::vector<Ptr<Vector<Real>>> INPUT_emul_;
61  std::vector<Ptr<Constraint<Real>>> INPUT_icon_;
62  std::vector<Ptr<Vector<Real>>> INPUT_imul_;
63  std::vector<Ptr<BoundConstraint<Real>>> INPUT_ibnd_;
64 
65  Ptr<Objective<Real>> INTERMEDIATE_obj_;
66  Ptr<Vector<Real>> INTERMEDIATE_sol_;
67  Ptr<BoundConstraint<Real>> INTERMEDIATE_bnd_;
68  std::vector<Ptr<Constraint<Real>>> INTERMEDIATE_econ_;
69  std::vector<Ptr<Vector<Real>>> INTERMEDIATE_emul_;
70  std::vector<Ptr<Constraint<Real>>> INTERMEDIATE_icon_;
71  std::vector<Ptr<Vector<Real>>> INTERMEDIATE_imul_;
72  std::vector<Ptr<BoundConstraint<Real>>> INTERMEDIATE_ibnd_;
73 
74  Ptr<SampleGenerator<Real>> vsampler_;
75  Ptr<SampleGenerator<Real>> gsampler_;
76  Ptr<SampleGenerator<Real>> hsampler_;
77  std::vector<Ptr<SampleGenerator<Real>>> exsampler_;
78  std::vector<Ptr<BatchManager<Real>>> ecbman_;
79  std::vector<Ptr<SampleGenerator<Real>>> ixsampler_;
80  std::vector<Ptr<BatchManager<Real>>> icbman_;
81 
82  Ptr<ParameterList> parlistObj_;
83  std::vector<Ptr<ParameterList>> parlistCon_;
84 
85  Ptr<Objective<Real>> obj_;
86  Ptr<Vector<Real>> sol_;
87  Ptr<BoundConstraint<Real>> bnd_;
88  Ptr<Constraint<Real>> con_;
89  Ptr<Vector<Real>> mul_;
90 
91  Ptr<ConstraintManager<Real>> conManager_;
92 
94 
96 
98  std::vector<bool> needRiskLessEcon_;
99  std::vector<bool> needRiskLessIcon_;
101 
102  void initialize( const Ptr<Objective<Real>> &obj,
103  const Ptr<Vector<Real>> &x,
104  const Ptr<BoundConstraint<Real>> &bnd,
105  const std::vector<Ptr<Constraint<Real>>> &econ,
106  const std::vector<Ptr<Vector<Real>>> &emul,
107  const std::vector<Ptr<Constraint<Real>>> &icon,
108  const std::vector<Ptr<Vector<Real>>> &imul,
109  const std::vector<Ptr<BoundConstraint<Real>>> &ibnd ) {
110  if (!isInitialized_) {
111  int esize = static_cast<int>(econ.size());
112  int isize = static_cast<int>(icon.size());
113  std::vector<Ptr<Constraint<Real>>> cvec;
114  std::vector<Ptr<Vector<Real>>> lvec;
115  std::vector<Ptr<BoundConstraint<Real>>> bvec;
116  for (int i = 0; i < esize; ++i) {
117  if ( econ[i] != nullPtr ) {
118  if (isStochastic_) {
119  cvec.push_back(setRiskLessCon(econ[i],needRiskLessEcon_[i]));
120  }
121  else {
122  cvec.push_back(econ[i]);
123  }
124  lvec.push_back(emul[i]);
125  bvec.push_back(nullPtr);
126  }
127  }
128  for (int i = 0; i < isize; ++i) {
129  if ( icon[i] != nullPtr ) {
130  if (isStochastic_) {
131  cvec.push_back(setRiskLessCon(icon[i],needRiskLessIcon_[i]));
132  }
133  else {
134  cvec.push_back(icon[i]);
135  }
136  lvec.push_back(imul[i]);
137  bvec.push_back(ibnd[i]);
138  }
139  }
140 
141  conManager_ = makePtr<ConstraintManager<Real>>(cvec,lvec,bvec,x,bnd);
142  con_ = conManager_->getConstraint();
143  mul_ = conManager_->getMultiplier();
144  sol_ = conManager_->getOptVector();
145  bnd_ = conManager_->getBoundConstraint();
146  Ptr<Objective<Real>> obj0;
147  if (isStochastic_) {
148  obj0 = setRiskLessObj(obj,needRiskLessObj_);
149  }
150  else {
151  obj0 = obj;
152  }
153  if ( conManager_->hasInequality() ) {
154  obj_ = makePtr<SlacklessObjective<Real>>(obj0);
155  }
156  else {
157  obj_ = obj0;
158  }
159 
160  if ( conManager_->isNull() ) {
161  if( bnd_ == nullPtr || !bnd_->isActivated() ) { // Type-U
162  problemType_ = TYPE_U;
163  }
164  else { // Type-B
165  problemType_ = TYPE_B;
166  }
167  }
168  else {
169  if( bnd_ == nullPtr || !bnd_->isActivated() ) { // Type-E
170  problemType_ = TYPE_E;
171  }
172  else { // Type-EB
174  }
175  }
176  isInitialized_ = true;
177  }
178  }
179 
180  const Ptr<Constraint<Real>> setRiskLessCon(const Ptr<Constraint<Real>> &con, const bool needRiskLess) const {
181  if (needRiskLess) {
182  return makePtr<RiskLessConstraint<Real>>(con);
183  }
184  else {
185  return con;
186  }
187  }
188 
189  const Ptr<Objective<Real>> setRiskLessObj(const Ptr<Objective<Real>> &obj, const bool needRiskLess) const {
190  if (needRiskLess) {
191  return makePtr<RiskLessObjective<Real>>(obj);
192  }
193  else {
194  return obj;
195  }
196  }
197 
198  std::vector<Real> computeSampleMean(const Ptr<SampleGenerator<Real>> &sampler) const {
199  // Compute mean value of inputs and set parameter in objective
200  int dim = sampler->getMyPoint(0).size(), nsamp = sampler->numMySamples();
201  std::vector<Real> loc(dim), mean(dim), pt(dim);
202  Real wt(0);
203  for (int i = 0; i < nsamp; i++) {
204  pt = sampler->getMyPoint(i);
205  wt = sampler->getMyWeight(i);
206  for (int j = 0; j < dim; j++) {
207  loc[j] += wt*pt[j];
208  }
209  }
210  sampler->sumAll(&loc[0],&mean[0],dim);
211  return mean;
212  }
213 
214  void initStochastic(void) {
215  if (!isStochastic_) {
216  int econSize = INPUT_econ_.size();
217  int iconSize = INPUT_icon_.size();
218  needRiskLessObj_ = true;
219  needRiskLessEcon_.clear(); needRiskLessEcon_.resize(econSize,true);
220  needRiskLessIcon_.clear(); needRiskLessIcon_.resize(iconSize,true);
221  parlistObj_ = nullPtr;
222  parlistCon_.clear(); parlistCon_.resize(iconSize,nullPtr);
223 
224  exsampler_.clear(); exsampler_.resize(econSize,nullPtr);
225  ecbman_.clear(); ecbman_.resize(econSize,nullPtr);
226 
227  ixsampler_.clear(); ixsampler_.resize(iconSize,nullPtr);
228  icbman_.clear(); icbman_.resize(iconSize,nullPtr);
229 
230  isStochastic_ = true;
231  }
232  }
233 
234  void buildRiskVec(Ptr<Vector<Real>> &x) {
235  // Build risk vector and risk bound constraint
237  = makePtr<RiskVector<Real>>(parlistObj_,parlistCon_,x);
238  if (parlistObj_ != nullPtr) {
239  Real statObj = parlistObj_->sublist("SOL").get("Initial Statistic",1.0);
240  dynamicPtrCast<RiskVector<Real>>(INTERMEDIATE_sol_)->setStatistic(statObj,0);
241  }
242  int nc = INPUT_icon_.size();
243  for (int i = 0; i < nc; ++i) {
244  if (parlistCon_[i] != nullPtr) {
245  Real statCon = parlistCon_[i]->sublist("SOL").get("Initial Statistic",1.0);
246  dynamicPtrCast<RiskVector<Real>>(INTERMEDIATE_sol_)->setStatistic(statCon,1,i);
247  }
248  }
249  }
250 
252  if ( INPUT_bnd_ != nullPtr ) {
254  = makePtr<RiskBoundConstraint<Real>>(parlistObj_,parlistCon_,bnd);
255  }
256  }
257 
258 public:
259  virtual ~OptimizationProblem(void) {}
260 
261  // Default constructor [0]
263  : isInitialized_(false), isStochastic_(false) {}
264 
265  // Complete option constructor [1]
267  const Ptr<Vector<Real>> &x,
268  const Ptr<BoundConstraint<Real>> &bnd,
269  const std::vector<Ptr<Constraint<Real>>> &econ,
270  const std::vector<Ptr<Vector<Real>>> &emul,
271  const std::vector<Ptr<Constraint<Real>>> &icon,
272  const std::vector<Ptr<Vector<Real>>> &imul,
273  const std::vector<Ptr<BoundConstraint<Real>>> &ibnd )
274  : INPUT_obj_(obj), INPUT_sol_(x), INPUT_bnd_(bnd),
275  INPUT_econ_(econ), INPUT_emul_(emul),
276  INPUT_icon_(icon), INPUT_imul_(imul), INPUT_ibnd_(ibnd),
280  isInitialized_(false), isStochastic_(false) {}
281 
283  const Ptr<Vector<Real>> &x,
284  const Ptr<BoundConstraint<Real>> &bnd,
285  const Ptr<Constraint<Real>> &econ,
286  const Ptr<Vector<Real>> &emul,
287  const std::vector<Ptr<Constraint<Real>>> &icon,
288  const std::vector<Ptr<Vector<Real>>> &imul,
289  const std::vector<Ptr<BoundConstraint<Real>>> &ibnd )
290  : INPUT_obj_(obj), INPUT_sol_(x), INPUT_bnd_(bnd),
291  INPUT_icon_(icon), INPUT_imul_(imul), INPUT_ibnd_(ibnd),
294  isInitialized_(false), isStochastic_(false) {
295  std::vector<Ptr<Constraint<Real>>> econ0(1,econ);
296  std::vector<Ptr<Vector<Real>>> emul0(1,emul);
297  INPUT_econ_ = econ0;
298  INPUT_emul_ = emul0;
299  INTERMEDIATE_econ_ = econ0;
300  INTERMEDIATE_emul_ = emul0;
301  }
302 
304  const Ptr<Vector<Real>> &x,
305  const Ptr<BoundConstraint<Real>> &bnd,
306  const std::vector<Ptr<Constraint<Real>>> &econ,
307  const std::vector<Ptr<Vector<Real>>> &emul,
308  const Ptr<Constraint<Real>> &icon,
309  const Ptr<Vector<Real>> &imul,
310  const Ptr<BoundConstraint<Real>> &ibnd )
311  : INPUT_obj_(obj), INPUT_sol_(x), INPUT_bnd_(bnd),
312  INPUT_econ_(econ), INPUT_emul_(emul),
315  isInitialized_(false), isStochastic_(false) {
316  std::vector<Ptr<Constraint<Real>>> icon0(1,icon);
317  std::vector<Ptr<Vector<Real>>> imul0(1,imul);
318  std::vector<Ptr<BoundConstraint<Real>>> ibnd0(1,ibnd);
319  INPUT_icon_ = icon0;
320  INPUT_imul_ = imul0;
321  INPUT_ibnd_ = ibnd0;
322  INTERMEDIATE_icon_ = icon0;
323  INTERMEDIATE_imul_ = imul0;
324  INTERMEDIATE_ibnd_ = ibnd0;
325  }
326 
328  const Ptr<Vector<Real>> &x,
329  const Ptr<BoundConstraint<Real>> &bnd,
330  const Ptr<Constraint<Real>> &econ,
331  const Ptr<Vector<Real>> &emul,
332  const Ptr<Constraint<Real>> &icon,
333  const Ptr<Vector<Real>> &imul,
334  const Ptr<BoundConstraint<Real>> &ibnd )
335  : INPUT_obj_(obj), INPUT_sol_(x), INPUT_bnd_(bnd),
337  isInitialized_(false), isStochastic_(false) {
338  std::vector<Ptr<Constraint<Real>>> econ0(1,econ);
339  std::vector<Ptr<Vector<Real>>> emul0(1,emul);
340  std::vector<Ptr<Constraint<Real>>> icon0(1,icon);
341  std::vector<Ptr<Vector<Real>>> imul0(1,imul);
342  std::vector<Ptr<BoundConstraint<Real>>> ibnd0(1,ibnd);
343  INPUT_econ_ = econ0;
344  INPUT_emul_ = emul0;
345  INPUT_icon_ = icon0;
346  INPUT_imul_ = imul0;
347  INPUT_ibnd_ = ibnd0;
348  INTERMEDIATE_econ_ = econ0;
349  INTERMEDIATE_emul_ = emul0;
350  INTERMEDIATE_icon_ = icon0;
351  INTERMEDIATE_imul_ = imul0;
352  INTERMEDIATE_ibnd_ = ibnd0;
353  }
354 
355  // No bound constuctor [2]
357  const Ptr<Vector<Real>> &x,
358  const std::vector<Ptr<Constraint<Real>>> &econ,
359  const std::vector<Ptr<Vector<Real>>> &emul,
360  const std::vector<Ptr<Constraint<Real>>> &icon,
361  const std::vector<Ptr<Vector<Real>>> &imul,
362  const std::vector<Ptr<BoundConstraint<Real>>> &ibnd )
363  : OptimizationProblem( obj, x, nullPtr, econ, emul, icon, imul, ibnd ) {}
364 
366  const Ptr<Vector<Real>> &x,
367  const Ptr<Constraint<Real>> &econ,
368  const Ptr<Vector<Real>> &emul,
369  const std::vector<Ptr<Constraint<Real>>> &icon,
370  const std::vector<Ptr<Vector<Real>>> &imul,
371  const std::vector<Ptr<BoundConstraint<Real>>> &ibnd )
372  : OptimizationProblem( obj, x, nullPtr, econ, emul, icon, imul, ibnd) {}
373 
375  const Ptr<Vector<Real>> &x,
376  const std::vector<Ptr<Constraint<Real>>> &econ,
377  const std::vector<Ptr<Vector<Real>>> &emul,
378  const Ptr<Constraint<Real>> &icon,
379  const Ptr<Vector<Real>> &imul,
380  const Ptr<BoundConstraint<Real>> &ibnd )
381  : OptimizationProblem( obj, x, nullPtr, econ, emul, icon, imul, ibnd) {}
382 
384  const Ptr<Vector<Real>> &x,
385  const Ptr<Constraint<Real>> &econ,
386  const Ptr<Vector<Real>> &emul,
387  const Ptr<Constraint<Real>> &icon,
388  const Ptr<Vector<Real>> &imul,
389  const Ptr<BoundConstraint<Real>> &ibnd )
390  : OptimizationProblem( obj, x, nullPtr, econ, emul, icon, imul, ibnd) {}
391 
392  // No inequality constraint [3]
394  const Ptr<Vector<Real>> &x,
395  const Ptr<BoundConstraint<Real>> &bnd,
396  const std::vector<Ptr<Constraint<Real>>> &econ,
397  const std::vector<Ptr<Vector<Real>>> &emul )
398  : OptimizationProblem( obj, x, bnd, econ, emul, nullPtr, nullPtr, nullPtr ) {}
399 
401  const Ptr<Vector<Real>> &x,
402  const Ptr<BoundConstraint<Real>> &bnd,
403  const Ptr<Constraint<Real>> &econ,
404  const Ptr<Vector<Real>> &emul )
405  : OptimizationProblem( obj, x, bnd, econ, emul, nullPtr, nullPtr, nullPtr) {}
406 
407  // No equality constraint [4]
409  const Ptr<Vector<Real>> &x,
410  const Ptr<BoundConstraint<Real>> &bnd,
411  const std::vector<Ptr<Constraint<Real>>> &icon,
412  const std::vector<Ptr<Vector<Real>>> &imul,
413  const std::vector<Ptr<BoundConstraint<Real>>> &ibnd )
414  : OptimizationProblem( obj, x, bnd, nullPtr, nullPtr, icon, imul, ibnd ) {}
415 
417  const Ptr<Vector<Real>> &x,
418  const Ptr<BoundConstraint<Real>> &bnd,
419  const Ptr<Constraint<Real>> &icon,
420  const Ptr<Vector<Real>> &imul,
421  const Ptr<BoundConstraint<Real>> &ibnd )
422  : OptimizationProblem( obj, x, bnd, nullPtr, nullPtr, icon, imul, ibnd) {}
423 
424  // No inequality or bound constraint [5]
426  const Ptr<Vector<Real>> &x,
427  const std::vector<Ptr<Constraint<Real>>> &econ,
428  const std::vector<Ptr<Vector<Real>>> &emul )
429  : OptimizationProblem( obj, x, nullPtr, econ, emul, nullPtr, nullPtr, nullPtr ) {}
430 
432  const Ptr<Vector<Real>> &x,
433  const Ptr<Constraint<Real>> &econ,
434  const Ptr<Vector<Real>> &emul )
435  : OptimizationProblem( obj, x, nullPtr, econ, emul, nullPtr, nullPtr, nullPtr) {}
436 
437  // No equality or bound constraint [6]
439  const Ptr<Vector<Real>> &x,
440  const std::vector<Ptr<Constraint<Real>>> &icon,
441  const std::vector<Ptr<Vector<Real>>> &imul,
442  const std::vector<Ptr<BoundConstraint<Real>>> &ibnd )
443  : OptimizationProblem( obj, x, nullPtr, nullPtr, nullPtr, icon, imul, ibnd ) {}
444 
446  const Ptr<Vector<Real>> &x,
447  const Ptr<Constraint<Real>> &icon,
448  const Ptr<Vector<Real>> &imul,
449  const Ptr<BoundConstraint<Real>> &ibnd )
450  : OptimizationProblem( obj, x, nullPtr, nullPtr, nullPtr, icon, imul, ibnd) {}
451 
452  // Bound constrained problem [7]
454  const Ptr<Vector<Real>> &x,
455  const Ptr<BoundConstraint<Real>> &bnd )
456  : OptimizationProblem( obj, x, bnd, nullPtr, nullPtr, nullPtr, nullPtr, nullPtr ) {}
457 
458  // Unconstrained problem [8]
460  const Ptr<Vector<Real>> &x ) :
461  OptimizationProblem( obj, x, nullPtr, nullPtr, nullPtr, nullPtr, nullPtr, nullPtr ) {}
462 
463  /* Get methods */
464 
465  virtual Ptr<Objective<Real>> getObjective(void) {
466  if ( INTERMEDIATE_obj_ == nullPtr ) {
467  throw Exception::NotImplemented(">>> ROL::OptimizationProblem::getObjective: No objective inputed!");
468  }
472  return obj_;
473  }
474 
475  virtual Ptr<Vector<Real>> getSolutionVector(void) {
476  if ( INTERMEDIATE_sol_ == nullPtr ) {
477  throw Exception::NotImplemented(">>> ROL::OptimizationProblem::getSolutionVector: No solution vector inputed!");
478  }
482  return sol_;
483  }
484 
485  virtual Ptr<BoundConstraint<Real>> getBoundConstraint(void) {
489  return bnd_;
490  }
491 
492  virtual Ptr<Constraint<Real>> getConstraint(void) {
496  return con_;
497  }
498 
499  virtual Ptr<Vector<Real>> getMultiplierVector(void) {
503  return mul_;
504  }
505 
510  return problemType_;
511  }
512 
513  /* Set Stochastic Methods */
514 
515  /* Objective function */
526  void setMeanValueObjective(const Ptr<SampleGenerator<Real>> &sampler) {
527  initStochastic();
528  // Set objective function samplers
529  vsampler_ = sampler;
530  gsampler_ = sampler;
531  hsampler_ = sampler;
532  // Construct risk-averse/probabilistic objective function
533  if ( vsampler_ == nullPtr ) {
534  throw Exception::NotImplemented(">>> ROL::OptimizationProblem::setMeanValueObjective: Objective function value sampler is null!");
535  }
536  else {
537  std::vector<Real> mean = computeSampleMean(vsampler_);
539  INTERMEDIATE_obj_->setParameter(mean);
540  }
541  // Set vector and bound constraint
544 
545  isInitialized_ = false;
546  }
547 
561  const Ptr<SampleGenerator<Real>> &gsampler = nullPtr,
562  const Ptr<SampleGenerator<Real>> &hsampler = nullPtr,
563  const bool storage = true) {
564  initStochastic();
565  // Set objective function samplers
566  vsampler_ = vsampler;
567  gsampler_ = gsampler;
568  hsampler_ = hsampler;
569  if ( gsampler == nullPtr ) {
571  }
572  if ( hsampler == nullPtr ) {
574  }
575  // Construct risk-averse/probabilistic objective function
576  if ( vsampler_ == nullPtr ) {
577  throw Exception::NotImplemented(">>> ROL::OptimizationProblem::setRiskNeutralObjective: Objective function value sampler is null!");
578  }
579  else {
581  = makePtr<RiskNeutralObjective<Real>>(INPUT_obj_,vsampler_,gsampler_,hsampler_,storage);
582  }
583  // Set vector and bound constraint
586 
587  isInitialized_ = false;
588  }
589 
602  void setRiskAverseObjective(ParameterList &parlist,
603  const Ptr<SampleGenerator<Real>> &vsampler,
604  const Ptr<SampleGenerator<Real>> &gsampler = nullPtr,
605  const Ptr<SampleGenerator<Real>> &hsampler = nullPtr) {
606  initStochastic();
607  // Set objective function samplers
608  vsampler_ = vsampler;
609  gsampler_ = gsampler;
610  hsampler_ = hsampler;
611  if ( gsampler == nullPtr ) {
613  }
614  if ( hsampler == nullPtr ) {
616  }
617  // Construct risk-averse/probabilistic objective function
618  if ( vsampler_ == nullPtr ) {
619  throw Exception::NotImplemented(">>> ROL::OptimizationProblem::setRiskAverseObjective: Objective function value sampler is null!");
620  }
621  else {
622  needRiskLessObj_ = false;
623  parlistObj_ = makePtrFromRef(parlist);
625  = makePtr<StochasticObjective<Real>>(INPUT_obj_,parlist,vsampler_,gsampler_,hsampler_);
626  }
627  // Set vector and bound constraint
630 
631  isInitialized_ = false;
632  }
633 
634  void setStochasticObjective(ParameterList &parlist,
635  const Ptr<SampleGenerator<Real>> &vsampler,
636  const Ptr<SampleGenerator<Real>> &gsampler = nullPtr,
637  const Ptr<SampleGenerator<Real>> &hsampler = nullPtr) {
638  // Determine Stochastic Objective Type
639  std::string type = parlist.sublist("SOL").get("Type","Risk Neutral");
640  if ( type == "Risk Neutral" ) {
641  bool storage = parlist.sublist("SOL").get("Store Sampled Value and Gradient",true);
642  setRiskNeutralObjective(vsampler,gsampler,hsampler,storage);
643  }
644  else if ( type == "Risk Averse" ||
645  type == "Deviation" ||
646  type == "Error" ||
647  type == "Regret" ||
648  type == "Probability" ) {
649  setRiskAverseObjective(parlist,vsampler,gsampler,hsampler);
650  }
651  else if ( type == "Mean Value" ) {
652  setMeanValueObjective(vsampler);
653  }
654  else {
655  throw Exception::NotImplemented(">>> ROL::OptimizationProblem::setStochasticObjective: Invalid stochastic optimization type!");
656  }
657  // Set vector and bound constraint
660 
661  isInitialized_ = false;
662  }
663 
664  /* Equality Constraint */
665  void setMeanValueEquality(const Ptr<SampleGenerator<Real>> &sampler, const int index = 0) {
666  initStochastic();
667  exsampler_[index] = sampler;
668  if ( INPUT_econ_[index] != nullPtr && sampler != nullPtr ) {
669  std::vector<Real> mean = computeSampleMean(sampler);
670  INTERMEDIATE_econ_[index] = INPUT_econ_[index];
671  INTERMEDIATE_econ_[index]->setParameter(mean);
672  INTERMEDIATE_emul_[index] = INPUT_emul_[index];
673  }
674  else {
675  throw Exception::NotImplemented(">>> ROL::OptimizationProblem::setMeanValueEquality: Either SampleGenerator or Constraint is NULL!");
676  }
677  // Set vector and bound constraint
680 
681  isInitialized_ = false;
682  }
683 
685  const Ptr<BatchManager<Real>> &cbman,
686  const int index = 0) {
687  initStochastic();
688  exsampler_[index] = xsampler;
689  ecbman_[index] = cbman;
690  if ( INPUT_econ_[index] != nullPtr
691  && xsampler != nullPtr
692  && cbman != nullPtr ) {
693  INTERMEDIATE_econ_[index]
694  = makePtr<RiskNeutralConstraint<Real>>(INPUT_econ_[index],xsampler,cbman);
695  INTERMEDIATE_emul_[index] = INPUT_emul_[index];
696  }
697  else {
698  throw Exception::NotImplemented(">>> ROL::OptimizationProblem::SetRiskNeutralEquality: Either SampleGenerator, Constraint or BatchManager is NULL!");
699  }
700  // Set vector and bound constraint
703 
704  isInitialized_ = false;
705  }
706 
708  const int index = 0) {
709  initStochastic();
710  exsampler_[index] = sampler;
711  if ( INPUT_econ_[index] != nullPtr && sampler != nullPtr ) {
712  int nsamp = sampler->numMySamples();
713  INTERMEDIATE_econ_[index]
714  = makePtr<AlmostSureConstraint<Real>>(sampler,INPUT_econ_[index]);
715  std::vector<Ptr<Vector<Real>>> emul(nsamp,nullPtr);
716  for (int j = 0; j < nsamp; ++j) {
717  emul[j] = INPUT_emul_[index]->clone();
718  emul[j]->set(*INPUT_emul_[index]);
719  }
720  INTERMEDIATE_emul_[index]
721  = makePtr<DualSimulatedVector<Real>>(emul, sampler->getBatchManager(), sampler);
722  }
723  else {
724  throw Exception::NotImplemented(">>> ROL::OptimizationProblem::SetAlmostSureEquality: Either SampleGenerator or Constraint is NULL!");
725  }
726  // Set vector and bound constraint
729 
730  isInitialized_ = false;
731  }
732 
733 
734  void setStochasticEquality(std::vector<ParameterList> &parlist,
735  const std::vector<Ptr<SampleGenerator<Real>>> &xsampler,
736  const std::vector<Ptr<BatchManager<Real>>> &cbman) {
737  initStochastic();
738  int nc = static_cast<int>(INPUT_econ_.size());
739  if ( nc != static_cast<int>(xsampler.size()) || nc != static_cast<int>(cbman.size()) ) {
740  throw Exception::NotImplemented(">>> ROL::OptimizationProblem::setStochasticEquality: Constraint vector and SampleGenerator vector are not the same size!");
741  }
742  for (int i = 0; i < nc; ++i) {
743  if (xsampler[i] != nullPtr) {
744  std::string type = parlist[i].sublist("SOL").get("Type","Risk Neutral");
745  if ( type == "Risk Neutral" ) {
746  setRiskNeutralEquality(xsampler[i],cbman[i],i);
747  }
748  else if ( type == "Almost Sure" ) {
749  setAlmostSureEquality(xsampler[i],i);
750  }
751  else if ( type == "Mean Value" ) {
752  setMeanValueEquality(xsampler[i],i);
753  }
754  else {
755  throw Exception::NotImplemented(">>> ROL::OptimizationProblem::SetStochasticEquality: Invalid stochastic constraint type!");
756  }
757  }
758  else {
761  }
762  }
763  // Set vector and bound constraint
766 
767  isInitialized_ = false;
768  }
769 
770  void setStochasticEquality(ParameterList &parlist,
771  const Ptr<SampleGenerator<Real>> &xsampler,
772  const Ptr<BatchManager<Real>> &cbman) {
773  std::vector<ParameterList> cparlist(1,parlist);
774  std::vector<Ptr<SampleGenerator<Real>>> cxsampler(1,xsampler);
775  std::vector<Ptr<BatchManager<Real>>> ccbman(1,cbman);
776  setStochasticEquality(cparlist,cxsampler,ccbman);
777  }
778 
779  /* Inequality constraint */
781  const int index = 0) {
782  initStochastic();
783  ixsampler_[index] = sampler;
784  if ( INPUT_icon_[index] != nullPtr && sampler != nullPtr ) {
785  std::vector<Real> mean = computeSampleMean(sampler);
786  INTERMEDIATE_icon_[index] = INPUT_icon_[index];
787  INTERMEDIATE_icon_[index]->setParameter(mean);
788  INTERMEDIATE_ibnd_[index] = INPUT_ibnd_[index];
789  INTERMEDIATE_imul_[index] = INPUT_imul_[index];
790  }
791  else {
792  throw Exception::NotImplemented(">>> ROL::OptimizationProblem::SetMeanValueInequality: Either Constraint or SampleGenerator is NULL!");
793  }
794  // Set vector and bound constraint
797 
798  isInitialized_ = false;
799  }
800 
802  const Ptr<BatchManager<Real>> &cbman,
803  const int index = 0) {
804  initStochastic();
805  ixsampler_[index] = xsampler;
806  icbman_[index] = cbman;
807  if ( INPUT_icon_[index] != nullPtr
808  && xsampler != nullPtr
809  && cbman != nullPtr ) {
810  INTERMEDIATE_icon_[index]
811  = makePtr<RiskNeutralConstraint<Real>>(INPUT_icon_[index],xsampler,cbman);
812  INTERMEDIATE_ibnd_[index] = INPUT_ibnd_[index];
813  INTERMEDIATE_imul_[index] = INPUT_imul_[index];
814  }
815  else {
816  throw Exception::NotImplemented(">>> ROL::OptimizationProblem::SetRiskNeutralInequality: Either Constraint, SampleGenerator or BatchManager is NULL!");
817  }
818  // Set vector and bound constraint
821 
822  isInitialized_ = false;
823  }
824 
825  void setRiskAverseInequality(ParameterList &parlist,
826  const Ptr<SampleGenerator<Real>> &sampler,
827  const int index = 0) {
828  initStochastic();
829  ixsampler_[index] = sampler;
830  if ( INPUT_icon_[index] != nullPtr && sampler != nullPtr ) {
831  needRiskLessIcon_[index] = false;
832  parlistCon_[index] = makePtrFromRef(parlist);
833  INTERMEDIATE_icon_[index]
834  = makePtr<StochasticConstraint<Real>>(INPUT_icon_[index],sampler,parlist,index);
835  INTERMEDIATE_ibnd_[index] = INPUT_ibnd_[index];
836  INTERMEDIATE_imul_[index] = INPUT_imul_[index];
837  }
838  else {
839  throw Exception::NotImplemented(">>> ROL::OptimizationProblem::SetRiskAverseInequality: Either Constraint or SampleGenerator is NULL!");
840  }
841  // Set vector and bound constraint
844 
845  isInitialized_ = false;
846  }
847 
849  const int index = 0) {
850  initStochastic();
851  ixsampler_[index] = sampler;
852  if ( INPUT_icon_[index] != nullPtr && sampler != nullPtr ) {
853  int nsamp = sampler->numMySamples();
854  INTERMEDIATE_icon_[index]
855  = makePtr<AlmostSureConstraint<Real>>(sampler, INPUT_icon_[index]);
856  std::vector<Ptr<Vector<Real>>> imul(nsamp,nullPtr);
857  for (int j = 0; j < nsamp; ++j) {
858  imul[j] = INPUT_imul_[index]->clone();
859  imul[j]->set(*INPUT_imul_[index]);
860  }
861  INTERMEDIATE_imul_[index]
862  = makePtr<DualSimulatedVector<Real>>(imul, sampler->getBatchManager(), sampler);
863  INTERMEDIATE_ibnd_[index]
864  = makePtr<SimulatedBoundConstraint<Real>>(sampler, INPUT_ibnd_[index]);
865  }
866  else {
867  throw Exception::NotImplemented(">>> ROL::OptimizationProblem::SetAlmostSureInequality: Either Constraint or SampleGenerator is NULL!");
868  }
869  // Set vector and bound constraint
872 
873  isInitialized_ = false;
874  }
875 
876  void setStochasticInequality(std::vector<ParameterList> &parlist,
877  const std::vector<Ptr<SampleGenerator<Real>>> &xsampler,
878  const std::vector<Ptr<BatchManager<Real>>> &cbman) {
879  initStochastic();
880  int nc = static_cast<int>(INPUT_icon_.size());
881  if ( nc != static_cast<int>(xsampler.size()) || nc != static_cast<int>(cbman.size()) ) {
882  throw Exception::NotImplemented(">>> ROL::OptimizationProblem::setStochasticInequality: Constraint vector and SampleGenerator vector are not the same size!");
883  }
884  for (int i = 0; i < nc; ++i) {
885  if ( xsampler[i] != nullPtr ) {
886  std::string type = parlist[i].sublist("SOL").get("Type","Risk Neutral");
887  if ( type == "Risk Neutral" ) {
888  setRiskNeutralInequality(xsampler[i],cbman[i],i);
889  }
890  else if ( type == "Risk Averse" ||
891  type == "Deviation" ||
892  type == "Error" ||
893  type == "Regret" ||
894  type == "Probability" ) {
895  setRiskAverseInequality(parlist[i],xsampler[i],i);
896  }
897  else if ( type == "Almost Sure" ) {
898  setAlmostSureInequality(xsampler[i],i);
899  }
900  else if ( type == "Mean Value" ) {
901  setMeanValueInequality(xsampler[i],i);
902  }
903  else {
904  throw Exception::NotImplemented(">>> ROL::OptimizationProblem::SetStochasticInequality: Invalid stochastic constraint type!");
905  }
906  }
907  else {
911  }
912  }
913  // Set vector and bound constraint
916 
917  isInitialized_ = false;
918  }
919 
920  void setStochasticInequality(ParameterList &parlist,
921  const Ptr<SampleGenerator<Real>> &xsampler,
922  const Ptr<BatchManager<Real>> &cbman) {
923  std::vector<ParameterList> cparlist(1,parlist);
924  std::vector<Ptr<SampleGenerator<Real>>> cxsampler(1,xsampler);
925  std::vector<Ptr<BatchManager<Real>>> ccbman(1,cbman);
926  setStochasticInequality(cparlist,cxsampler,ccbman);
927  }
928 
934  Real getSolutionStatistic(int comp = 0, int index = 0) {
935  Real val(0);
936  if (comp == 0) {
937  try {
938  val = dynamicPtrCast<StochasticObjective<Real>>(INTERMEDIATE_obj_)->computeStatistic(*INTERMEDIATE_sol_);
939  }
940  catch (std::exception &e) {
941  throw Exception::NotImplemented(">>> ROL::OptimizationProblem::getSolutionStatistic: Objective does not have computeStatistic function!");
942  }
943  }
944  else if (comp == 1) {
945  int np = INTERMEDIATE_icon_.size();
946  if (np <= index || index < 0) {
947  throw Exception::NotImplemented(">>> ROL::OptimizationProblem::getSolutionStatistic: Index out of bounds!");
948  }
949  try {
950  val = dynamicPtrCast<StochasticConstraint<Real>>(INTERMEDIATE_icon_[index])->computeStatistic(*INTERMEDIATE_sol_);
951  }
952  catch (std::exception &e) {
953  throw Exception::NotImplemented(">>> ROL::OptimizationProblem::getSolutionStatistic: Constraint does not have computeStatistic function!");
954  }
955  }
956  else {
957  throw Exception::NotImplemented(">>> ROL::OptimizationProblem::getSolutionStatistic: Component must be either 0 or 1!");
958  }
959  return val;
960  }
961 
962  std::vector<Real> getObjectiveStatistic(void) const {
963  try {
964  Ptr<std::vector<Real>> stat
965  = dynamicPtrCast<RiskVector<Real>>(INTERMEDIATE_sol_)->getStatistic();
966  if (stat != nullPtr) {
967  return *stat;
968  }
969  else {
970  std::vector<Real> empty;
971  return empty;
972  }
973  }
974  catch (std::exception &e) {
975  std::vector<Real> empty;
976  return empty;
977  }
978  }
979 
980  std::vector<Real> getConstraintStatistic(const int index = 0) const {
981  try {
982  Ptr<std::vector<Real>> stat
983  = dynamicPtrCast<RiskVector<Real>>(INTERMEDIATE_sol_)->getStatistic(1,index);
984  if (stat != nullPtr) {
985  return *stat;
986  }
987  else {
988  std::vector<Real> empty;
989  return empty;
990  }
991  }
992  catch (std::exception &e) {
993  std::vector<Real> empty;
994  return empty;
995  }
996  }
997 
998  void reset(void) {
1002  conManager_->resetSlackVariables();
1003  }
1004 
1005  // Check derivatives, and consistency
1006  void checkSolutionVector( Vector<Real> &x, // Optimization space
1007  Vector<Real> &y, // Optimization space
1008  Vector<Real> &u, // Optimization space
1009  std::ostream &outStream = std::cout ) {
1011  checkSolutionVector(data,x,y,u,outStream);
1012 
1013  }
1014 
1016  Vector<Real> &x, // Optimization space
1017  Vector<Real> &y, // Optimization space
1018  Vector<Real> &u, // Optimization space
1019  std::ostream &outStream = std::cout ) {
1023  if (obj_ != nullPtr) {
1024  outStream << "\nPerforming OptimizationProblem diagnostics." << std::endl << std::endl;
1025 
1026  outStream << "Checking vector operations in optimization vector space X." << std::endl;
1027  data.checkSolutionVector = x.checkVector(y,u,true,outStream);
1028  }
1029  }
1030 
1031  void checkObjective( Vector<Real> &x, // Optimization space
1032  Vector<Real> &u, // Optimization space
1033  Vector<Real> &v, // Optimization space
1034  std::ostream &outStream = std::cout,
1035  const int numSteps = ROL_NUM_CHECKDERIV_STEPS,
1036  const int order = 1 ) {
1038  checkObjective(data,x,u,v,outStream,numSteps,order);
1039  }
1040 
1042  Vector<Real> &x, // Optimization space
1043  Vector<Real> &u, // Optimization space
1044  Vector<Real> &v, // Optimization space
1045  std::ostream &outStream = std::cout,
1046  const int numSteps = ROL_NUM_CHECKDERIV_STEPS,
1047  const int order = 1 ) {
1051  if (obj_ != nullPtr) {
1052  outStream << std::endl << "Performing OptimizationProblem diagnostics."
1053  << std::endl << std::endl;
1054  outStream << "Checking objective function." << std::endl;
1055  data.checkGradient = obj_->checkGradient(x,v,true,outStream,numSteps,order);
1056  outStream << std::endl;
1057  data.checkHessVec = obj_->checkHessVec(x,u,true,outStream,numSteps,order);
1058  outStream << std::endl;
1059  data.checkHessSym = obj_->checkHessSym(x,u,v,true,outStream);
1060  outStream << std::endl;
1061  }
1062  }
1063 
1064  void checkMultiplierVector( Vector<Real> &w, // Dual constraint space
1065  Vector<Real> &q, // Dual constraint space
1066  Vector<Real> &l, // Dual constraint space
1067  std::ostream &outStream = std::cout ) {
1069  checkMultiplierVector(data,w,q,l,outStream);
1070  }
1071 
1073  Vector<Real> &w, // Dual constraint space
1074  Vector<Real> &q, // Dual constraint space
1075  Vector<Real> &l, // Dual constraint space
1076  std::ostream &outStream = std::cout ) {
1080  if(con_ != nullPtr) {
1081  outStream << "\nPerforming OptimizationProblem diagnostics." << std::endl << std::endl;
1082 
1083  outStream << "Checking vector operations in constraint multiplier space C*." << std::endl;
1084  data.checkMultiplierVector = l.checkVector(q,w,true,outStream);
1085  }
1086  }
1087 
1088  void checkConstraint( Vector<Real> &x, // Optimization space
1089  Vector<Real> &u, // Optimization space
1090  Vector<Real> &v, // Optimization space
1091  Vector<Real> &c, // Constraint space
1092  Vector<Real> &l, // Dual constraint space
1093  std::ostream &outStream = std::cout,
1094  const int numSteps = ROL_NUM_CHECKDERIV_STEPS,
1095  const int order = 1 ) {
1097  checkConstraint(data,x,u,v,c,l,outStream,numSteps,order);
1098  }
1099 
1101  Vector<Real> &x, // Optimization space
1102  Vector<Real> &u, // Optimization space
1103  Vector<Real> &v, // Optimization space
1104  Vector<Real> &c, // Constraint space
1105  Vector<Real> &l, // Dual constraint space
1106  std::ostream &outStream = std::cout,
1107  const int numSteps = ROL_NUM_CHECKDERIV_STEPS,
1108  const int order = 1 ) {
1112  if(con_ != nullPtr) {
1113  outStream << "\nPerforming OptimizationProblem diagnostics." << std::endl << std::endl;
1114 
1115  outStream << "Checking equality constraint." << std::endl;
1116  data.checkApplyJacobian = con_->checkApplyJacobian(x,v,c,true,outStream,numSteps,order);
1117  outStream << std::endl;
1118  data.checkAdjointConsistencyJacobian = con_->checkAdjointConsistencyJacobian(l,u,x,true,outStream);
1119  outStream << std::endl;
1120  data.checkApplyAdjointHessian = con_->checkApplyAdjointHessian(x,l,v,u,true,outStream,numSteps,order);
1121  outStream << std::endl;
1122  }
1123  }
1124 
1125  // Check derivatives, and consistency
1126  void check( std::ostream &outStream = std::cout,
1127  const int numSteps = ROL_NUM_CHECKDERIV_STEPS,
1128  const int order = 1 ) {
1130  check(data,outStream,numSteps,order);
1131  }
1132 
1134  std::ostream &outStream = std::cout,
1135  const int numSteps = ROL_NUM_CHECKDERIV_STEPS,
1136  const int order = 1 ) {
1140 
1141  Ptr<Vector<Real>> x, y, u, v;
1142  try {
1143  x = sol_->clone(); x->randomize();
1144  y = sol_->clone(); y->randomize();
1145  u = sol_->clone(); u->randomize();
1146  v = sol_->clone(); v->randomize();
1147 
1148  checkSolutionVector(data,*x,*y,*u,outStream);
1149  checkObjective(data,*x,*u,*v,outStream,numSteps,order);
1150  }
1151  catch (std::exception &e) {
1152 // throw Exception::NotImplemented(">>> ROL::OptimizationProblem::check: Elementwise is not implemented for optimization space vectors");
1153  }
1154 
1155  if(con_ != nullPtr) {
1156  Ptr<Vector<Real>> c, l, w, q;
1157  try {
1158  c = mul_->dual().clone(); c->randomize();
1159  l = mul_->clone(); l->randomize();
1160  w = mul_->clone(); w->randomize();
1161  q = mul_->clone(); q->randomize();
1162 
1163  checkMultiplierVector(data,*w,*q,*l,outStream);
1164  checkConstraint(data,*x,*u,*v,*c,*l,outStream,numSteps,order);
1165  }
1166  catch (std::exception &e) {
1167  throw Exception::NotImplemented(">>> ROL::OptimizationProblem::check: Elementwise is not implemented for constraint space vectors");
1168  }
1169  }
1170  }
1171 
1172 }; // class OptimizationProblem
1173 
1174 
1175 template<template<typename> class V,
1176  template<typename> class Obj,
1177  typename Real,typename P=Ptr<OptimizationProblem<Real>>,typename...Args>
1178 inline typename std::enable_if<std::is_base_of<Objective<Real>,Obj<Real>>::value &&
1179  std::is_base_of<Vector<Real>, V<Real>>::value,P>::type
1180 make_OptimizationProblem( const Ptr<Obj<Real>> &obj, const Ptr<V<Real>> &x, Args&&...args) {
1181  return makePtr<OptimizationProblem<Real>>(obj,x,std::forward<Args>(args)...);
1182 }
1183 
1184 } // namespace ROL
1185 
1186 #endif // ROL_OPTIMIZATIONPROBLEM_HPP
Ptr< Vector< Real > > INTERMEDIATE_sol_
Provides the interface to evaluate objective functions.
void setRiskNeutralObjective(const Ptr< SampleGenerator< Real >> &vsampler, const Ptr< SampleGenerator< Real >> &gsampler=nullPtr, const Ptr< SampleGenerator< Real >> &hsampler=nullPtr, const bool storage=true)
Set objective function to risk neutral objective.
Ptr< Constraint< Real > > con_
void checkConstraint(OptimizationProblemCheckData< Real > &data, Vector< Real > &x, Vector< Real > &u, Vector< Real > &v, Vector< Real > &c, Vector< Real > &l, std::ostream &outStream=std::cout, const int numSteps=ROL_NUM_CHECKDERIV_STEPS, const int order=1)
std::vector< Ptr< Vector< Real > > > INTERMEDIATE_imul_
OptimizationProblem(const Ptr< Objective< Real >> &obj, const Ptr< Vector< Real >> &x, const Ptr< BoundConstraint< Real >> &bnd)
void checkObjective(Vector< Real > &x, Vector< Real > &u, Vector< Real > &v, std::ostream &outStream=std::cout, const int numSteps=ROL_NUM_CHECKDERIV_STEPS, const int order=1)
std::vector< Ptr< BoundConstraint< Real > > > INPUT_ibnd_
OptimizationProblem(const Ptr< Objective< Real >> &obj, const Ptr< Vector< Real >> &x, const Ptr< Constraint< Real >> &econ, const Ptr< Vector< Real >> &emul, const Ptr< Constraint< Real >> &icon, const Ptr< Vector< Real >> &imul, const Ptr< BoundConstraint< Real >> &ibnd)
OptimizationProblem(const Ptr< Objective< Real >> &obj, const Ptr< Vector< Real >> &x)
void setRiskNeutralEquality(const Ptr< SampleGenerator< Real >> &xsampler, const Ptr< BatchManager< Real >> &cbman, const int index=0)
Ptr< SampleGenerator< Real > > hsampler_
void checkSolutionVector(OptimizationProblemCheckData< Real > &data, Vector< Real > &x, Vector< Real > &y, Vector< Real > &u, std::ostream &outStream=std::cout)
std::vector< Ptr< Constraint< Real > > > INTERMEDIATE_econ_
void checkMultiplierVector(Vector< Real > &w, Vector< Real > &q, Vector< Real > &l, std::ostream &outStream=std::cout)
OptimizationProblem(const Ptr< Objective< Real >> &obj, const Ptr< Vector< Real >> &x, const std::vector< Ptr< Constraint< Real >>> &econ, const std::vector< Ptr< Vector< Real >>> &emul, const Ptr< Constraint< Real >> &icon, const Ptr< Vector< Real >> &imul, const Ptr< BoundConstraint< Real >> &ibnd)
OptimizationProblem(const Ptr< Objective< Real >> &obj, const Ptr< Vector< Real >> &x, const Ptr< BoundConstraint< Real >> &bnd, const std::vector< Ptr< Constraint< Real >>> &econ, const std::vector< Ptr< Vector< Real >>> &emul, const Ptr< Constraint< Real >> &icon, const Ptr< Vector< Real >> &imul, const Ptr< BoundConstraint< Real >> &ibnd)
void setRiskNeutralInequality(const Ptr< SampleGenerator< Real >> &xsampler, const Ptr< BatchManager< Real >> &cbman, const int index=0)
std::vector< Ptr< SampleGenerator< Real > > > ixsampler_
virtual Ptr< Objective< Real > > getObjective(void)
void setMeanValueInequality(const Ptr< SampleGenerator< Real >> &sampler, const int index=0)
ROL::Objective_SimOpt value
virtual Ptr< BoundConstraint< Real > > getBoundConstraint(void)
void setStochasticInequality(std::vector< ParameterList > &parlist, const std::vector< Ptr< SampleGenerator< Real >>> &xsampler, const std::vector< Ptr< BatchManager< Real >>> &cbman)
void setStochasticObjective(ParameterList &parlist, const Ptr< SampleGenerator< Real >> &vsampler, const Ptr< SampleGenerator< Real >> &gsampler=nullPtr, const Ptr< SampleGenerator< Real >> &hsampler=nullPtr)
OptimizationProblem(const Ptr< Objective< Real >> &obj, const Ptr< Vector< Real >> &x, const Ptr< BoundConstraint< Real >> &bnd, const std::vector< Ptr< Constraint< Real >>> &econ, const std::vector< Ptr< Vector< Real >>> &emul, const std::vector< Ptr< Constraint< Real >>> &icon, const std::vector< Ptr< Vector< Real >>> &imul, const std::vector< Ptr< BoundConstraint< Real >>> &ibnd)
void setAlmostSureEquality(const Ptr< SampleGenerator< Real >> &sampler, const int index=0)
void setStochasticEquality(std::vector< ParameterList > &parlist, const std::vector< Ptr< SampleGenerator< Real >>> &xsampler, const std::vector< Ptr< BatchManager< Real >>> &cbman)
std::enable_if< std::is_base_of< Objective< Real >, Obj< Real > >::value &&std::is_base_of< Vector< Real >, V< Real > >::value, P >::type make_OptimizationProblem(const Ptr< Obj< Real >> &obj, const Ptr< V< Real >> &x, Args &&...args)
OptimizationProblem(const Ptr< Objective< Real >> &obj, const Ptr< Vector< Real >> &x, const Ptr< Constraint< Real >> &econ, const Ptr< Vector< Real >> &emul, const std::vector< Ptr< Constraint< Real >>> &icon, const std::vector< Ptr< Vector< Real >>> &imul, const std::vector< Ptr< BoundConstraint< Real >>> &ibnd)
virtual std::vector< Real > checkVector(const Vector< Real > &x, const Vector< Real > &y, const bool printToStream=true, std::ostream &outStream=std::cout) const
Verify vector-space methods.
Definition: ROL_Vector.hpp:291
std::vector< Ptr< Vector< Real > > > INTERMEDIATE_emul_
std::vector< Ptr< ParameterList > > parlistCon_
void checkObjective(OptimizationProblemCheckData< Real > &data, Vector< Real > &x, Vector< Real > &u, Vector< Real > &v, std::ostream &outStream=std::cout, const int numSteps=ROL_NUM_CHECKDERIV_STEPS, const int order=1)
std::vector< Ptr< BoundConstraint< Real > > > INTERMEDIATE_ibnd_
Objective_TimeSimOpt< Real > Obj
Defines the linear algebra or vector space interface.
Definition: ROL_Vector.hpp:46
std::vector< Ptr< SampleGenerator< Real > > > exsampler_
Ptr< Vector< Real > > INPUT_sol_
Ptr< BoundConstraint< Real > > INPUT_bnd_
OptimizationProblem(const Ptr< Objective< Real >> &obj, const Ptr< Vector< Real >> &x, const Ptr< BoundConstraint< Real >> &bnd, const std::vector< Ptr< Constraint< Real >>> &econ, const std::vector< Ptr< Vector< Real >>> &emul)
Vector< Real > V
void setAlmostSureInequality(const Ptr< SampleGenerator< Real >> &sampler, const int index=0)
std::vector< Ptr< Constraint< Real > > > INTERMEDIATE_icon_
std::vector< Ptr< Constraint< Real > > > INPUT_econ_
OptimizationProblem(const Ptr< Objective< Real >> &obj, const Ptr< Vector< Real >> &x, const Ptr< BoundConstraint< Real >> &bnd, const Ptr< Constraint< Real >> &econ, const Ptr< Vector< Real >> &emul)
std::vector< bool > needRiskLessEcon_
OptimizationProblem(const Ptr< Objective< Real >> &obj, const Ptr< Vector< Real >> &x, const Ptr< BoundConstraint< Real >> &bnd, const std::vector< Ptr< Constraint< Real >>> &icon, const std::vector< Ptr< Vector< Real >>> &imul, const std::vector< Ptr< BoundConstraint< Real >>> &ibnd)
void setMeanValueObjective(const Ptr< SampleGenerator< Real >> &sampler)
Set objective function to mean value objective.
Ptr< Objective< Real > > INPUT_obj_
Real getSolutionStatistic(int comp=0, int index=0)
Returns the statistic from the soluton vector.
void initialize(const Ptr< Objective< Real >> &obj, const Ptr< Vector< Real >> &x, const Ptr< BoundConstraint< Real >> &bnd, const std::vector< Ptr< Constraint< Real >>> &econ, const std::vector< Ptr< Vector< Real >>> &emul, const std::vector< Ptr< Constraint< Real >>> &icon, const std::vector< Ptr< Vector< Real >>> &imul, const std::vector< Ptr< BoundConstraint< Real >>> &ibnd)
virtual Ptr< Vector< Real > > getSolutionVector(void)
void buildRiskBnd(Ptr< BoundConstraint< Real >> &bnd)
Ptr< ConstraintManager< Real > > conManager_
void setMeanValueEquality(const Ptr< SampleGenerator< Real >> &sampler, const int index=0)
Ptr< SampleGenerator< Real > > vsampler_
void setRiskAverseObjective(ParameterList &parlist, const Ptr< SampleGenerator< Real >> &vsampler, const Ptr< SampleGenerator< Real >> &gsampler=nullPtr, const Ptr< SampleGenerator< Real >> &hsampler=nullPtr)
Set objective function to risk averse objective.
std::vector< std::vector< Real > > checkApplyAdjointJacobian
void check(OptimizationProblemCheckData< Real > &data, std::ostream &outStream=std::cout, const int numSteps=ROL_NUM_CHECKDERIV_STEPS, const int order=1)
void checkConstraint(Vector< Real > &x, Vector< Real > &u, Vector< Real > &v, Vector< Real > &c, Vector< Real > &l, std::ostream &outStream=std::cout, const int numSteps=ROL_NUM_CHECKDERIV_STEPS, const int order=1)
OptimizationProblem(const Ptr< Objective< Real >> &obj, const Ptr< Vector< Real >> &x, const std::vector< Ptr< Constraint< Real >>> &icon, const std::vector< Ptr< Vector< Real >>> &imul, const std::vector< Ptr< BoundConstraint< Real >>> &ibnd)
OptimizationProblem(const Ptr< Objective< Real >> &obj, const Ptr< Vector< Real >> &x, const Ptr< BoundConstraint< Real >> &bnd, const Ptr< Constraint< Real >> &econ, const Ptr< Vector< Real >> &emul, const std::vector< Ptr< Constraint< Real >>> &icon, const std::vector< Ptr< Vector< Real >>> &imul, const std::vector< Ptr< BoundConstraint< Real >>> &ibnd)
virtual Ptr< Vector< Real > > getMultiplierVector(void)
void setStochasticInequality(ParameterList &parlist, const Ptr< SampleGenerator< Real >> &xsampler, const Ptr< BatchManager< Real >> &cbman)
std::vector< Real > getObjectiveStatistic(void) const
Provides the interface to apply upper and lower bound constraints.
Ptr< BoundConstraint< Real > > bnd_
#define ROL_NUM_CHECKDERIV_STEPS
Number of steps for derivative checks.
Definition: ROL_Types.hpp:40
std::vector< Real > getConstraintStatistic(const int index=0) const
Ptr< Objective< Real > > obj_
std::vector< std::vector< Real > > checkApplyAdjointHessian
void setRiskAverseInequality(ParameterList &parlist, const Ptr< SampleGenerator< Real >> &sampler, const int index=0)
std::vector< Ptr< Vector< Real > > > INPUT_imul_
OptimizationProblem(const Ptr< Objective< Real >> &obj, const Ptr< Vector< Real >> &x, const Ptr< BoundConstraint< Real >> &bnd, const Ptr< Constraint< Real >> &econ, const Ptr< Vector< Real >> &emul, const Ptr< Constraint< Real >> &icon, const Ptr< Vector< Real >> &imul, const Ptr< BoundConstraint< Real >> &ibnd)
OptimizationProblem(const Ptr< Objective< Real >> &obj, const Ptr< Vector< Real >> &x, const Ptr< BoundConstraint< Real >> &bnd, const Ptr< Constraint< Real >> &icon, const Ptr< Vector< Real >> &imul, const Ptr< BoundConstraint< Real >> &ibnd)
std::vector< std::vector< Real > > checkGradient
void buildRiskVec(Ptr< Vector< Real >> &x)
OptimizationProblem(const Ptr< Objective< Real >> &obj, const Ptr< Vector< Real >> &x, const std::vector< Ptr< Constraint< Real >>> &econ, const std::vector< Ptr< Vector< Real >>> &emul, const std::vector< Ptr< Constraint< Real >>> &icon, const std::vector< Ptr< Vector< Real >>> &imul, const std::vector< Ptr< BoundConstraint< Real >>> &ibnd)
void checkSolutionVector(Vector< Real > &x, Vector< Real > &y, Vector< Real > &u, std::ostream &outStream=std::cout)
const Ptr< Constraint< Real > > setRiskLessCon(const Ptr< Constraint< Real >> &con, const bool needRiskLess) const
OptimizationProblem(const Ptr< Objective< Real >> &obj, const Ptr< Vector< Real >> &x, const std::vector< Ptr< Constraint< Real >>> &econ, const std::vector< Ptr< Vector< Real >>> &emul)
Ptr< SampleGenerator< Real > > gsampler_
void check(std::ostream &outStream=std::cout, const int numSteps=ROL_NUM_CHECKDERIV_STEPS, const int order=1)
std::vector< std::vector< Real > > checkHessVec
void checkMultiplierVector(OptimizationProblemCheckData< Real > &data, Vector< Real > &w, Vector< Real > &q, Vector< Real > &l, std::ostream &outStream=std::cout)
std::vector< Ptr< BatchManager< Real > > > ecbman_
std::vector< std::vector< Real > > checkApplyJacobian
Ptr< Objective< Real > > INTERMEDIATE_obj_
void setStochasticEquality(ParameterList &parlist, const Ptr< SampleGenerator< Real >> &xsampler, const Ptr< BatchManager< Real >> &cbman)
EProblem
Definition: ROL_Types.hpp:223
constexpr auto dim
std::vector< Ptr< Vector< Real > > > INPUT_emul_
std::vector< Real > computeSampleMean(const Ptr< SampleGenerator< Real >> &sampler) const
std::vector< Ptr< Constraint< Real > > > INPUT_icon_
Defines the general constraint operator interface.
const Ptr< Objective< Real > > setRiskLessObj(const Ptr< Objective< Real >> &obj, const bool needRiskLess) const
std::vector< bool > needRiskLessIcon_
OptimizationProblem(const Ptr< Objective< Real >> &obj, const Ptr< Vector< Real >> &x, const Ptr< Constraint< Real >> &icon, const Ptr< Vector< Real >> &imul, const Ptr< BoundConstraint< Real >> &ibnd)
Ptr< BoundConstraint< Real > > INTERMEDIATE_bnd_
virtual Ptr< Constraint< Real > > getConstraint(void)
std::vector< Ptr< BatchManager< Real > > > icbman_
OptimizationProblem(const Ptr< Objective< Real >> &obj, const Ptr< Vector< Real >> &x, const Ptr< Constraint< Real >> &econ, const Ptr< Vector< Real >> &emul)