20 #ifndef __mast_optimization_discrete_aggregation_h__ 21 #define __mast_optimization_discrete_aggregation_h__ 28 #include <libmesh/parallel.h> 31 namespace Optimization {
32 namespace Aggregation {
42 template <
typename ScalarType>
45 const std::vector<ScalarType> &vec,
56 for (
uint_t i=0; i<vec.size(); i++) {
58 v += exp(-p * (vec[i] - v_min));
63 v = v_min - log(v) / p;
78 template <
typename ScalarType>
81 const std::vector<ScalarType> &vec,
93 for (
uint_t i=0; i<vec.size(); i++) {
95 v += exp(-p * (vec[i] - v_min));
100 v = exp(-p * (vec[i] - v_min)) / v;
117 template <
typename ScalarType>
120 const std::vector<ScalarType> &vec,
121 const std::vector<ScalarType> &dvec,
133 for (
uint_t i=0; i<vec.size(); i++) {
135 dv += exp(-p * (vec[i] - v_min)) * dvec[i];
136 v += exp(-p * (vec[i] - v_min));
157 template <
typename ScalarType>
160 const std::vector<ScalarType> &vec,
171 for (
uint_t i=0; i<vec.size(); i++) {
173 denom += exp(-p * (vec[i] - v_min));
190 template <
typename ScalarType>
195 const ScalarType &denom,
196 const ScalarType &v_min) {
198 return exp(-p * (vec[i] - v_min)) / denom;
215 template <
typename ScalarType>
218 const std::vector<ScalarType> &vec,
219 const std::vector<ScalarType> &dvec,
221 const ScalarType &denom,
222 const ScalarType &v_min) {
227 for (
uint_t i=0; i<vec.size(); i++) {
229 dv += exp(-p * (vec[i] - v_min)) * dvec[i];
246 template <
typename ScalarType>
249 const std::vector<ScalarType> &vec,
260 for (
uint_t i=0; i<vec.size(); i++) {
262 v += exp(p * (vec[i] - v_max));
267 v = v_max + log(v) / p;
282 template <
typename ScalarType>
285 const std::vector<ScalarType> &vec,
297 for (
uint_t i=0; i<vec.size(); i++) {
299 v += exp(p * (vec[i] - v_max));
304 v = exp(p * (vec[i] - v_max)) / v;
321 template <
typename ScalarType>
324 const std::vector<ScalarType> &vec,
325 const std::vector<ScalarType> &dvec,
337 for (
uint_t i=0; i<vec.size(); i++) {
339 dv += exp(p * (vec[i] - v_max)) * dvec[i];
340 v += exp(p * (vec[i] - v_max));
360 template <
typename ScalarType>
363 const std::vector<ScalarType> &vec,
374 for (
uint_t i=0; i<vec.size(); i++) {
376 denom += exp(p * (vec[i] - v_max));
393 template <
typename ScalarType>
398 const ScalarType &denom,
399 const ScalarType &v_max) {
401 return exp(p * (vec[i] - v_max)) / denom;
418 template <
typename ScalarType>
421 const std::vector<ScalarType> &vec,
422 const std::vector<ScalarType> &dvec,
424 const ScalarType &denom,
425 const ScalarType &v_max) {
430 for (
uint_t i=0; i<vec.size(); i++) {
432 dv += exp(p * (vec[i] - v_max)) * dvec[i];
445 #endif // __mast_optimization_discrete_aggregation_h__ real_t comm_max(const libMesh::Parallel::Communicator &comm, const std::vector< real_t > &v)
void aggregate_minimum_denominator(const libMesh::Parallel::Communicator *comm, const std::vector< ScalarType > &vec, const real_t p, ScalarType &denom, ScalarType &v_min)
Computes the denominator of the sensitivity of aggregated minimum function for use in later sensitivi...
ScalarType aggregate_minimum(const libMesh::Parallel::Communicator *comm, const std::vector< ScalarType > &vec, const real_t p)
computes aggregated minimum of values specified in vector vec.
void aggregate_maximum_denominator(const libMesh::Parallel::Communicator *comm, const std::vector< ScalarType > &vec, const real_t p, ScalarType &denom, ScalarType &v_max)
Computes the denominator of the sensitivity of aggregated maximum function for use in later sensitivi...
real_t real_minimum(const std::vector< real_t > &vec)
computes minimum of vector
ScalarType aggregate_minimum_sensitivity(const libMesh::Parallel::Communicator *comm, const std::vector< ScalarType > &vec, const uint_t i, const real_t p)
computes sensitivity of aggregated minimum of values specified in vector vec with respect to i th val...
ScalarType aggregate_maximum_sensitivity(const libMesh::Parallel::Communicator *comm, const std::vector< ScalarType > &vec, const uint_t i, const real_t p)
computes sensitivity of aggregated maximum of values specified in vector vec with respect to i th val...
ScalarType aggregate_maximum(const libMesh::Parallel::Communicator *comm, const std::vector< ScalarType > &vec, const real_t p)
computes aggregated maximum of values specified in vector vec.
real_t real_maximum(const std::vector< real_t > &vec)
computes maximum of vector
real_t comm_min(const libMesh::Parallel::Communicator &comm, const std::vector< real_t > &v)
void comm_sum(const libMesh::Parallel::Communicator &comm, real_t &v)