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 
49 
50 // Stochastic Includes
51 #include "ROL_SampleGenerator.hpp"
52 #include "ROL_RiskVector.hpp"
54 // Objective includes
58 // Constraint includes
62 // Almost sure constraint includes
65 #include "ROL_SimulatedVector.hpp"
66 
67 namespace ROL {
68 
69 /* Represents optimization problems in Type-EB form
70  */
71 
72 template<class Real>
74 private:
75  Ptr<Objective<Real>> INPUT_obj_;
76  Ptr<Vector<Real>> INPUT_sol_;
77  Ptr<BoundConstraint<Real>> INPUT_bnd_;
78  std::vector<Ptr<Constraint<Real>>> INPUT_econ_;
79  std::vector<Ptr<Vector<Real>>> INPUT_emul_;
80  std::vector<Ptr<Constraint<Real>>> INPUT_icon_;
81  std::vector<Ptr<Vector<Real>>> INPUT_imul_;
82  std::vector<Ptr<BoundConstraint<Real>>> INPUT_ibnd_;
83 
84  Ptr<Objective<Real>> INTERMEDIATE_obj_;
85  Ptr<Vector<Real>> INTERMEDIATE_sol_;
86  Ptr<BoundConstraint<Real>> INTERMEDIATE_bnd_;
87  std::vector<Ptr<Constraint<Real>>> INTERMEDIATE_econ_;
88  std::vector<Ptr<Vector<Real>>> INTERMEDIATE_emul_;
89  std::vector<Ptr<Constraint<Real>>> INTERMEDIATE_icon_;
90  std::vector<Ptr<Vector<Real>>> INTERMEDIATE_imul_;
91  std::vector<Ptr<BoundConstraint<Real>>> INTERMEDIATE_ibnd_;
92 
93  Ptr<SampleGenerator<Real>> vsampler_;
94  Ptr<SampleGenerator<Real>> gsampler_;
95  Ptr<SampleGenerator<Real>> hsampler_;
96  std::vector<Ptr<SampleGenerator<Real>>> exsampler_;
97  std::vector<Ptr<BatchManager<Real>>> ecbman_;
98  std::vector<Ptr<SampleGenerator<Real>>> ixsampler_;
99  std::vector<Ptr<BatchManager<Real>>> icbman_;
100 
101  Ptr<ParameterList> parlistObj_;
102  std::vector<Ptr<ParameterList>> parlistCon_;
103 
104  Ptr<Objective<Real>> obj_;
105  Ptr<Vector<Real>> sol_;
106  Ptr<BoundConstraint<Real>> bnd_;
107  Ptr<Constraint<Real>> con_;
108  Ptr<Vector<Real>> mul_;
109 
110  Ptr<ConstraintManager<Real>> conManager_;
111 
113 
115 
117  std::vector<bool> needRiskLessEcon_;
118  std::vector<bool> needRiskLessIcon_;
120 
121  void initialize( const Ptr<Objective<Real>> &obj,
122  const Ptr<Vector<Real>> &x,
123  const Ptr<BoundConstraint<Real>> &bnd,
124  const std::vector<Ptr<Constraint<Real>>> &econ,
125  const std::vector<Ptr<Vector<Real>>> &emul,
126  const std::vector<Ptr<Constraint<Real>>> &icon,
127  const std::vector<Ptr<Vector<Real>>> &imul,
128  const std::vector<Ptr<BoundConstraint<Real>>> &ibnd ) {
129  if (!isInitialized_) {
130  int esize = static_cast<int>(econ.size());
131  int isize = static_cast<int>(icon.size());
132  std::vector<Ptr<Constraint<Real>>> cvec;
133  std::vector<Ptr<Vector<Real>>> lvec;
134  std::vector<Ptr<BoundConstraint<Real>>> bvec;
135  for (int i = 0; i < esize; ++i) {
136  if ( econ[i] != nullPtr ) {
137  if (isStochastic_) {
138  cvec.push_back(setRiskLessCon(econ[i],needRiskLessEcon_[i]));
139  }
140  else {
141  cvec.push_back(econ[i]);
142  }
143  lvec.push_back(emul[i]);
144  bvec.push_back(nullPtr);
145  }
146  }
147  for (int i = 0; i < isize; ++i) {
148  if ( icon[i] != nullPtr ) {
149  if (isStochastic_) {
150  cvec.push_back(setRiskLessCon(icon[i],needRiskLessIcon_[i]));
151  }
152  else {
153  cvec.push_back(icon[i]);
154  }
155  lvec.push_back(imul[i]);
156  bvec.push_back(ibnd[i]);
157  }
158  }
159 
160  conManager_ = makePtr<ConstraintManager<Real>>(cvec,lvec,bvec,x,bnd);
161  con_ = conManager_->getConstraint();
162  mul_ = conManager_->getMultiplier();
163  sol_ = conManager_->getOptVector();
164  bnd_ = conManager_->getBoundConstraint();
165  Ptr<Objective<Real>> obj0;
166  if (isStochastic_) {
167  obj0 = setRiskLessObj(obj,needRiskLessObj_);
168  }
169  else {
170  obj0 = obj;
171  }
172  if ( conManager_->hasInequality() ) {
173  obj_ = makePtr<SlacklessObjective<Real>>(obj0);
174  }
175  else {
176  obj_ = obj0;
177  }
178 
179  if ( conManager_->isNull() ) {
180  if( bnd_ == nullPtr || !bnd_->isActivated() ) { // Type-U
181  problemType_ = TYPE_U;
182  }
183  else { // Type-B
184  problemType_ = TYPE_B;
185  }
186  }
187  else {
188  if( bnd_ == nullPtr || !bnd_->isActivated() ) { // Type-E
189  problemType_ = TYPE_E;
190  }
191  else { // Type-EB
193  }
194  }
195  isInitialized_ = true;
196  }
197  }
198 
199  const Ptr<Constraint<Real>> setRiskLessCon(const Ptr<Constraint<Real>> &con, const bool needRiskLess) const {
200  if (needRiskLess) {
201  return makePtr<RiskLessConstraint<Real>>(con);
202  }
203  else {
204  return con;
205  }
206  }
207 
208  const Ptr<Objective<Real>> setRiskLessObj(const Ptr<Objective<Real>> &obj, const bool needRiskLess) const {
209  if (needRiskLess) {
210  return makePtr<RiskLessObjective<Real>>(obj);
211  }
212  else {
213  return obj;
214  }
215  }
216 
217  std::vector<Real> computeSampleMean(const Ptr<SampleGenerator<Real>> &sampler) const {
218  // Compute mean value of inputs and set parameter in objective
219  int dim = sampler->getMyPoint(0).size(), nsamp = sampler->numMySamples();
220  std::vector<Real> loc(dim), mean(dim), pt(dim);
221  Real wt(0);
222  for (int i = 0; i < nsamp; i++) {
223  pt = sampler->getMyPoint(i);
224  wt = sampler->getMyWeight(i);
225  for (int j = 0; j < dim; j++) {
226  loc[j] += wt*pt[j];
227  }
228  }
229  sampler->sumAll(&loc[0],&mean[0],dim);
230  return mean;
231  }
232 
233  void initStochastic(void) {
234  if (!isStochastic_) {
235  int econSize = INPUT_econ_.size();
236  int iconSize = INPUT_icon_.size();
237  needRiskLessObj_ = true;
238  needRiskLessEcon_.clear(); needRiskLessEcon_.resize(econSize,true);
239  needRiskLessIcon_.clear(); needRiskLessIcon_.resize(iconSize,true);
240  parlistObj_ = nullPtr;
241  parlistCon_.clear(); parlistCon_.resize(iconSize,nullPtr);
242 
243  exsampler_.clear(); exsampler_.resize(econSize,nullPtr);
244  ecbman_.clear(); ecbman_.resize(econSize,nullPtr);
245 
246  ixsampler_.clear(); ixsampler_.resize(iconSize,nullPtr);
247  icbman_.clear(); icbman_.resize(iconSize,nullPtr);
248 
249  isStochastic_ = true;
250  }
251  }
252 
253  void buildRiskVec(Ptr<Vector<Real>> &x) {
254  // Build risk vector and risk bound constraint
256  = makePtr<RiskVector<Real>>(parlistObj_,parlistCon_,x);
257  if (parlistObj_ != nullPtr) {
258  Real statObj = parlistObj_->sublist("SOL").get("Initial Statistic",1.0);
259  dynamicPtrCast<RiskVector<Real>>(INTERMEDIATE_sol_)->setStatistic(statObj,0);
260  }
261  int nc = INPUT_icon_.size();
262  for (int i = 0; i < nc; ++i) {
263  if (parlistCon_[i] != nullPtr) {
264  Real statCon = parlistCon_[i]->sublist("SOL").get("Initial Statistic",1.0);
265  dynamicPtrCast<RiskVector<Real>>(INTERMEDIATE_sol_)->setStatistic(statCon,1,i);
266  }
267  }
268  }
269 
271  if ( INPUT_bnd_ != nullPtr ) {
273  = makePtr<RiskBoundConstraint<Real>>(parlistObj_,parlistCon_,bnd);
274  }
275  }
276 
277 public:
278  virtual ~OptimizationProblem(void) {}
279 
280  // Default constructor [0]
282  : isInitialized_(false), isStochastic_(false) {}
283 
284  // Complete option constructor [1]
286  const Ptr<Vector<Real>> &x,
287  const Ptr<BoundConstraint<Real>> &bnd,
288  const std::vector<Ptr<Constraint<Real>>> &econ,
289  const std::vector<Ptr<Vector<Real>>> &emul,
290  const std::vector<Ptr<Constraint<Real>>> &icon,
291  const std::vector<Ptr<Vector<Real>>> &imul,
292  const std::vector<Ptr<BoundConstraint<Real>>> &ibnd )
293  : INPUT_obj_(obj), INPUT_sol_(x), INPUT_bnd_(bnd),
294  INPUT_econ_(econ), INPUT_emul_(emul),
295  INPUT_icon_(icon), INPUT_imul_(imul), INPUT_ibnd_(ibnd),
299  isInitialized_(false), isStochastic_(false) {}
300 
302  const Ptr<Vector<Real>> &x,
303  const Ptr<BoundConstraint<Real>> &bnd,
304  const Ptr<Constraint<Real>> &econ,
305  const Ptr<Vector<Real>> &emul,
306  const std::vector<Ptr<Constraint<Real>>> &icon,
307  const std::vector<Ptr<Vector<Real>>> &imul,
308  const std::vector<Ptr<BoundConstraint<Real>>> &ibnd )
309  : INPUT_obj_(obj), INPUT_sol_(x), INPUT_bnd_(bnd),
310  INPUT_icon_(icon), INPUT_imul_(imul), INPUT_ibnd_(ibnd),
313  isInitialized_(false), isStochastic_(false) {
314  std::vector<Ptr<Constraint<Real>>> econ0(1,econ);
315  std::vector<Ptr<Vector<Real>>> emul0(1,emul);
316  INPUT_econ_ = econ0;
317  INPUT_emul_ = emul0;
318  INTERMEDIATE_econ_ = econ0;
319  INTERMEDIATE_emul_ = emul0;
320  }
321 
323  const Ptr<Vector<Real>> &x,
324  const Ptr<BoundConstraint<Real>> &bnd,
325  const std::vector<Ptr<Constraint<Real>>> &econ,
326  const std::vector<Ptr<Vector<Real>>> &emul,
327  const Ptr<Constraint<Real>> &icon,
328  const Ptr<Vector<Real>> &imul,
329  const Ptr<BoundConstraint<Real>> &ibnd )
330  : INPUT_obj_(obj), INPUT_sol_(x), INPUT_bnd_(bnd),
331  INPUT_econ_(econ), INPUT_emul_(emul),
334  isInitialized_(false), isStochastic_(false) {
335  std::vector<Ptr<Constraint<Real>>> icon0(1,icon);
336  std::vector<Ptr<Vector<Real>>> imul0(1,imul);
337  std::vector<Ptr<BoundConstraint<Real>>> ibnd0(1,ibnd);
338  INPUT_icon_ = icon0;
339  INPUT_imul_ = imul0;
340  INPUT_ibnd_ = ibnd0;
341  INTERMEDIATE_icon_ = icon0;
342  INTERMEDIATE_imul_ = imul0;
343  INTERMEDIATE_ibnd_ = ibnd0;
344  }
345 
347  const Ptr<Vector<Real>> &x,
348  const Ptr<BoundConstraint<Real>> &bnd,
349  const Ptr<Constraint<Real>> &econ,
350  const Ptr<Vector<Real>> &emul,
351  const Ptr<Constraint<Real>> &icon,
352  const Ptr<Vector<Real>> &imul,
353  const Ptr<BoundConstraint<Real>> &ibnd )
354  : INPUT_obj_(obj), INPUT_sol_(x), INPUT_bnd_(bnd),
356  isInitialized_(false), isStochastic_(false) {
357  std::vector<Ptr<Constraint<Real>>> econ0(1,econ);
358  std::vector<Ptr<Vector<Real>>> emul0(1,emul);
359  std::vector<Ptr<Constraint<Real>>> icon0(1,icon);
360  std::vector<Ptr<Vector<Real>>> imul0(1,imul);
361  std::vector<Ptr<BoundConstraint<Real>>> ibnd0(1,ibnd);
362  INPUT_econ_ = econ0;
363  INPUT_emul_ = emul0;
364  INPUT_icon_ = icon0;
365  INPUT_imul_ = imul0;
366  INPUT_ibnd_ = ibnd0;
367  INTERMEDIATE_econ_ = econ0;
368  INTERMEDIATE_emul_ = emul0;
369  INTERMEDIATE_icon_ = icon0;
370  INTERMEDIATE_imul_ = imul0;
371  INTERMEDIATE_ibnd_ = ibnd0;
372  }
373 
374  // No bound constuctor [2]
376  const Ptr<Vector<Real>> &x,
377  const std::vector<Ptr<Constraint<Real>>> &econ,
378  const std::vector<Ptr<Vector<Real>>> &emul,
379  const std::vector<Ptr<Constraint<Real>>> &icon,
380  const std::vector<Ptr<Vector<Real>>> &imul,
381  const std::vector<Ptr<BoundConstraint<Real>>> &ibnd )
382  : OptimizationProblem( obj, x, nullPtr, econ, emul, icon, imul, ibnd ) {}
383 
385  const Ptr<Vector<Real>> &x,
386  const Ptr<Constraint<Real>> &econ,
387  const Ptr<Vector<Real>> &emul,
388  const std::vector<Ptr<Constraint<Real>>> &icon,
389  const std::vector<Ptr<Vector<Real>>> &imul,
390  const std::vector<Ptr<BoundConstraint<Real>>> &ibnd )
391  : OptimizationProblem( obj, x, nullPtr, econ, emul, icon, imul, ibnd) {}
392 
394  const Ptr<Vector<Real>> &x,
395  const std::vector<Ptr<Constraint<Real>>> &econ,
396  const std::vector<Ptr<Vector<Real>>> &emul,
397  const Ptr<Constraint<Real>> &icon,
398  const Ptr<Vector<Real>> &imul,
399  const Ptr<BoundConstraint<Real>> &ibnd )
400  : OptimizationProblem( obj, x, nullPtr, econ, emul, icon, imul, ibnd) {}
401 
403  const Ptr<Vector<Real>> &x,
404  const Ptr<Constraint<Real>> &econ,
405  const Ptr<Vector<Real>> &emul,
406  const Ptr<Constraint<Real>> &icon,
407  const Ptr<Vector<Real>> &imul,
408  const Ptr<BoundConstraint<Real>> &ibnd )
409  : OptimizationProblem( obj, x, nullPtr, econ, emul, icon, imul, ibnd) {}
410 
411  // No inequality constraint [3]
413  const Ptr<Vector<Real>> &x,
414  const Ptr<BoundConstraint<Real>> &bnd,
415  const std::vector<Ptr<Constraint<Real>>> &econ,
416  const std::vector<Ptr<Vector<Real>>> &emul )
417  : OptimizationProblem( obj, x, bnd, econ, emul, nullPtr, nullPtr, nullPtr ) {}
418 
420  const Ptr<Vector<Real>> &x,
421  const Ptr<BoundConstraint<Real>> &bnd,
422  const Ptr<Constraint<Real>> &econ,
423  const Ptr<Vector<Real>> &emul )
424  : OptimizationProblem( obj, x, bnd, econ, emul, nullPtr, nullPtr, nullPtr) {}
425 
426  // No equality constraint [4]
428  const Ptr<Vector<Real>> &x,
429  const Ptr<BoundConstraint<Real>> &bnd,
430  const std::vector<Ptr<Constraint<Real>>> &icon,
431  const std::vector<Ptr<Vector<Real>>> &imul,
432  const std::vector<Ptr<BoundConstraint<Real>>> &ibnd )
433  : OptimizationProblem( obj, x, bnd, nullPtr, nullPtr, icon, imul, ibnd ) {}
434 
436  const Ptr<Vector<Real>> &x,
437  const Ptr<BoundConstraint<Real>> &bnd,
438  const Ptr<Constraint<Real>> &icon,
439  const Ptr<Vector<Real>> &imul,
440  const Ptr<BoundConstraint<Real>> &ibnd )
441  : OptimizationProblem( obj, x, bnd, nullPtr, nullPtr, icon, imul, ibnd) {}
442 
443  // No inequality or bound constraint [5]
445  const Ptr<Vector<Real>> &x,
446  const std::vector<Ptr<Constraint<Real>>> &econ,
447  const std::vector<Ptr<Vector<Real>>> &emul )
448  : OptimizationProblem( obj, x, nullPtr, econ, emul, nullPtr, nullPtr, nullPtr ) {}
449 
451  const Ptr<Vector<Real>> &x,
452  const Ptr<Constraint<Real>> &econ,
453  const Ptr<Vector<Real>> &emul )
454  : OptimizationProblem( obj, x, nullPtr, econ, emul, nullPtr, nullPtr, nullPtr) {}
455 
456  // No equality or bound constraint [6]
458  const Ptr<Vector<Real>> &x,
459  const std::vector<Ptr<Constraint<Real>>> &icon,
460  const std::vector<Ptr<Vector<Real>>> &imul,
461  const std::vector<Ptr<BoundConstraint<Real>>> &ibnd )
462  : OptimizationProblem( obj, x, nullPtr, nullPtr, nullPtr, icon, imul, ibnd ) {}
463 
465  const Ptr<Vector<Real>> &x,
466  const Ptr<Constraint<Real>> &icon,
467  const Ptr<Vector<Real>> &imul,
468  const Ptr<BoundConstraint<Real>> &ibnd )
469  : OptimizationProblem( obj, x, nullPtr, nullPtr, nullPtr, icon, imul, ibnd) {}
470 
471  // Bound constrained problem [7]
473  const Ptr<Vector<Real>> &x,
474  const Ptr<BoundConstraint<Real>> &bnd )
475  : OptimizationProblem( obj, x, bnd, nullPtr, nullPtr, nullPtr, nullPtr, nullPtr ) {}
476 
477  // Unconstrained problem [8]
479  const Ptr<Vector<Real>> &x ) :
480  OptimizationProblem( obj, x, nullPtr, nullPtr, nullPtr, nullPtr, nullPtr, nullPtr ) {}
481 
482  /* Get methods */
483 
484  virtual Ptr<Objective<Real>> getObjective(void) {
485  if ( INTERMEDIATE_obj_ == nullPtr ) {
486  throw Exception::NotImplemented(">>> ROL::OptimizationProblem::getObjective: No objective inputed!");
487  }
491  return obj_;
492  }
493 
494  virtual Ptr<Vector<Real>> getSolutionVector(void) {
495  if ( INTERMEDIATE_sol_ == nullPtr ) {
496  throw Exception::NotImplemented(">>> ROL::OptimizationProblem::getSolutionVector: No solution vector inputed!");
497  }
501  return sol_;
502  }
503 
504  virtual Ptr<BoundConstraint<Real>> getBoundConstraint(void) {
508  return bnd_;
509  }
510 
511  virtual Ptr<Constraint<Real>> getConstraint(void) {
515  return con_;
516  }
517 
518  virtual Ptr<Vector<Real>> getMultiplierVector(void) {
522  return mul_;
523  }
524 
529  return problemType_;
530  }
531 
532  /* Set Stochastic Methods */
533 
534  /* Objective function */
545  void setMeanValueObjective(const Ptr<SampleGenerator<Real>> &sampler) {
546  initStochastic();
547  // Set objective function samplers
548  vsampler_ = sampler;
549  gsampler_ = sampler;
550  hsampler_ = sampler;
551  // Construct risk-averse/probabilistic objective function
552  if ( vsampler_ == nullPtr ) {
553  throw Exception::NotImplemented(">>> ROL::OptimizationProblem::setMeanValueObjective: Objective function value sampler is null!");
554  }
555  else {
556  std::vector<Real> mean = computeSampleMean(vsampler_);
558  INTERMEDIATE_obj_->setParameter(mean);
559  }
560  // Set vector and bound constraint
563 
564  isInitialized_ = false;
565  }
566 
580  const Ptr<SampleGenerator<Real>> &gsampler = nullPtr,
581  const Ptr<SampleGenerator<Real>> &hsampler = nullPtr,
582  const bool storage = true) {
583  initStochastic();
584  // Set objective function samplers
585  vsampler_ = vsampler;
586  gsampler_ = gsampler;
587  hsampler_ = hsampler;
588  if ( gsampler == nullPtr ) {
590  }
591  if ( hsampler == nullPtr ) {
593  }
594  // Construct risk-averse/probabilistic objective function
595  if ( vsampler_ == nullPtr ) {
596  throw Exception::NotImplemented(">>> ROL::OptimizationProblem::setRiskNeutralObjective: Objective function value sampler is null!");
597  }
598  else {
600  = makePtr<RiskNeutralObjective<Real>>(INPUT_obj_,vsampler_,gsampler_,hsampler_,storage);
601  }
602  // Set vector and bound constraint
605 
606  isInitialized_ = false;
607  }
608 
621  void setRiskAverseObjective(ParameterList &parlist,
622  const Ptr<SampleGenerator<Real>> &vsampler,
623  const Ptr<SampleGenerator<Real>> &gsampler = nullPtr,
624  const Ptr<SampleGenerator<Real>> &hsampler = nullPtr) {
625  initStochastic();
626  // Set objective function samplers
627  vsampler_ = vsampler;
628  gsampler_ = gsampler;
629  hsampler_ = hsampler;
630  if ( gsampler == nullPtr ) {
632  }
633  if ( hsampler == nullPtr ) {
635  }
636  // Construct risk-averse/probabilistic objective function
637  if ( vsampler_ == nullPtr ) {
638  throw Exception::NotImplemented(">>> ROL::OptimizationProblem::setRiskAverseObjective: Objective function value sampler is null!");
639  }
640  else {
641  needRiskLessObj_ = false;
642  parlistObj_ = makePtrFromRef(parlist);
644  = makePtr<StochasticObjective<Real>>(INPUT_obj_,parlist,vsampler_,gsampler_,hsampler_);
645  }
646  // Set vector and bound constraint
649 
650  isInitialized_ = false;
651  }
652 
653  void setStochasticObjective(ParameterList &parlist,
654  const Ptr<SampleGenerator<Real>> &vsampler,
655  const Ptr<SampleGenerator<Real>> &gsampler = nullPtr,
656  const Ptr<SampleGenerator<Real>> &hsampler = nullPtr) {
657  // Determine Stochastic Objective Type
658  std::string type = parlist.sublist("SOL").get("Stochastic Component Type","Risk Neutral");
659  if ( type == "Risk Neutral" ) {
660  bool storage = parlist.sublist("SOL").get("Store Sampled Value and Gradient",true);
661  setRiskNeutralObjective(vsampler,gsampler,hsampler,storage);
662  }
663  else if ( type == "Risk Averse" ||
664  type == "Deviation" ||
665  type == "Error" ||
666  type == "Regret" ||
667  type == "Probability" ) {
668  setRiskAverseObjective(parlist,vsampler,gsampler,hsampler);
669  }
670  else if ( type == "Mean Value" ) {
671  setMeanValueObjective(vsampler);
672  }
673  else {
674  throw Exception::NotImplemented(">>> ROL::OptimizationProblem::setStochasticObjective: Invalid stochastic optimization type!");
675  }
676  // Set vector and bound constraint
679 
680  isInitialized_ = false;
681  }
682 
683  /* Equality Constraint */
684  void setMeanValueEquality(const Ptr<SampleGenerator<Real>> &sampler, const int index = 0) {
685  initStochastic();
686  exsampler_[index] = sampler;
687  if ( INPUT_econ_[index] != nullPtr && sampler != nullPtr ) {
688  std::vector<Real> mean = computeSampleMean(sampler);
689  INTERMEDIATE_econ_[index] = INPUT_econ_[index];
690  INTERMEDIATE_econ_[index]->setParameter(mean);
691  INTERMEDIATE_emul_[index] = INPUT_emul_[index];
692  }
693  else {
694  throw Exception::NotImplemented(">>> ROL::OptimizationProblem::setMeanValueEquality: Either SampleGenerator or Constraint is NULL!");
695  }
696  // Set vector and bound constraint
699 
700  isInitialized_ = false;
701  }
702 
704  const Ptr<BatchManager<Real>> &cbman,
705  const int index = 0) {
706  initStochastic();
707  exsampler_[index] = xsampler;
708  ecbman_[index] = cbman;
709  if ( INPUT_econ_[index] != nullPtr
710  && xsampler != nullPtr
711  && cbman != nullPtr ) {
712  INTERMEDIATE_econ_[index]
713  = makePtr<RiskNeutralConstraint<Real>>(INPUT_econ_[index],xsampler,cbman);
714  INTERMEDIATE_emul_[index] = INPUT_emul_[index];
715  }
716  else {
717  throw Exception::NotImplemented(">>> ROL::OptimizationProblem::SetRiskNeutralEquality: Either SampleGenerator, Constraint or BatchManager is NULL!");
718  }
719  // Set vector and bound constraint
722 
723  isInitialized_ = false;
724  }
725 
727  const int index = 0) {
728  initStochastic();
729  exsampler_[index] = sampler;
730  if ( INPUT_econ_[index] != nullPtr && sampler != nullPtr ) {
731  int nsamp = sampler->numMySamples();
732  INTERMEDIATE_econ_[index]
733  = makePtr<AlmostSureConstraint<Real>>(sampler,INPUT_econ_[index]);
734  std::vector<Ptr<Vector<Real>>> emul(nsamp,nullPtr);
735  for (int j = 0; j < nsamp; ++j) {
736  emul[j] = INPUT_emul_[index]->clone();
737  emul[j]->set(*INPUT_emul_[index]);
738  }
739  INTERMEDIATE_emul_[index]
740  = makePtr<DualSimulatedVector<Real>>(emul, sampler->getBatchManager(), sampler);
741  }
742  else {
743  throw Exception::NotImplemented(">>> ROL::OptimizationProblem::SetAlmostSureEquality: Either SampleGenerator or Constraint is NULL!");
744  }
745  // Set vector and bound constraint
748 
749  isInitialized_ = false;
750  }
751 
752 
753  void setStochasticEquality(std::vector<ParameterList> &parlist,
754  const std::vector<Ptr<SampleGenerator<Real>>> &xsampler,
755  const std::vector<Ptr<BatchManager<Real>>> &cbman) {
756  initStochastic();
757  int nc = static_cast<int>(INPUT_econ_.size());
758  if ( nc != static_cast<int>(xsampler.size()) || nc != static_cast<int>(cbman.size()) ) {
759  throw Exception::NotImplemented(">>> ROL::OptimizationProblem::setStochasticEquality: Constraint vector and SampleGenerator vector are not the same size!");
760  }
761  for (int i = 0; i < nc; ++i) {
762  if (xsampler[i] != nullPtr) {
763  std::string type = parlist[i].sublist("SOL").get("Stochastic Component Type","Risk Neutral");
764  if ( type == "Risk Neutral" ) {
765  setRiskNeutralEquality(xsampler[i],cbman[i],i);
766  }
767  else if ( type == "Almost Sure" ) {
768  setAlmostSureEquality(xsampler[i],i);
769  }
770  else if ( type == "Mean Value" ) {
771  setMeanValueEquality(xsampler[i],i);
772  }
773  else {
774  throw Exception::NotImplemented(">>> ROL::OptimizationProblem::SetStochasticEquality: Invalid stochastic constraint type!");
775  }
776  }
777  else {
780  }
781  }
782  // Set vector and bound constraint
785 
786  isInitialized_ = false;
787  }
788 
789  void setStochasticEquality(ParameterList &parlist,
790  const Ptr<SampleGenerator<Real>> &xsampler,
791  const Ptr<BatchManager<Real>> &cbman) {
792  std::vector<ParameterList> cparlist(1,parlist);
793  std::vector<Ptr<SampleGenerator<Real>>> cxsampler(1,xsampler);
794  std::vector<Ptr<BatchManager<Real>>> ccbman(1,cbman);
795  setStochasticEquality(cparlist,cxsampler,ccbman);
796  }
797 
798  /* Inequality constraint */
800  const int index = 0) {
801  initStochastic();
802  ixsampler_[index] = sampler;
803  if ( INPUT_icon_[index] != nullPtr && sampler != nullPtr ) {
804  std::vector<Real> mean = computeSampleMean(sampler);
805  INTERMEDIATE_icon_[index] = INPUT_icon_[index];
806  INTERMEDIATE_icon_[index]->setParameter(mean);
807  INTERMEDIATE_ibnd_[index] = INPUT_ibnd_[index];
808  INTERMEDIATE_imul_[index] = INPUT_imul_[index];
809  }
810  else {
811  throw Exception::NotImplemented(">>> ROL::OptimizationProblem::SetMeanValueInequality: Either Constraint or SampleGenerator is NULL!");
812  }
813  // Set vector and bound constraint
816 
817  isInitialized_ = false;
818  }
819 
821  const Ptr<BatchManager<Real>> &cbman,
822  const int index = 0) {
823  initStochastic();
824  ixsampler_[index] = xsampler;
825  icbman_[index] = cbman;
826  if ( INPUT_icon_[index] != nullPtr
827  && xsampler != nullPtr
828  && cbman != nullPtr ) {
829  INTERMEDIATE_icon_[index]
830  = makePtr<RiskNeutralConstraint<Real>>(INPUT_icon_[index],xsampler,cbman);
831  INTERMEDIATE_ibnd_[index] = INPUT_ibnd_[index];
832  INTERMEDIATE_imul_[index] = INPUT_imul_[index];
833  }
834  else {
835  throw Exception::NotImplemented(">>> ROL::OptimizationProblem::SetRiskNeutralInequality: Either Constraint, SampleGenerator or BatchManager is NULL!");
836  }
837  // Set vector and bound constraint
840 
841  isInitialized_ = false;
842  }
843 
844  void setRiskAverseInequality(ParameterList &parlist,
845  const Ptr<SampleGenerator<Real>> &sampler,
846  const int index = 0) {
847  initStochastic();
848  ixsampler_[index] = sampler;
849  if ( INPUT_icon_[index] != nullPtr && sampler != nullPtr ) {
850  needRiskLessIcon_[index] = false;
851  parlistCon_[index] = makePtrFromRef(parlist);
852  INTERMEDIATE_icon_[index]
853  = makePtr<StochasticConstraint<Real>>(INPUT_icon_[index],sampler,parlist,index);
854  INTERMEDIATE_ibnd_[index] = INPUT_ibnd_[index];
855  INTERMEDIATE_imul_[index] = INPUT_imul_[index];
856  }
857  else {
858  throw Exception::NotImplemented(">>> ROL::OptimizationProblem::SetRiskAverseInequality: Either Constraint or SampleGenerator is NULL!");
859  }
860  // Set vector and bound constraint
863 
864  isInitialized_ = false;
865  }
866 
868  const int index = 0) {
869  initStochastic();
870  ixsampler_[index] = sampler;
871  if ( INPUT_icon_[index] != nullPtr && sampler != nullPtr ) {
872  int nsamp = sampler->numMySamples();
873  INTERMEDIATE_icon_[index]
874  = makePtr<AlmostSureConstraint<Real>>(sampler, INPUT_icon_[index]);
875  std::vector<Ptr<Vector<Real>>> imul(nsamp,nullPtr);
876  for (int j = 0; j < nsamp; ++j) {
877  imul[j] = INPUT_imul_[index]->clone();
878  imul[j]->set(*INPUT_imul_[index]);
879  }
880  INTERMEDIATE_imul_[index]
881  = makePtr<DualSimulatedVector<Real>>(imul, sampler->getBatchManager(), sampler);
882  INTERMEDIATE_ibnd_[index]
883  = makePtr<SimulatedBoundConstraint<Real>>(sampler, INPUT_ibnd_[index]);
884  }
885  else {
886  throw Exception::NotImplemented(">>> ROL::OptimizationProblem::SetAlmostSureInequality: Either Constraint or SampleGenerator is NULL!");
887  }
888  // Set vector and bound constraint
891 
892  isInitialized_ = false;
893  }
894 
895  void setStochasticInequality(std::vector<ParameterList> &parlist,
896  const std::vector<Ptr<SampleGenerator<Real>>> &xsampler,
897  const std::vector<Ptr<BatchManager<Real>>> &cbman) {
898  initStochastic();
899  int nc = static_cast<int>(INPUT_icon_.size());
900  if ( nc != static_cast<int>(xsampler.size()) || nc != static_cast<int>(cbman.size()) ) {
901  throw Exception::NotImplemented(">>> ROL::OptimizationProblem::setStochasticInequality: Constraint vector and SampleGenerator vector are not the same size!");
902  }
903  for (int i = 0; i < nc; ++i) {
904  if ( xsampler[i] != nullPtr ) {
905  std::string type = parlist[i].sublist("SOL").get("Stochastic Component Type","Risk Neutral");
906  if ( type == "Risk Neutral" ) {
907  setRiskNeutralInequality(xsampler[i],cbman[i],i);
908  }
909  else if ( type == "Risk Averse" ||
910  type == "Deviation" ||
911  type == "Error" ||
912  type == "Regret" ||
913  type == "Probability" ) {
914  setRiskAverseInequality(parlist[i],xsampler[i],i);
915  }
916  else if ( type == "Almost Sure" ) {
917  setAlmostSureInequality(xsampler[i],i);
918  }
919  else if ( type == "Mean Value" ) {
920  setMeanValueInequality(xsampler[i],i);
921  }
922  else {
923  throw Exception::NotImplemented(">>> ROL::OptimizationProblem::SetStochasticInequality: Invalid stochastic constraint type!");
924  }
925  }
926  else {
930  }
931  }
932  // Set vector and bound constraint
935 
936  isInitialized_ = false;
937  }
938 
939  void setStochasticInequality(ParameterList &parlist,
940  const Ptr<SampleGenerator<Real>> &xsampler,
941  const Ptr<BatchManager<Real>> &cbman) {
942  std::vector<ParameterList> cparlist(1,parlist);
943  std::vector<Ptr<SampleGenerator<Real>>> cxsampler(1,xsampler);
944  std::vector<Ptr<BatchManager<Real>>> ccbman(1,cbman);
945  setStochasticInequality(cparlist,cxsampler,ccbman);
946  }
947 
953  Real getSolutionStatistic(int comp = 0, int index = 0) {
954  Real val(0);
955  if (comp == 0) {
956  try {
957  val = dynamicPtrCast<StochasticObjective<Real>>(INTERMEDIATE_obj_)->computeStatistic(*INTERMEDIATE_sol_);
958  }
959  catch (std::exception &e) {
960  throw Exception::NotImplemented(">>> ROL::OptimizationProblem::getSolutionStatistic: Objective does not have computeStatistic function!");
961  }
962  }
963  else if (comp == 1) {
964  int np = INTERMEDIATE_icon_.size();
965  if (np <= index || index < 0) {
966  throw Exception::NotImplemented(">>> ROL::OptimizationProblem::getSolutionStatistic: Index out of bounds!");
967  }
968  try {
969  val = dynamicPtrCast<StochasticConstraint<Real>>(INTERMEDIATE_icon_[index])->computeStatistic(*INTERMEDIATE_sol_);
970  }
971  catch (std::exception &e) {
972  throw Exception::NotImplemented(">>> ROL::OptimizationProblem::getSolutionStatistic: Constraint does not have computeStatistic function!");
973  }
974  }
975  else {
976  throw Exception::NotImplemented(">>> ROL::OptimizationProblem::getSolutionStatistic: Component must be either 0 or 1!");
977  }
978  return val;
979  }
980 
981  std::vector<Real> getObjectiveStatistic(void) const {
982  try {
983  Ptr<std::vector<Real>> stat
984  = dynamicPtrCast<RiskVector<Real>>(INTERMEDIATE_sol_)->getStatistic();
985  if (stat != nullPtr) {
986  return *stat;
987  }
988  else {
989  std::vector<Real> empty;
990  return empty;
991  }
992  }
993  catch (std::exception &e) {
994  std::vector<Real> empty;
995  return empty;
996  }
997  }
998 
999  std::vector<Real> getConstraintStatistic(const int index = 0) const {
1000  try {
1001  Ptr<std::vector<Real>> stat
1002  = dynamicPtrCast<RiskVector<Real>>(INTERMEDIATE_sol_)->getStatistic(1,index);
1003  if (stat != nullPtr) {
1004  return *stat;
1005  }
1006  else {
1007  std::vector<Real> empty;
1008  return empty;
1009  }
1010  }
1011  catch (std::exception &e) {
1012  std::vector<Real> empty;
1013  return empty;
1014  }
1015  }
1016 
1017  void reset(void) {
1021  conManager_->resetSlackVariables();
1022  }
1023 
1024  // Check derivatives, and consistency
1025  void checkSolutionVector( Vector<Real> &x, // Optimization space
1026  Vector<Real> &y, // Optimization space
1027  Vector<Real> &u, // Optimization space
1028  std::ostream &outStream = std::cout ) {
1032  if (obj_ != nullPtr) {
1033  outStream << "\nPerforming OptimizationProblem diagnostics." << std::endl << std::endl;
1034 
1035  outStream << "Checking vector operations in optimization vector space X." << std::endl;
1036  x.checkVector(y,u,true,outStream);
1037  }
1038  }
1039 
1040  void checkObjective( Vector<Real> &x, // Optimization space
1041  Vector<Real> &u, // Optimization space
1042  Vector<Real> &v, // Optimization space
1043  std::ostream &outStream = std::cout,
1044  const int numSteps = ROL_NUM_CHECKDERIV_STEPS,
1045  const int order = 1 ) {
1049  if (obj_ != nullPtr) {
1050  outStream << "\nPerforming OptimizationProblem diagnostics." << std::endl << std::endl;
1051 
1052  outStream << "Checking objective function." << std::endl;
1053  obj_->checkGradient(x,v,true,outStream,numSteps,order); outStream << std::endl;
1054  obj_->checkHessVec(x,u,true,outStream,numSteps,order); outStream << std::endl;
1055  obj_->checkHessSym(x,u,v,true,outStream); outStream << std::endl;
1056  }
1057  }
1058 
1059  void checkMultiplierVector( Vector<Real> &w, // Dual constraint space
1060  Vector<Real> &q, // Dual constraint space
1061  Vector<Real> &l, // Dual constraint space
1062  std::ostream &outStream = std::cout ) {
1066  if(con_ != nullPtr) {
1067  outStream << "\nPerforming OptimizationProblem diagnostics." << std::endl << std::endl;
1068 
1069  outStream << "Checking vector operations in constraint multiplier space C*." << std::endl;
1070  l.checkVector(q,w,true,outStream);
1071  }
1072  }
1073 
1074  void checkConstraint( Vector<Real> &x, // Optimization space
1075  Vector<Real> &u, // Optimization space
1076  Vector<Real> &v, // Optimization space
1077  Vector<Real> &c, // Constraint space
1078  Vector<Real> &l, // Dual constraint space
1079  std::ostream &outStream = std::cout,
1080  const int numSteps = ROL_NUM_CHECKDERIV_STEPS,
1081  const int order = 1 ) {
1085  if(con_ != nullPtr) {
1086  outStream << "\nPerforming OptimizationProblem diagnostics." << std::endl << std::endl;
1087 
1088  outStream << "Checking equality constraint." << std::endl;
1089  con_->checkApplyJacobian(x,v,c,true,outStream,numSteps,order); outStream << std::endl;
1090  con_->checkAdjointConsistencyJacobian(l,u,x,true,outStream); outStream << std::endl;
1091  con_->checkApplyAdjointHessian(x,l,v,u,true,outStream,numSteps,order); outStream << std::endl;
1092  }
1093  }
1094 
1095  // Check derivatives, and consistency
1096  void check( std::ostream &outStream = std::cout,
1097  const int numSteps = ROL_NUM_CHECKDERIV_STEPS,
1098  const int order = 1 ) {
1102 
1103  Ptr<Vector<Real>> x, y, u, v;
1104  try {
1105  x = sol_->clone(); x->randomize();
1106  y = sol_->clone(); y->randomize();
1107  u = sol_->clone(); u->randomize();
1108  v = sol_->clone(); v->randomize();
1109 
1110  checkSolutionVector(*x,*y,*u,outStream);
1111  checkObjective(*x,*u,*v,outStream,numSteps,order);
1112  }
1113  catch (std::exception &e) {
1114 // throw Exception::NotImplemented(">>> ROL::OptimizationProblem::check: Elementwise is not implemented for optimization space vectors");
1115  }
1116 
1117  if(con_ != nullPtr) {
1118  Ptr<Vector<Real>> c, l, w, q;
1119  try {
1120  c = mul_->dual().clone(); c->randomize();
1121  l = mul_->clone(); l->randomize();
1122  w = mul_->clone(); w->randomize();
1123  q = mul_->clone(); q->randomize();
1124 
1125  checkMultiplierVector(*w,*q,*l,outStream);
1126  checkConstraint(*x,*u,*v,*c,*l,outStream,numSteps,order);
1127  }
1128  catch (std::exception &e) {
1129  throw Exception::NotImplemented(">>> ROL::OptimizationProblem::check: Elementwise is not implemented for constraint space vectors");
1130  }
1131  }
1132  }
1133 
1134 }; // class OptimizationProblem
1135 
1136 } // namespace ROL
1137 
1138 #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_
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_
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)
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)
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_
std::vector< Ptr< BoundConstraint< Real > > > INTERMEDIATE_ibnd_
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)
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.
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_
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)
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< Ptr< BatchManager< Real > > > ecbman_
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
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)