46 std::vector<std::vector<Real>> pts;
47 std::vector<Real> wts;
50 pts.push_back(*(atom.
getAtom(i)));
60 pt = pts[i]; ind.clear();
64 err += std::pow(pt[d] - pts[j][d],2);
70 pts[i][d] += pts[j][d];
75 if ( ind.size() > 0 ) {
77 pts[i][d] /= (Real)(ind.size()+1);
79 for (
int k = ind.size()-1; k >= 0; k--) {
80 pts.erase(pts.begin()+ind[k]);
81 wts.erase(wts.begin()+ind[k]);
87 Real psum = 0.0, sum = 0.0;
105 std::ostream &outStream = std::cout)
109 ROL::ParameterList &list = parlist.sublist(
"SOL").sublist(
"Sample Generator").sublist(
"SROM");
111 adaptive_ = list.get(
"Adaptive Sampling",
false);
112 numNewSamples_ = list.get(
"Number of New Samples Per Adaptation",0);
113 ptol_ = list.get(
"Probability Tolerance",1.e2*std::sqrt(ROL_EPSILON<Real>()));
114 atol_ = list.get(
"Atom Tolerance",1.e2*std::sqrt(ROL_EPSILON<Real>()));
115 bool presolve = list.get(
"Presolve for Atom Locations",
false);
123 Ptr<ProbabilityVector<Real>> prob, prob_lo, prob_hi, prob_eq;
124 Ptr<AtomVector<Real>> atom, atom_lo, atom_hi, atom_eq;
125 Ptr<Vector<Real>> x, x_lo, x_hi, x_eq;
126 initialize_vectors(prob,prob_lo,prob_hi,prob_eq,atom,atom_lo,atom_hi,atom_eq,x,x_lo,x_hi,x_eq,bman);
127 Ptr<Vector<Real>> l = makePtr<SingletonVector<Real>>(0.0);
129 Ptr<BoundConstraint<Real>> bnd = makePtr<Bounds<Real>>(x_lo,x_hi);
130 Ptr<Constraint<Real>> con = makePtr<ScalarLinearConstraint<Real>>(x_eq,1.0);
132 ROL::ParameterList pslist(list);
133 pslist.sublist(
"Step").set(
"Type",
"Trust Region");
137 optSolver.
solve(outStream);
142 optProblem.
check(outStream);
144 optSolver.
solve(outStream);
154 typw.clear(); typx.clear();
157 Real mean = 1, var = 1, one(1);
159 mean = std::abs(
dist_[j]->moment(1));
160 var =
dist_[j]->moment(2) - mean*mean;
161 mean = ((mean > ROL_EPSILON<Real>()) ? mean : std::sqrt(var));
162 mean = ((mean > ROL_EPSILON<Real>()) ? mean : one);
183 std::vector<Real> typx, typw;
190 Real lo = 0., hi = 0.;
193 lo =
dist_[j]->lowerBound();
194 hi =
dist_[j]->upperBound();
196 pt[i*
dimension_ + j] =
dist_[j]->invertCDF((Real)rand()/(Real)RAND_MAX);
203 prob = makePtr<PrimalProbabilityVector<Real>>(
204 makePtr<std::vector<Real>>(wt),bman,
205 makePtr<std::vector<Real>>(typw));
206 atom = makePtr<PrimalAtomVector<Real>>(
208 makePtr<std::vector<Real>>(typx));
209 vec = makePtr<SROMVector<Real>>(prob,atom);
211 prob_lo = makePtr<PrimalProbabilityVector<Real>>(
212 makePtr<std::vector<Real>>(wt_lo),bman,
213 makePtr<std::vector<Real>>(typw));
214 prob_hi = makePtr<PrimalProbabilityVector<Real>>(
215 makePtr<std::vector<Real>>(wt_hi),bman,
216 makePtr<std::vector<Real>>(typw));
218 atom_lo = makePtr<PrimalAtomVector<Real>>(
220 makePtr<std::vector<Real>>(typx));
221 atom_hi = makePtr<PrimalAtomVector<Real>>(
223 makePtr<std::vector<Real>>(typx));
225 vec_lo = makePtr<SROMVector<Real>>(prob_lo,atom_lo);
226 vec_hi = makePtr<SROMVector<Real>>(prob_hi,atom_hi);
228 prob_eq = makePtr<DualProbabilityVector<Real>>(
229 makePtr<std::vector<Real>>(wt_eq),bman,
230 makePtr<std::vector<Real>>(typw));
231 atom_eq = makePtr<DualAtomVector<Real>>(
233 makePtr<std::vector<Real>>(typx));
234 vec_eq = makePtr<SROMVector<Real>>(prob_eq,atom_eq);
239 const bool optProb,
const bool optAtom,
240 ROL::ParameterList &list)
const {
241 std::vector<Ptr<Objective<Real>>> obj_vec;
243 Real scale = list.get(
"CDF Smoothing Parameter",1.e-2);
246 std::vector<int> tmp_order
247 = ROL::getArrayFromStringParameter<int>(list,
"Moments");
248 std::vector<int> order(tmp_order.size(),0);
249 for (
unsigned int i = 0; i < tmp_order.size(); i++) {
250 order[i] =
static_cast<int>(tmp_order[i]);
254 std::vector<Real> tmp_coeff
255 = ROL::getArrayFromStringParameter<Real>(list,
"Coefficients");
256 std::vector<Real> coeff(2,0.);
257 coeff[0] = tmp_coeff[0]; coeff[1] = tmp_coeff[1];
258 return makePtr<LinearCombinationObjective<Real>>(coeff,obj_vec);