28 _constr_penalty (5.e1),
29 _initial_rel_step (5.e-1),
30 _asymptote_reduction (0.7),
31 _asymptote_expansion (1.2),
32 _max_inner_iters (15) {
34 #if MAST_ENABLE_GCMMA == 0 35 libmesh_error_msg(
"MAST configured without GCMMA support.");
43 if (nm ==
"constraint_penalty") {
45 libmesh_assert_greater(val, 0.);
49 else if (nm ==
"initial_rel_step") {
51 libmesh_assert_greater(val, 0.);
55 else if (nm ==
"asymptote_reduction") {
57 libmesh_assert_greater(val, 0.);
61 else if (nm ==
"asymptote_expansion") {
63 libmesh_assert_greater(val, 0.);
69 <<
"Unrecognized real parameter: " << nm << std::endl;
76 if (nm ==
"max_inner_iters") {
78 libmesh_assert_greater(val, 0);
84 <<
"Unrecognized integer parameter: " << nm << std::endl;
91 #if MAST_ENABLE_GCMMA == 1 101 libmesh_assert_greater(N, 0);
103 std::vector<Real> XVAL(N, 0.), XOLD1(N, 0.), XOLD2(N, 0.),
104 XMMA(N, 0.), XMIN(N, 0.), XMAX(N, 0.), XLOW(N, 0.), XUPP(N, 0.),
105 ALFA(N, 0.), BETA(N, 0.), DF0DX(N, 0.),
106 A(M, 0.), B(M, 0.), C(M, 0.), Y(M, 0.), RAA(M, 0.), ULAM(M, 0.),
107 FVAL(M, 0.), FAPP(M, 0.), FNEW(M, 0.), FMAX(M, 0.),
108 DFDX(M*N, 0.), P(M*N, 0.), Q(M*N, 0.), P0(N, 0.), Q0(N, 0.),
109 UU(M, 0.), GRADF(M, 0.), DSRCH(M, 0.), HESSF(M*(M+1)/2, 0.),
110 f0_iters(n_rel_change_iters);
112 std::vector<int> IYFREE(M, 0);
113 std::vector<bool> eval_grads(M,
false);
208 for (
unsigned int i=0; i<N; i++)
209 if (max_x < fabs(XVAL[i]))
210 max_x = fabs(XVAL[i]);
216 bool terminate =
false, inner_terminate=
false;
230 std::fill(eval_grads.begin(), eval_grads.end(),
true);
233 FVAL, eval_grads, DFDX);
241 raasta_(&M, &N, &RAA0, &RAA[0], &XMIN[0], &XMAX[0], &DF0DX[0], &DFDX[0]);
242 asympg_(&ITER, &M, &N, &ALBEFA, &GHINIT, &GHDECR, &GHINCR,
243 &XVAL[0], &XMIN[0], &XMAX[0], &XOLD1[0], &XOLD2[0],
244 &XLOW[0], &XUPP[0], &ALFA[0], &BETA[0]);
253 inner_terminate =
false;
254 while (!inner_terminate) {
259 mmasug_(&ITER, &M, &N, &GEPS, &IYFREE[0], &XVAL[0], &XMMA[0],
260 &XMIN[0], &XMAX[0], &XLOW[0], &XUPP[0], &ALFA[0], &BETA[0],
261 &A[0], &B[0], &C[0], &Y[0], &Z, &RAA0, &RAA[0], &ULAM[0],
262 &F0VAL, &FVAL[0], &F0APP, &FAPP[0], &FMAX[0], &DF0DX[0], &DFDX[0],
263 &P[0], &Q[0], &P0[0], &Q0[0], &UU[0], &GRADF[0], &DSRCH[0], &HESSF[0]);
268 std::fill(eval_grads.begin(), eval_grads.end(),
false);
271 FNEW, eval_grads, DFDX);
275 std::vector<Real> XMMA_new(XMMA);
277 while (FNEW[0] > 1.e2) {
278 libMesh::out <<
"*** Backtracking: frac = " 280 <<
" constr: " << FNEW[0]
282 for (
unsigned int i=0; i<XMMA.size(); i++)
283 XMMA_new[i] = XOLD1[i] + frac*(XMMA[i]-XOLD1[i]);
287 FNEW, eval_grads, DFDX);
290 for (
unsigned int i=0; i<XMMA.size(); i++)
291 XMMA[i] = XMMA_new[i];
294 if (INNER >= INNMAX) {
296 <<
"** Max Inner Iter Reached: Terminating! Inner Iter = " 297 << INNER << std::endl;
298 inner_terminate =
true;
304 conser_( &M, &ICONSE, &GEPS, &F0NEW, &F0APP, &FNEW[0], &FAPP[0]);
307 <<
"** Conservative Solution: Terminating! Inner Iter = " 308 << INNER << std::endl;
309 inner_terminate =
true;
317 raaupd_( &M, &N, &GEPS, &XMMA[0], &XVAL[0],
318 &XMIN[0], &XMAX[0], &XLOW[0], &XUPP[0],
319 &F0NEW, &FNEW[0], &F0APP, &FAPP[0], &RAA0, &RAA[0]);
330 xupdat_( &N, &ITER, &XMMA[0], &XVAL[0], &XOLD1[0], &XOLD2[0]);
331 fupdat_( &M, &F0NEW, &FNEW[0], &F0VAL, &FVAL[0]);
336 f0_iters[(ITE-1)%n_rel_change_iters] = F0VAL;
344 <<
"GCMMA: Reached maximum iterations, terminating! " 350 bool rel_change_conv =
true;
351 Real f0_curr = f0_iters[n_rel_change_iters-1];
353 for (
unsigned int i=0; i<n_rel_change_iters-1; i++) {
354 if (f0_curr > sqrt(GEPS))
355 rel_change_conv = (rel_change_conv &&
356 fabs(f0_iters[i]-f0_curr)/fabs(f0_curr) < GEPS);
358 rel_change_conv = (rel_change_conv &&
359 fabs(f0_iters[i]-f0_curr) < GEPS);
361 if (rel_change_conv) {
363 <<
"GCMMA: Converged relative change tolerance, terminating! " 370 #endif //MAST_ENABLE_GCMMA == 1 376 const std::vector<Real>& XVAL,
377 const std::vector<Real>& XMIN,
378 const std::vector<Real>& XMAX,
379 const std::vector<Real>& XLOW,
380 const std::vector<Real>& XUPP,
381 const std::vector<Real>& ALFA,
382 const std::vector<Real>& BETA) {
void xupdat_(int *N, int *ITER, double *XMMA, double *XVAL, double *XOLD1, double *XOLD2)
void sanitize_parallel()
make sure that the analysis is setup consistently across all parallel processes
virtual void set_real_parameter(const std::string &nm, Real val)
void raasta_(int *M, int *N, double *RAA0, double *RAA, double *XMIN, double *XMAX, double *DF0DX, double *DFDX)
Real _asymptote_reduction
void raaupd_(int *M, int *N, double *GEPS, double *XMMA, double *XVAL, double *XMIN, double *XMAX, double *XLOW, double *XUPP, double *F0NEW, double *FNEW, double *F0APP, double *FAPP, double *RAA0, double *RAA)
void conser_(int *M, int *ICONSE, double *GEPS, double *F0NEW, double *F0APP, double *FNEW, double *FAPP)
void asympg_(int *ITER, int *M, int *N, double *ALBEFA, double *GHINIT, double *GHDECR, double *GHINCR, double *XVAL, double *XMIN, double *XMAX, double *XOLD1, double *XOLD2, double *XLOW, double *XUPP, double *ALFA, double *BETA)
unsigned int _max_inner_iters
unsigned int max_iters() const
unsigned int n_ineq() const
void mmasug_(int *ITER, int *M, int *N, double *GEPS, int *IYFREE, double *XVAL, double *XMMA, double *XMIN, double *XMAX, double *XLOW, double *XUPP, double *ALFA, double *BETA, double *A, double *B, double *C, double *Y, double *Z, double *RAA0, double *RAA, double *ULAM, double *F0VAL, double *FVAL, double *F0APP, double *FAPP, double *FMAX, double *DF0DX, double *DFDX, double *P, double *Q, double *P0, double *Q0, double *UU, double *GRADF, double *DSRCH, double *HESSF)
virtual void _evaluate_wrapper(const std::vector< Real > &dvars, Real &obj, bool eval_obj_grad, std::vector< Real > &obj_grad, std::vector< Real > &fvals, std::vector< bool > &eval_grads, std::vector< Real > &grads)
This serves as a wrapper around evaluate() and makes sure that the derived class's implementation is ...
Provides the basic interface API for classes the provide implement optimization problems.
GCMMAOptimizationInterface()
unsigned int n_vars() const
Real _asymptote_expansion
virtual void _output_wrapper(unsigned int iter, const std::vector< Real > &x, Real obj, const std::vector< Real > &fval, bool if_write_to_optim_file)
This serves as a wrapper around evaluate() and makes sure that the derived class's implementation is ...
virtual void set_integer_parameter(const std::string &nm, int val)
void _output_iteration_data(unsigned int i, const std::vector< Real > &XVAL, const std::vector< Real > &XMIN, const std::vector< Real > &XMAX, const std::vector< Real > &XLOW, const std::vector< Real > &XUPP, const std::vector< Real > &ALFA, const std::vector< Real > &BETA)
MAST::FunctionEvaluation * _feval
virtual void _init_dvar_wrapper(std::vector< Real > &x, std::vector< Real > &xmin, std::vector< Real > &xmax)
This serves as a wrapper around init_dvar() and makes sure that the derived class's implementation pr...
unsigned int n_eq() const
unsigned int n_iters_relative_change() const
void fupdat_(int *M, double *F0NEW, double *FNEW, double *F0VAL, double *FVAL)