ROL
ROL_OptimizationProblem.hpp
Go to the documentation of this file.
1 // @HEADER
2 // ************************************************************************
3 //
4 // Rapid Optimization Library (ROL) Package
5 // Copyright (2014) Sandia Corporation
6 //
7 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
8 // license for use of this work by or on behalf of the U.S. Government.
9 //
10 // Redistribution and use in source and binary forms, with or without
11 // modification, are permitted provided that the following conditions are
12 // met:
13 //
14 // 1. Redistributions of source code must retain the above copyright
15 // notice, this list of conditions and the following disclaimer.
16 //
17 // 2. Redistributions in binary form must reproduce the above copyright
18 // notice, this list of conditions and the following disclaimer in the
19 // documentation and/or other materials provided with the distribution.
20 //
21 // 3. Neither the name of the Corporation nor the names of the
22 // contributors may be used to endorse or promote products derived from
23 // this software without specific prior written permission.
24 //
25 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 //
37 // Questions? Contact lead developers:
38 // Drew Kouri (dpkouri@sandia.gov) and
39 // Denis Ridzal (dridzal@sandia.gov)
40 //
41 // ************************************************************************
42 // @HEADER
43 
44 #ifndef ROL_OPTIMIZATIONPROBLEM_HPP
45 #define ROL_OPTIMIZATIONPROBLEM_HPP
46 
47 #include <utility>
48 
51 
52 // Stochastic Includes
53 #include "ROL_SampleGenerator.hpp"
54 #include "ROL_RiskVector.hpp"
56 // Objective includes
60 // Constraint includes
64 // Almost sure constraint includes
67 #include "ROL_SimulatedVector.hpp"
68 
69 namespace ROL {
70 
71 template <class Real>
73  std::vector<Real> checkSolutionVector;
74  std::vector<std::vector<Real>> checkGradient;
75  std::vector<std::vector<Real>> checkHessVec;
76  std::vector<Real> checkHessSym;
77  std::vector<Real> checkMultiplierVector;
78  std::vector<std::vector<Real>> checkApplyJacobian;
79  std::vector<std::vector<Real>> checkApplyAdjointJacobian;
80  std::vector<std::vector<Real>> checkApplyAdjointHessian;
82 };
83 
84 /* Represents optimization problems in Type-EB form
85  */
86 
87 template<class Real>
89 private:
90  Ptr<Objective<Real>> INPUT_obj_;
91  Ptr<Vector<Real>> INPUT_sol_;
92  Ptr<BoundConstraint<Real>> INPUT_bnd_;
93  std::vector<Ptr<Constraint<Real>>> INPUT_econ_;
94  std::vector<Ptr<Vector<Real>>> INPUT_emul_;
95  std::vector<Ptr<Constraint<Real>>> INPUT_icon_;
96  std::vector<Ptr<Vector<Real>>> INPUT_imul_;
97  std::vector<Ptr<BoundConstraint<Real>>> INPUT_ibnd_;
98 
99  Ptr<Objective<Real>> INTERMEDIATE_obj_;
100  Ptr<Vector<Real>> INTERMEDIATE_sol_;
101  Ptr<BoundConstraint<Real>> INTERMEDIATE_bnd_;
102  std::vector<Ptr<Constraint<Real>>> INTERMEDIATE_econ_;
103  std::vector<Ptr<Vector<Real>>> INTERMEDIATE_emul_;
104  std::vector<Ptr<Constraint<Real>>> INTERMEDIATE_icon_;
105  std::vector<Ptr<Vector<Real>>> INTERMEDIATE_imul_;
106  std::vector<Ptr<BoundConstraint<Real>>> INTERMEDIATE_ibnd_;
107 
108  Ptr<SampleGenerator<Real>> vsampler_;
109  Ptr<SampleGenerator<Real>> gsampler_;
110  Ptr<SampleGenerator<Real>> hsampler_;
111  std::vector<Ptr<SampleGenerator<Real>>> exsampler_;
112  std::vector<Ptr<BatchManager<Real>>> ecbman_;
113  std::vector<Ptr<SampleGenerator<Real>>> ixsampler_;
114  std::vector<Ptr<BatchManager<Real>>> icbman_;
115 
116  Ptr<ParameterList> parlistObj_;
117  std::vector<Ptr<ParameterList>> parlistCon_;
118 
119  Ptr<Objective<Real>> obj_;
120  Ptr<Vector<Real>> sol_;
121  Ptr<BoundConstraint<Real>> bnd_;
122  Ptr<Constraint<Real>> con_;
123  Ptr<Vector<Real>> mul_;
124 
125  Ptr<ConstraintManager<Real>> conManager_;
126 
128 
130 
132  std::vector<bool> needRiskLessEcon_;
133  std::vector<bool> needRiskLessIcon_;
135 
136  void initialize( const Ptr<Objective<Real>> &obj,
137  const Ptr<Vector<Real>> &x,
138  const Ptr<BoundConstraint<Real>> &bnd,
139  const std::vector<Ptr<Constraint<Real>>> &econ,
140  const std::vector<Ptr<Vector<Real>>> &emul,
141  const std::vector<Ptr<Constraint<Real>>> &icon,
142  const std::vector<Ptr<Vector<Real>>> &imul,
143  const std::vector<Ptr<BoundConstraint<Real>>> &ibnd ) {
144  if (!isInitialized_) {
145  int esize = static_cast<int>(econ.size());
146  int isize = static_cast<int>(icon.size());
147  std::vector<Ptr<Constraint<Real>>> cvec;
148  std::vector<Ptr<Vector<Real>>> lvec;
149  std::vector<Ptr<BoundConstraint<Real>>> bvec;
150  for (int i = 0; i < esize; ++i) {
151  if ( econ[i] != nullPtr ) {
152  if (isStochastic_) {
153  cvec.push_back(setRiskLessCon(econ[i],needRiskLessEcon_[i]));
154  }
155  else {
156  cvec.push_back(econ[i]);
157  }
158  lvec.push_back(emul[i]);
159  bvec.push_back(nullPtr);
160  }
161  }
162  for (int i = 0; i < isize; ++i) {
163  if ( icon[i] != nullPtr ) {
164  if (isStochastic_) {
165  cvec.push_back(setRiskLessCon(icon[i],needRiskLessIcon_[i]));
166  }
167  else {
168  cvec.push_back(icon[i]);
169  }
170  lvec.push_back(imul[i]);
171  bvec.push_back(ibnd[i]);
172  }
173  }
174 
175  conManager_ = makePtr<ConstraintManager<Real>>(cvec,lvec,bvec,x,bnd);
176  con_ = conManager_->getConstraint();
177  mul_ = conManager_->getMultiplier();
178  sol_ = conManager_->getOptVector();
179  bnd_ = conManager_->getBoundConstraint();
180  Ptr<Objective<Real>> obj0;
181  if (isStochastic_) {
182  obj0 = setRiskLessObj(obj,needRiskLessObj_);
183  }
184  else {
185  obj0 = obj;
186  }
187  if ( conManager_->hasInequality() ) {
188  obj_ = makePtr<SlacklessObjective<Real>>(obj0);
189  }
190  else {
191  obj_ = obj0;
192  }
193 
194  if ( conManager_->isNull() ) {
195  if( bnd_ == nullPtr || !bnd_->isActivated() ) { // Type-U
196  problemType_ = TYPE_U;
197  }
198  else { // Type-B
199  problemType_ = TYPE_B;
200  }
201  }
202  else {
203  if( bnd_ == nullPtr || !bnd_->isActivated() ) { // Type-E
204  problemType_ = TYPE_E;
205  }
206  else { // Type-EB
208  }
209  }
210  isInitialized_ = true;
211  }
212  }
213 
214  const Ptr<Constraint<Real>> setRiskLessCon(const Ptr<Constraint<Real>> &con, const bool needRiskLess) const {
215  if (needRiskLess) {
216  return makePtr<RiskLessConstraint<Real>>(con);
217  }
218  else {
219  return con;
220  }
221  }
222 
223  const Ptr<Objective<Real>> setRiskLessObj(const Ptr<Objective<Real>> &obj, const bool needRiskLess) const {
224  if (needRiskLess) {
225  return makePtr<RiskLessObjective<Real>>(obj);
226  }
227  else {
228  return obj;
229  }
230  }
231 
232  std::vector<Real> computeSampleMean(const Ptr<SampleGenerator<Real>> &sampler) const {
233  // Compute mean value of inputs and set parameter in objective
234  int dim = sampler->getMyPoint(0).size(), nsamp = sampler->numMySamples();
235  std::vector<Real> loc(dim), mean(dim), pt(dim);
236  Real wt(0);
237  for (int i = 0; i < nsamp; i++) {
238  pt = sampler->getMyPoint(i);
239  wt = sampler->getMyWeight(i);
240  for (int j = 0; j < dim; j++) {
241  loc[j] += wt*pt[j];
242  }
243  }
244  sampler->sumAll(&loc[0],&mean[0],dim);
245  return mean;
246  }
247 
248  void initStochastic(void) {
249  if (!isStochastic_) {
250  int econSize = INPUT_econ_.size();
251  int iconSize = INPUT_icon_.size();
252  needRiskLessObj_ = true;
253  needRiskLessEcon_.clear(); needRiskLessEcon_.resize(econSize,true);
254  needRiskLessIcon_.clear(); needRiskLessIcon_.resize(iconSize,true);
255  parlistObj_ = nullPtr;
256  parlistCon_.clear(); parlistCon_.resize(iconSize,nullPtr);
257 
258  exsampler_.clear(); exsampler_.resize(econSize,nullPtr);
259  ecbman_.clear(); ecbman_.resize(econSize,nullPtr);
260 
261  ixsampler_.clear(); ixsampler_.resize(iconSize,nullPtr);
262  icbman_.clear(); icbman_.resize(iconSize,nullPtr);
263 
264  isStochastic_ = true;
265  }
266  }
267 
268  void buildRiskVec(Ptr<Vector<Real>> &x) {
269  // Build risk vector and risk bound constraint
271  = makePtr<RiskVector<Real>>(parlistObj_,parlistCon_,x);
272  if (parlistObj_ != nullPtr) {
273  Real statObj = parlistObj_->sublist("SOL").get("Initial Statistic",1.0);
274  dynamicPtrCast<RiskVector<Real>>(INTERMEDIATE_sol_)->setStatistic(statObj,0);
275  }
276  int nc = INPUT_icon_.size();
277  for (int i = 0; i < nc; ++i) {
278  if (parlistCon_[i] != nullPtr) {
279  Real statCon = parlistCon_[i]->sublist("SOL").get("Initial Statistic",1.0);
280  dynamicPtrCast<RiskVector<Real>>(INTERMEDIATE_sol_)->setStatistic(statCon,1,i);
281  }
282  }
283  }
284 
286  if ( INPUT_bnd_ != nullPtr ) {
288  = makePtr<RiskBoundConstraint<Real>>(parlistObj_,parlistCon_,bnd);
289  }
290  }
291 
292 public:
293  virtual ~OptimizationProblem(void) {}
294 
295  // Default constructor [0]
297  : isInitialized_(false), isStochastic_(false) {}
298 
299  // Complete option constructor [1]
301  const Ptr<Vector<Real>> &x,
302  const Ptr<BoundConstraint<Real>> &bnd,
303  const std::vector<Ptr<Constraint<Real>>> &econ,
304  const std::vector<Ptr<Vector<Real>>> &emul,
305  const std::vector<Ptr<Constraint<Real>>> &icon,
306  const std::vector<Ptr<Vector<Real>>> &imul,
307  const std::vector<Ptr<BoundConstraint<Real>>> &ibnd )
308  : INPUT_obj_(obj), INPUT_sol_(x), INPUT_bnd_(bnd),
309  INPUT_econ_(econ), INPUT_emul_(emul),
310  INPUT_icon_(icon), INPUT_imul_(imul), INPUT_ibnd_(ibnd),
314  isInitialized_(false), isStochastic_(false) {}
315 
317  const Ptr<Vector<Real>> &x,
318  const Ptr<BoundConstraint<Real>> &bnd,
319  const Ptr<Constraint<Real>> &econ,
320  const Ptr<Vector<Real>> &emul,
321  const std::vector<Ptr<Constraint<Real>>> &icon,
322  const std::vector<Ptr<Vector<Real>>> &imul,
323  const std::vector<Ptr<BoundConstraint<Real>>> &ibnd )
324  : INPUT_obj_(obj), INPUT_sol_(x), INPUT_bnd_(bnd),
325  INPUT_icon_(icon), INPUT_imul_(imul), INPUT_ibnd_(ibnd),
328  isInitialized_(false), isStochastic_(false) {
329  std::vector<Ptr<Constraint<Real>>> econ0(1,econ);
330  std::vector<Ptr<Vector<Real>>> emul0(1,emul);
331  INPUT_econ_ = econ0;
332  INPUT_emul_ = emul0;
333  INTERMEDIATE_econ_ = econ0;
334  INTERMEDIATE_emul_ = emul0;
335  }
336 
338  const Ptr<Vector<Real>> &x,
339  const Ptr<BoundConstraint<Real>> &bnd,
340  const std::vector<Ptr<Constraint<Real>>> &econ,
341  const std::vector<Ptr<Vector<Real>>> &emul,
342  const Ptr<Constraint<Real>> &icon,
343  const Ptr<Vector<Real>> &imul,
344  const Ptr<BoundConstraint<Real>> &ibnd )
345  : INPUT_obj_(obj), INPUT_sol_(x), INPUT_bnd_(bnd),
346  INPUT_econ_(econ), INPUT_emul_(emul),
349  isInitialized_(false), isStochastic_(false) {
350  std::vector<Ptr<Constraint<Real>>> icon0(1,icon);
351  std::vector<Ptr<Vector<Real>>> imul0(1,imul);
352  std::vector<Ptr<BoundConstraint<Real>>> ibnd0(1,ibnd);
353  INPUT_icon_ = icon0;
354  INPUT_imul_ = imul0;
355  INPUT_ibnd_ = ibnd0;
356  INTERMEDIATE_icon_ = icon0;
357  INTERMEDIATE_imul_ = imul0;
358  INTERMEDIATE_ibnd_ = ibnd0;
359  }
360 
362  const Ptr<Vector<Real>> &x,
363  const Ptr<BoundConstraint<Real>> &bnd,
364  const Ptr<Constraint<Real>> &econ,
365  const Ptr<Vector<Real>> &emul,
366  const Ptr<Constraint<Real>> &icon,
367  const Ptr<Vector<Real>> &imul,
368  const Ptr<BoundConstraint<Real>> &ibnd )
369  : INPUT_obj_(obj), INPUT_sol_(x), INPUT_bnd_(bnd),
371  isInitialized_(false), isStochastic_(false) {
372  std::vector<Ptr<Constraint<Real>>> econ0(1,econ);
373  std::vector<Ptr<Vector<Real>>> emul0(1,emul);
374  std::vector<Ptr<Constraint<Real>>> icon0(1,icon);
375  std::vector<Ptr<Vector<Real>>> imul0(1,imul);
376  std::vector<Ptr<BoundConstraint<Real>>> ibnd0(1,ibnd);
377  INPUT_econ_ = econ0;
378  INPUT_emul_ = emul0;
379  INPUT_icon_ = icon0;
380  INPUT_imul_ = imul0;
381  INPUT_ibnd_ = ibnd0;
382  INTERMEDIATE_econ_ = econ0;
383  INTERMEDIATE_emul_ = emul0;
384  INTERMEDIATE_icon_ = icon0;
385  INTERMEDIATE_imul_ = imul0;
386  INTERMEDIATE_ibnd_ = ibnd0;
387  }
388 
389  // No bound constuctor [2]
391  const Ptr<Vector<Real>> &x,
392  const std::vector<Ptr<Constraint<Real>>> &econ,
393  const std::vector<Ptr<Vector<Real>>> &emul,
394  const std::vector<Ptr<Constraint<Real>>> &icon,
395  const std::vector<Ptr<Vector<Real>>> &imul,
396  const std::vector<Ptr<BoundConstraint<Real>>> &ibnd )
397  : OptimizationProblem( obj, x, nullPtr, econ, emul, icon, imul, ibnd ) {}
398 
400  const Ptr<Vector<Real>> &x,
401  const Ptr<Constraint<Real>> &econ,
402  const Ptr<Vector<Real>> &emul,
403  const std::vector<Ptr<Constraint<Real>>> &icon,
404  const std::vector<Ptr<Vector<Real>>> &imul,
405  const std::vector<Ptr<BoundConstraint<Real>>> &ibnd )
406  : OptimizationProblem( obj, x, nullPtr, econ, emul, icon, imul, ibnd) {}
407 
409  const Ptr<Vector<Real>> &x,
410  const std::vector<Ptr<Constraint<Real>>> &econ,
411  const std::vector<Ptr<Vector<Real>>> &emul,
412  const Ptr<Constraint<Real>> &icon,
413  const Ptr<Vector<Real>> &imul,
414  const Ptr<BoundConstraint<Real>> &ibnd )
415  : OptimizationProblem( obj, x, nullPtr, econ, emul, icon, imul, ibnd) {}
416 
418  const Ptr<Vector<Real>> &x,
419  const Ptr<Constraint<Real>> &econ,
420  const Ptr<Vector<Real>> &emul,
421  const Ptr<Constraint<Real>> &icon,
422  const Ptr<Vector<Real>> &imul,
423  const Ptr<BoundConstraint<Real>> &ibnd )
424  : OptimizationProblem( obj, x, nullPtr, econ, emul, icon, imul, ibnd) {}
425 
426  // No inequality constraint [3]
428  const Ptr<Vector<Real>> &x,
429  const Ptr<BoundConstraint<Real>> &bnd,
430  const std::vector<Ptr<Constraint<Real>>> &econ,
431  const std::vector<Ptr<Vector<Real>>> &emul )
432  : OptimizationProblem( obj, x, bnd, econ, emul, nullPtr, nullPtr, nullPtr ) {}
433 
435  const Ptr<Vector<Real>> &x,
436  const Ptr<BoundConstraint<Real>> &bnd,
437  const Ptr<Constraint<Real>> &econ,
438  const Ptr<Vector<Real>> &emul )
439  : OptimizationProblem( obj, x, bnd, econ, emul, nullPtr, nullPtr, nullPtr) {}
440 
441  // No equality constraint [4]
443  const Ptr<Vector<Real>> &x,
444  const Ptr<BoundConstraint<Real>> &bnd,
445  const std::vector<Ptr<Constraint<Real>>> &icon,
446  const std::vector<Ptr<Vector<Real>>> &imul,
447  const std::vector<Ptr<BoundConstraint<Real>>> &ibnd )
448  : OptimizationProblem( obj, x, bnd, nullPtr, nullPtr, icon, imul, ibnd ) {}
449 
451  const Ptr<Vector<Real>> &x,
452  const Ptr<BoundConstraint<Real>> &bnd,
453  const Ptr<Constraint<Real>> &icon,
454  const Ptr<Vector<Real>> &imul,
455  const Ptr<BoundConstraint<Real>> &ibnd )
456  : OptimizationProblem( obj, x, bnd, nullPtr, nullPtr, icon, imul, ibnd) {}
457 
458  // No inequality or bound constraint [5]
460  const Ptr<Vector<Real>> &x,
461  const std::vector<Ptr<Constraint<Real>>> &econ,
462  const std::vector<Ptr<Vector<Real>>> &emul )
463  : OptimizationProblem( obj, x, nullPtr, econ, emul, nullPtr, nullPtr, nullPtr ) {}
464 
466  const Ptr<Vector<Real>> &x,
467  const Ptr<Constraint<Real>> &econ,
468  const Ptr<Vector<Real>> &emul )
469  : OptimizationProblem( obj, x, nullPtr, econ, emul, nullPtr, nullPtr, nullPtr) {}
470 
471  // No equality or bound constraint [6]
473  const Ptr<Vector<Real>> &x,
474  const std::vector<Ptr<Constraint<Real>>> &icon,
475  const std::vector<Ptr<Vector<Real>>> &imul,
476  const std::vector<Ptr<BoundConstraint<Real>>> &ibnd )
477  : OptimizationProblem( obj, x, nullPtr, nullPtr, nullPtr, icon, imul, ibnd ) {}
478 
480  const Ptr<Vector<Real>> &x,
481  const Ptr<Constraint<Real>> &icon,
482  const Ptr<Vector<Real>> &imul,
483  const Ptr<BoundConstraint<Real>> &ibnd )
484  : OptimizationProblem( obj, x, nullPtr, nullPtr, nullPtr, icon, imul, ibnd) {}
485 
486  // Bound constrained problem [7]
488  const Ptr<Vector<Real>> &x,
489  const Ptr<BoundConstraint<Real>> &bnd )
490  : OptimizationProblem( obj, x, bnd, nullPtr, nullPtr, nullPtr, nullPtr, nullPtr ) {}
491 
492  // Unconstrained problem [8]
494  const Ptr<Vector<Real>> &x ) :
495  OptimizationProblem( obj, x, nullPtr, nullPtr, nullPtr, nullPtr, nullPtr, nullPtr ) {}
496 
497  /* Get methods */
498 
499  virtual Ptr<Objective<Real>> getObjective(void) {
500  if ( INTERMEDIATE_obj_ == nullPtr ) {
501  throw Exception::NotImplemented(">>> ROL::OptimizationProblem::getObjective: No objective inputed!");
502  }
506  return obj_;
507  }
508 
509  virtual Ptr<Vector<Real>> getSolutionVector(void) {
510  if ( INTERMEDIATE_sol_ == nullPtr ) {
511  throw Exception::NotImplemented(">>> ROL::OptimizationProblem::getSolutionVector: No solution vector inputed!");
512  }
516  return sol_;
517  }
518 
519  virtual Ptr<BoundConstraint<Real>> getBoundConstraint(void) {
523  return bnd_;
524  }
525 
526  virtual Ptr<Constraint<Real>> getConstraint(void) {
530  return con_;
531  }
532 
533  virtual Ptr<Vector<Real>> getMultiplierVector(void) {
537  return mul_;
538  }
539 
544  return problemType_;
545  }
546 
547  /* Set Stochastic Methods */
548 
549  /* Objective function */
560  void setMeanValueObjective(const Ptr<SampleGenerator<Real>> &sampler) {
561  initStochastic();
562  // Set objective function samplers
563  vsampler_ = sampler;
564  gsampler_ = sampler;
565  hsampler_ = sampler;
566  // Construct risk-averse/probabilistic objective function
567  if ( vsampler_ == nullPtr ) {
568  throw Exception::NotImplemented(">>> ROL::OptimizationProblem::setMeanValueObjective: Objective function value sampler is null!");
569  }
570  else {
571  std::vector<Real> mean = computeSampleMean(vsampler_);
573  INTERMEDIATE_obj_->setParameter(mean);
574  }
575  // Set vector and bound constraint
578 
579  isInitialized_ = false;
580  }
581 
595  const Ptr<SampleGenerator<Real>> &gsampler = nullPtr,
596  const Ptr<SampleGenerator<Real>> &hsampler = nullPtr,
597  const bool storage = true) {
598  initStochastic();
599  // Set objective function samplers
600  vsampler_ = vsampler;
601  gsampler_ = gsampler;
602  hsampler_ = hsampler;
603  if ( gsampler == nullPtr ) {
605  }
606  if ( hsampler == nullPtr ) {
608  }
609  // Construct risk-averse/probabilistic objective function
610  if ( vsampler_ == nullPtr ) {
611  throw Exception::NotImplemented(">>> ROL::OptimizationProblem::setRiskNeutralObjective: Objective function value sampler is null!");
612  }
613  else {
615  = makePtr<RiskNeutralObjective<Real>>(INPUT_obj_,vsampler_,gsampler_,hsampler_,storage);
616  }
617  // Set vector and bound constraint
620 
621  isInitialized_ = false;
622  }
623 
636  void setRiskAverseObjective(ParameterList &parlist,
637  const Ptr<SampleGenerator<Real>> &vsampler,
638  const Ptr<SampleGenerator<Real>> &gsampler = nullPtr,
639  const Ptr<SampleGenerator<Real>> &hsampler = nullPtr) {
640  initStochastic();
641  // Set objective function samplers
642  vsampler_ = vsampler;
643  gsampler_ = gsampler;
644  hsampler_ = hsampler;
645  if ( gsampler == nullPtr ) {
647  }
648  if ( hsampler == nullPtr ) {
650  }
651  // Construct risk-averse/probabilistic objective function
652  if ( vsampler_ == nullPtr ) {
653  throw Exception::NotImplemented(">>> ROL::OptimizationProblem::setRiskAverseObjective: Objective function value sampler is null!");
654  }
655  else {
656  needRiskLessObj_ = false;
657  parlistObj_ = makePtrFromRef(parlist);
659  = makePtr<StochasticObjective<Real>>(INPUT_obj_,parlist,vsampler_,gsampler_,hsampler_);
660  }
661  // Set vector and bound constraint
664 
665  isInitialized_ = false;
666  }
667 
668  void setStochasticObjective(ParameterList &parlist,
669  const Ptr<SampleGenerator<Real>> &vsampler,
670  const Ptr<SampleGenerator<Real>> &gsampler = nullPtr,
671  const Ptr<SampleGenerator<Real>> &hsampler = nullPtr) {
672  // Determine Stochastic Objective Type
673  std::string type = parlist.sublist("SOL").get("Stochastic Component Type","Risk Neutral");
674  if ( type == "Risk Neutral" ) {
675  bool storage = parlist.sublist("SOL").get("Store Sampled Value and Gradient",true);
676  setRiskNeutralObjective(vsampler,gsampler,hsampler,storage);
677  }
678  else if ( type == "Risk Averse" ||
679  type == "Deviation" ||
680  type == "Error" ||
681  type == "Regret" ||
682  type == "Probability" ) {
683  setRiskAverseObjective(parlist,vsampler,gsampler,hsampler);
684  }
685  else if ( type == "Mean Value" ) {
686  setMeanValueObjective(vsampler);
687  }
688  else {
689  throw Exception::NotImplemented(">>> ROL::OptimizationProblem::setStochasticObjective: Invalid stochastic optimization type!");
690  }
691  // Set vector and bound constraint
694 
695  isInitialized_ = false;
696  }
697 
698  /* Equality Constraint */
699  void setMeanValueEquality(const Ptr<SampleGenerator<Real>> &sampler, const int index = 0) {
700  initStochastic();
701  exsampler_[index] = sampler;
702  if ( INPUT_econ_[index] != nullPtr && sampler != nullPtr ) {
703  std::vector<Real> mean = computeSampleMean(sampler);
704  INTERMEDIATE_econ_[index] = INPUT_econ_[index];
705  INTERMEDIATE_econ_[index]->setParameter(mean);
706  INTERMEDIATE_emul_[index] = INPUT_emul_[index];
707  }
708  else {
709  throw Exception::NotImplemented(">>> ROL::OptimizationProblem::setMeanValueEquality: Either SampleGenerator or Constraint is NULL!");
710  }
711  // Set vector and bound constraint
714 
715  isInitialized_ = false;
716  }
717 
719  const Ptr<BatchManager<Real>> &cbman,
720  const int index = 0) {
721  initStochastic();
722  exsampler_[index] = xsampler;
723  ecbman_[index] = cbman;
724  if ( INPUT_econ_[index] != nullPtr
725  && xsampler != nullPtr
726  && cbman != nullPtr ) {
727  INTERMEDIATE_econ_[index]
728  = makePtr<RiskNeutralConstraint<Real>>(INPUT_econ_[index],xsampler,cbman);
729  INTERMEDIATE_emul_[index] = INPUT_emul_[index];
730  }
731  else {
732  throw Exception::NotImplemented(">>> ROL::OptimizationProblem::SetRiskNeutralEquality: Either SampleGenerator, Constraint or BatchManager is NULL!");
733  }
734  // Set vector and bound constraint
737 
738  isInitialized_ = false;
739  }
740 
742  const int index = 0) {
743  initStochastic();
744  exsampler_[index] = sampler;
745  if ( INPUT_econ_[index] != nullPtr && sampler != nullPtr ) {
746  int nsamp = sampler->numMySamples();
747  INTERMEDIATE_econ_[index]
748  = makePtr<AlmostSureConstraint<Real>>(sampler,INPUT_econ_[index]);
749  std::vector<Ptr<Vector<Real>>> emul(nsamp,nullPtr);
750  for (int j = 0; j < nsamp; ++j) {
751  emul[j] = INPUT_emul_[index]->clone();
752  emul[j]->set(*INPUT_emul_[index]);
753  }
754  INTERMEDIATE_emul_[index]
755  = makePtr<DualSimulatedVector<Real>>(emul, sampler->getBatchManager(), sampler);
756  }
757  else {
758  throw Exception::NotImplemented(">>> ROL::OptimizationProblem::SetAlmostSureEquality: Either SampleGenerator or Constraint is NULL!");
759  }
760  // Set vector and bound constraint
763 
764  isInitialized_ = false;
765  }
766 
767 
768  void setStochasticEquality(std::vector<ParameterList> &parlist,
769  const std::vector<Ptr<SampleGenerator<Real>>> &xsampler,
770  const std::vector<Ptr<BatchManager<Real>>> &cbman) {
771  initStochastic();
772  int nc = static_cast<int>(INPUT_econ_.size());
773  if ( nc != static_cast<int>(xsampler.size()) || nc != static_cast<int>(cbman.size()) ) {
774  throw Exception::NotImplemented(">>> ROL::OptimizationProblem::setStochasticEquality: Constraint vector and SampleGenerator vector are not the same size!");
775  }
776  for (int i = 0; i < nc; ++i) {
777  if (xsampler[i] != nullPtr) {
778  std::string type = parlist[i].sublist("SOL").get("Stochastic Component Type","Risk Neutral");
779  if ( type == "Risk Neutral" ) {
780  setRiskNeutralEquality(xsampler[i],cbman[i],i);
781  }
782  else if ( type == "Almost Sure" ) {
783  setAlmostSureEquality(xsampler[i],i);
784  }
785  else if ( type == "Mean Value" ) {
786  setMeanValueEquality(xsampler[i],i);
787  }
788  else {
789  throw Exception::NotImplemented(">>> ROL::OptimizationProblem::SetStochasticEquality: Invalid stochastic constraint type!");
790  }
791  }
792  else {
795  }
796  }
797  // Set vector and bound constraint
800 
801  isInitialized_ = false;
802  }
803 
804  void setStochasticEquality(ParameterList &parlist,
805  const Ptr<SampleGenerator<Real>> &xsampler,
806  const Ptr<BatchManager<Real>> &cbman) {
807  std::vector<ParameterList> cparlist(1,parlist);
808  std::vector<Ptr<SampleGenerator<Real>>> cxsampler(1,xsampler);
809  std::vector<Ptr<BatchManager<Real>>> ccbman(1,cbman);
810  setStochasticEquality(cparlist,cxsampler,ccbman);
811  }
812 
813  /* Inequality constraint */
815  const int index = 0) {
816  initStochastic();
817  ixsampler_[index] = sampler;
818  if ( INPUT_icon_[index] != nullPtr && sampler != nullPtr ) {
819  std::vector<Real> mean = computeSampleMean(sampler);
820  INTERMEDIATE_icon_[index] = INPUT_icon_[index];
821  INTERMEDIATE_icon_[index]->setParameter(mean);
822  INTERMEDIATE_ibnd_[index] = INPUT_ibnd_[index];
823  INTERMEDIATE_imul_[index] = INPUT_imul_[index];
824  }
825  else {
826  throw Exception::NotImplemented(">>> ROL::OptimizationProblem::SetMeanValueInequality: Either Constraint or SampleGenerator is NULL!");
827  }
828  // Set vector and bound constraint
831 
832  isInitialized_ = false;
833  }
834 
836  const Ptr<BatchManager<Real>> &cbman,
837  const int index = 0) {
838  initStochastic();
839  ixsampler_[index] = xsampler;
840  icbman_[index] = cbman;
841  if ( INPUT_icon_[index] != nullPtr
842  && xsampler != nullPtr
843  && cbman != nullPtr ) {
844  INTERMEDIATE_icon_[index]
845  = makePtr<RiskNeutralConstraint<Real>>(INPUT_icon_[index],xsampler,cbman);
846  INTERMEDIATE_ibnd_[index] = INPUT_ibnd_[index];
847  INTERMEDIATE_imul_[index] = INPUT_imul_[index];
848  }
849  else {
850  throw Exception::NotImplemented(">>> ROL::OptimizationProblem::SetRiskNeutralInequality: Either Constraint, SampleGenerator or BatchManager is NULL!");
851  }
852  // Set vector and bound constraint
855 
856  isInitialized_ = false;
857  }
858 
859  void setRiskAverseInequality(ParameterList &parlist,
860  const Ptr<SampleGenerator<Real>> &sampler,
861  const int index = 0) {
862  initStochastic();
863  ixsampler_[index] = sampler;
864  if ( INPUT_icon_[index] != nullPtr && sampler != nullPtr ) {
865  needRiskLessIcon_[index] = false;
866  parlistCon_[index] = makePtrFromRef(parlist);
867  INTERMEDIATE_icon_[index]
868  = makePtr<StochasticConstraint<Real>>(INPUT_icon_[index],sampler,parlist,index);
869  INTERMEDIATE_ibnd_[index] = INPUT_ibnd_[index];
870  INTERMEDIATE_imul_[index] = INPUT_imul_[index];
871  }
872  else {
873  throw Exception::NotImplemented(">>> ROL::OptimizationProblem::SetRiskAverseInequality: Either Constraint or SampleGenerator is NULL!");
874  }
875  // Set vector and bound constraint
878 
879  isInitialized_ = false;
880  }
881 
883  const int index = 0) {
884  initStochastic();
885  ixsampler_[index] = sampler;
886  if ( INPUT_icon_[index] != nullPtr && sampler != nullPtr ) {
887  int nsamp = sampler->numMySamples();
888  INTERMEDIATE_icon_[index]
889  = makePtr<AlmostSureConstraint<Real>>(sampler, INPUT_icon_[index]);
890  std::vector<Ptr<Vector<Real>>> imul(nsamp,nullPtr);
891  for (int j = 0; j < nsamp; ++j) {
892  imul[j] = INPUT_imul_[index]->clone();
893  imul[j]->set(*INPUT_imul_[index]);
894  }
895  INTERMEDIATE_imul_[index]
896  = makePtr<DualSimulatedVector<Real>>(imul, sampler->getBatchManager(), sampler);
897  INTERMEDIATE_ibnd_[index]
898  = makePtr<SimulatedBoundConstraint<Real>>(sampler, INPUT_ibnd_[index]);
899  }
900  else {
901  throw Exception::NotImplemented(">>> ROL::OptimizationProblem::SetAlmostSureInequality: Either Constraint or SampleGenerator is NULL!");
902  }
903  // Set vector and bound constraint
906 
907  isInitialized_ = false;
908  }
909 
910  void setStochasticInequality(std::vector<ParameterList> &parlist,
911  const std::vector<Ptr<SampleGenerator<Real>>> &xsampler,
912  const std::vector<Ptr<BatchManager<Real>>> &cbman) {
913  initStochastic();
914  int nc = static_cast<int>(INPUT_icon_.size());
915  if ( nc != static_cast<int>(xsampler.size()) || nc != static_cast<int>(cbman.size()) ) {
916  throw Exception::NotImplemented(">>> ROL::OptimizationProblem::setStochasticInequality: Constraint vector and SampleGenerator vector are not the same size!");
917  }
918  for (int i = 0; i < nc; ++i) {
919  if ( xsampler[i] != nullPtr ) {
920  std::string type = parlist[i].sublist("SOL").get("Stochastic Component Type","Risk Neutral");
921  if ( type == "Risk Neutral" ) {
922  setRiskNeutralInequality(xsampler[i],cbman[i],i);
923  }
924  else if ( type == "Risk Averse" ||
925  type == "Deviation" ||
926  type == "Error" ||
927  type == "Regret" ||
928  type == "Probability" ) {
929  setRiskAverseInequality(parlist[i],xsampler[i],i);
930  }
931  else if ( type == "Almost Sure" ) {
932  setAlmostSureInequality(xsampler[i],i);
933  }
934  else if ( type == "Mean Value" ) {
935  setMeanValueInequality(xsampler[i],i);
936  }
937  else {
938  throw Exception::NotImplemented(">>> ROL::OptimizationProblem::SetStochasticInequality: Invalid stochastic constraint type!");
939  }
940  }
941  else {
945  }
946  }
947  // Set vector and bound constraint
950 
951  isInitialized_ = false;
952  }
953 
954  void setStochasticInequality(ParameterList &parlist,
955  const Ptr<SampleGenerator<Real>> &xsampler,
956  const Ptr<BatchManager<Real>> &cbman) {
957  std::vector<ParameterList> cparlist(1,parlist);
958  std::vector<Ptr<SampleGenerator<Real>>> cxsampler(1,xsampler);
959  std::vector<Ptr<BatchManager<Real>>> ccbman(1,cbman);
960  setStochasticInequality(cparlist,cxsampler,ccbman);
961  }
962 
968  Real getSolutionStatistic(int comp = 0, int index = 0) {
969  Real val(0);
970  if (comp == 0) {
971  try {
972  val = dynamicPtrCast<StochasticObjective<Real>>(INTERMEDIATE_obj_)->computeStatistic(*INTERMEDIATE_sol_);
973  }
974  catch (std::exception &e) {
975  throw Exception::NotImplemented(">>> ROL::OptimizationProblem::getSolutionStatistic: Objective does not have computeStatistic function!");
976  }
977  }
978  else if (comp == 1) {
979  int np = INTERMEDIATE_icon_.size();
980  if (np <= index || index < 0) {
981  throw Exception::NotImplemented(">>> ROL::OptimizationProblem::getSolutionStatistic: Index out of bounds!");
982  }
983  try {
984  val = dynamicPtrCast<StochasticConstraint<Real>>(INTERMEDIATE_icon_[index])->computeStatistic(*INTERMEDIATE_sol_);
985  }
986  catch (std::exception &e) {
987  throw Exception::NotImplemented(">>> ROL::OptimizationProblem::getSolutionStatistic: Constraint does not have computeStatistic function!");
988  }
989  }
990  else {
991  throw Exception::NotImplemented(">>> ROL::OptimizationProblem::getSolutionStatistic: Component must be either 0 or 1!");
992  }
993  return val;
994  }
995 
996  std::vector<Real> getObjectiveStatistic(void) const {
997  try {
998  Ptr<std::vector<Real>> stat
999  = dynamicPtrCast<RiskVector<Real>>(INTERMEDIATE_sol_)->getStatistic();
1000  if (stat != nullPtr) {
1001  return *stat;
1002  }
1003  else {
1004  std::vector<Real> empty;
1005  return empty;
1006  }
1007  }
1008  catch (std::exception &e) {
1009  std::vector<Real> empty;
1010  return empty;
1011  }
1012  }
1013 
1014  std::vector<Real> getConstraintStatistic(const int index = 0) const {
1015  try {
1016  Ptr<std::vector<Real>> stat
1017  = dynamicPtrCast<RiskVector<Real>>(INTERMEDIATE_sol_)->getStatistic(1,index);
1018  if (stat != nullPtr) {
1019  return *stat;
1020  }
1021  else {
1022  std::vector<Real> empty;
1023  return empty;
1024  }
1025  }
1026  catch (std::exception &e) {
1027  std::vector<Real> empty;
1028  return empty;
1029  }
1030  }
1031 
1032  void reset(void) {
1036  conManager_->resetSlackVariables();
1037  }
1038 
1039  // Check derivatives, and consistency
1040  void checkSolutionVector( Vector<Real> &x, // Optimization space
1041  Vector<Real> &y, // Optimization space
1042  Vector<Real> &u, // Optimization space
1043  std::ostream &outStream = std::cout ) {
1045  checkSolutionVector(data,x,y,u,outStream);
1046 
1047  }
1048 
1050  Vector<Real> &x, // Optimization space
1051  Vector<Real> &y, // Optimization space
1052  Vector<Real> &u, // Optimization space
1053  std::ostream &outStream = std::cout ) {
1057  if (obj_ != nullPtr) {
1058  outStream << "\nPerforming OptimizationProblem diagnostics." << std::endl << std::endl;
1059 
1060  outStream << "Checking vector operations in optimization vector space X." << std::endl;
1061  data.checkSolutionVector = x.checkVector(y,u,true,outStream);
1062  }
1063  }
1064 
1065  void checkObjective( Vector<Real> &x, // Optimization space
1066  Vector<Real> &u, // Optimization space
1067  Vector<Real> &v, // Optimization space
1068  std::ostream &outStream = std::cout,
1069  const int numSteps = ROL_NUM_CHECKDERIV_STEPS,
1070  const int order = 1 ) {
1072  checkObjective(data,x,u,v,outStream,numSteps,order);
1073  }
1074 
1076  Vector<Real> &x, // Optimization space
1077  Vector<Real> &u, // Optimization space
1078  Vector<Real> &v, // Optimization space
1079  std::ostream &outStream = std::cout,
1080  const int numSteps = ROL_NUM_CHECKDERIV_STEPS,
1081  const int order = 1 ) {
1085  if (obj_ != nullPtr) {
1086  outStream << std::endl << "Performing OptimizationProblem diagnostics."
1087  << std::endl << std::endl;
1088  outStream << "Checking objective function." << std::endl;
1089  data.checkGradient = obj_->checkGradient(x,v,true,outStream,numSteps,order);
1090  outStream << std::endl;
1091  data.checkHessVec = obj_->checkHessVec(x,u,true,outStream,numSteps,order);
1092  outStream << std::endl;
1093  data.checkHessSym = obj_->checkHessSym(x,u,v,true,outStream);
1094  outStream << std::endl;
1095  }
1096  }
1097 
1098  void checkMultiplierVector( Vector<Real> &w, // Dual constraint space
1099  Vector<Real> &q, // Dual constraint space
1100  Vector<Real> &l, // Dual constraint space
1101  std::ostream &outStream = std::cout ) {
1103  checkMultiplierVector(data,w,q,l,outStream);
1104  }
1105 
1107  Vector<Real> &w, // Dual constraint space
1108  Vector<Real> &q, // Dual constraint space
1109  Vector<Real> &l, // Dual constraint space
1110  std::ostream &outStream = std::cout ) {
1114  if(con_ != nullPtr) {
1115  outStream << "\nPerforming OptimizationProblem diagnostics." << std::endl << std::endl;
1116 
1117  outStream << "Checking vector operations in constraint multiplier space C*." << std::endl;
1118  data.checkMultiplierVector = l.checkVector(q,w,true,outStream);
1119  }
1120  }
1121 
1122  void checkConstraint( Vector<Real> &x, // Optimization space
1123  Vector<Real> &u, // Optimization space
1124  Vector<Real> &v, // Optimization space
1125  Vector<Real> &c, // Constraint space
1126  Vector<Real> &l, // Dual constraint space
1127  std::ostream &outStream = std::cout,
1128  const int numSteps = ROL_NUM_CHECKDERIV_STEPS,
1129  const int order = 1 ) {
1131  checkConstraint(data,x,u,v,c,l,outStream,numSteps,order);
1132  }
1133 
1135  Vector<Real> &x, // Optimization space
1136  Vector<Real> &u, // Optimization space
1137  Vector<Real> &v, // Optimization space
1138  Vector<Real> &c, // Constraint space
1139  Vector<Real> &l, // Dual constraint space
1140  std::ostream &outStream = std::cout,
1141  const int numSteps = ROL_NUM_CHECKDERIV_STEPS,
1142  const int order = 1 ) {
1146  if(con_ != nullPtr) {
1147  outStream << "\nPerforming OptimizationProblem diagnostics." << std::endl << std::endl;
1148 
1149  outStream << "Checking equality constraint." << std::endl;
1150  data.checkApplyJacobian = con_->checkApplyJacobian(x,v,c,true,outStream,numSteps,order);
1151  outStream << std::endl;
1152  data.checkAdjointConsistencyJacobian = con_->checkAdjointConsistencyJacobian(l,u,x,true,outStream);
1153  outStream << std::endl;
1154  data.checkApplyAdjointHessian = con_->checkApplyAdjointHessian(x,l,v,u,true,outStream,numSteps,order);
1155  outStream << std::endl;
1156  }
1157  }
1158 
1159  // Check derivatives, and consistency
1160  void check( std::ostream &outStream = std::cout,
1161  const int numSteps = ROL_NUM_CHECKDERIV_STEPS,
1162  const int order = 1 ) {
1164  check(data,outStream,numSteps,order);
1165  }
1166 
1168  std::ostream &outStream = std::cout,
1169  const int numSteps = ROL_NUM_CHECKDERIV_STEPS,
1170  const int order = 1 ) {
1174 
1175  Ptr<Vector<Real>> x, y, u, v;
1176  try {
1177  x = sol_->clone(); x->randomize();
1178  y = sol_->clone(); y->randomize();
1179  u = sol_->clone(); u->randomize();
1180  v = sol_->clone(); v->randomize();
1181 
1182  checkSolutionVector(data,*x,*y,*u,outStream);
1183  checkObjective(data,*x,*u,*v,outStream,numSteps,order);
1184  }
1185  catch (std::exception &e) {
1186 // throw Exception::NotImplemented(">>> ROL::OptimizationProblem::check: Elementwise is not implemented for optimization space vectors");
1187  }
1188 
1189  if(con_ != nullPtr) {
1190  Ptr<Vector<Real>> c, l, w, q;
1191  try {
1192  c = mul_->dual().clone(); c->randomize();
1193  l = mul_->clone(); l->randomize();
1194  w = mul_->clone(); w->randomize();
1195  q = mul_->clone(); q->randomize();
1196 
1197  checkMultiplierVector(data,*w,*q,*l,outStream);
1198  checkConstraint(data,*x,*u,*v,*c,*l,outStream,numSteps,order);
1199  }
1200  catch (std::exception &e) {
1201  throw Exception::NotImplemented(">>> ROL::OptimizationProblem::check: Elementwise is not implemented for constraint space vectors");
1202  }
1203  }
1204  }
1205 
1206 }; // class OptimizationProblem
1207 
1208 
1209 template<template<typename> class V,
1210  template<typename> class Obj,
1211  typename Real,typename P=Ptr<OptimizationProblem<Real>>,typename...Args>
1212 inline typename std::enable_if<std::is_base_of<Objective<Real>,Obj<Real>>::value &&
1213  std::is_base_of<Vector<Real>, V<Real>>::value,P>::type
1214 make_OptimizationProblem( const Ptr<Obj<Real>> &obj, const Ptr<V<Real>> &x, Args&&...args) {
1215  return makePtr<OptimizationProblem<Real>>(obj,x,std::forward<Args>(args)...);
1216 }
1217 
1218 } // namespace ROL
1219 
1220 #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:312
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:80
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)
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:74
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:255
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
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)