Commit c91a07ed authored by frey_m's avatar frey_m
Browse files

Merge branch '504-file-header-for-optimiser-classes' into 'master'

Resolve "File header for Optimiser classes"

Closes #504

See merge request !323
parents 021aa428 71e5bb4e
//
// Class CommSplitter
// Role assignment according to strategy (that might use hardware
// network information).
//
// The CommSplitter splits the passed (usually MPI_COMM_WORLD) communicator
// into several comm groups using the colors provided by the splitting
// strategy.
// After construction each processor has an assigned role (optimizer, worker
// or pilot) and a set of communicators to send and receive tasks.
// The expected colors have the following meaning:
// - color[0] is shared by all my co-workers
// - color[1] is shared by the optimizer leader and the pilot
// - color[2] is shared by the worker leader and the pilot
// - color[3] is shared by all processors with the same role (used for
// broadcasts)
//
// Copyright (c) 2010 - 2013, Yves Ineichen, ETH Zürich
// All rights reserved
//
// Implemented as part of the PhD thesis
// "Toward massively parallel multi-objective optimization withapplication to
// particle accelerators" (https://doi.org/10.3929/ethz-a-009792359)
//
// This file is part of OPAL.
//
// OPAL is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// You should have received a copy of the GNU General Public License
// along with OPAL. If not, see <https://www.gnu.org/licenses/>.
//
#ifndef __COMM_SPLITTER__
#define __COMM_SPLITTER__
......@@ -10,24 +44,6 @@
//TODO: what is the performance difference between using MPI_COMM_WORLD and
// p2p communication vs. communicator groups??
/**
* \brief Role assignment according to strategy (that might use hardware
* network information).
*
* The CommSplitter splits the passed (usually MPI_COMM_WORLD) communicator
* into several comm groups using the colors provided by the splitting
* strategy.
* After construction each processor has an assigned role (optimizer, worker
* or pilot) and a set of communicators to send and receive tasks.
* The expected colors have the following meaning:
*
* - color[0] is shared by all my co-workers
* - color[1] is shared by the optimizer leader and the pilot
* - color[2] is shared by the worker leader and the pilot
* - color[3] is shared by all processors with the same role (used for
* broadcasts)
*
*/
template< class Strategy_t >
class CommSplitter : public Strategy_t {
......
//
// Class NDimMesh
//
// Copyright (c) 2010 - 2013, Yves Ineichen, ETH Zürich
// All rights reserved
//
// Implemented as part of the PhD thesis
// "Toward massively parallel multi-objective optimization withapplication to
// particle accelerators" (https://doi.org/10.3929/ethz-a-009792359)
//
// This file is part of OPAL.
//
// OPAL is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// You should have received a copy of the GNU General Public License
// along with OPAL. If not, see <https://www.gnu.org/licenses/>.
//
#ifndef __NDIM_MESH__
#define __NDIM_MESH__
......
//
// Class NoMasterGraph
// A simple empty master graph (no neighbors, every island works isolated).
//
// Copyright (c) 2010 - 2013, Yves Ineichen, ETH Zürich
// All rights reserved
//
// Implemented as part of the PhD thesis
// "Toward massively parallel multi-objective optimization withapplication to
// particle accelerators" (https://doi.org/10.3929/ethz-a-009792359)
//
// This file is part of OPAL.
//
// OPAL is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// You should have received a copy of the GNU General Public License
// along with OPAL. If not, see <https://www.gnu.org/licenses/>.
//
#ifndef __NO_MASTER_GRAPH__
#define __NO_MASTER_GRAPH__
#include <set>
/// A simple empty master graph (no neighbors, every island works isolated).
template < class TopoDiscoveryStrategy_t >
class NoMasterGraph : public TopoDiscoveryStrategy_t {
......
#ifndef __SOCIAL_NETWORK_GRAPH__
#define __SOCIAL_NETWORK_GRAPH__
#include <set>
#include <cstdint>
#include <boost/random/mersenne_twister.hpp>
#include <boost/random/discrete_distribution.hpp>
//
// Class SocialNetworkGraph
// Modeling social graph (Cartesian neighbors plus additional random
// link) as underlaying master network.
//
// @see MasterNode
//
// Due to its nice rumor spreading properties this master network is mimicking
// a social network graph (augmented grid) and solution states are distributed
// in a rumor fashion.
//
// Here, we use a simple mapping from processor ID's to 2D grid
// (determining neigborhood) assuming the total number of masters:
//
......@@ -15,17 +17,33 @@
// This is fine, because if we have topology info the masters are numbered
// in ascending order (done in comm splitter) and we can map them from 1D to
// 2D by index calculations.
//
// Copyright (c) 2010 - 2013, Yves Ineichen, ETH Zürich
// All rights reserved
//
// Implemented as part of the PhD thesis
// "Toward massively parallel multi-objective optimization withapplication to
// particle accelerators" (https://doi.org/10.3929/ethz-a-009792359)
//
// This file is part of OPAL.
//
// OPAL is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// You should have received a copy of the GNU General Public License
// along with OPAL. If not, see <https://www.gnu.org/licenses/>.
//
#ifndef __SOCIAL_NETWORK_GRAPH__
#define __SOCIAL_NETWORK_GRAPH__
#include <set>
#include <cstdint>
#include <boost/random/mersenne_twister.hpp>
#include <boost/random/discrete_distribution.hpp>
/**
* \brief Modeling social graph (Cartesian neighbors plus additional random
* link) as underlaying master network.
*
* @see MasterNode
*
* Due to its nice rumor spreading properties this master network is mimicking
* a social network graph (augmented grid) and solution states are distributed
* in a rumor fashion.
*/
template < class TopoDiscoveryStrategy_t >
class SocialNetworkGraph : public TopoDiscoveryStrategy_t {
......
//
// Class MasterNode
// Implements a node in the network of all pilots, exposing store and
// collect operations on a specific set of neighbors.
//
// Using the neighbor strategy a set of neighbors we collect solution state
// from (and they collect from us) is defined. Using this set of neighbors the
// solution states propagate throughout the network. The store and collect
// operations are implemented using one sided MPI communication methods
// (simulating shared memory).
// A revision number is used to prevent receiving previously collected
// solution states from neighbors.
//
// Copyright (c) 2010 - 2013, Yves Ineichen, ETH Zürich
// All rights reserved
//
// Implemented as part of the PhD thesis
// "Toward massively parallel multi-objective optimization withapplication to
// particle accelerators" (https://doi.org/10.3929/ethz-a-009792359)
//
// This file is part of OPAL.
//
// OPAL is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// You should have received a copy of the GNU General Public License
// along with OPAL. If not, see <https://www.gnu.org/licenses/>.
//
#ifndef __MASTER_NODE__
#define __MASTER_NODE__
......@@ -18,19 +48,6 @@
//XXX: SolutionState_t must be serializable! (call
// SerializableSolutionState_t?)
/**
* \brief Implements a node in the network of all pilots, exposing store and
* collect operations on a specific set of neighbors.
*
* Using the neighbor strategy a set of neighbors we collect solution state
* from (and they collect from us) is defined. Using this set of neighbors the
* solution states propagate throughout the network. The store and collect
* operations are implemented using one sided MPI communication methods
* (simulating shared memory).
* A revision number is used to prevent receiving previously collected
* solution states from neighbors.
*
*/
template <
class SolutionState_t
, class NeighborStrategy_t
......
//
// Types in namespace Comm
//
// Copyright (c) 2010 - 2013, Yves Ineichen, ETH Zürich
// All rights reserved
//
// Implemented as part of the PhD thesis
// "Toward massively parallel multi-objective optimization withapplication to
// particle accelerators" (https://doi.org/10.3929/ethz-a-009792359)
//
// This file is part of OPAL.
//
// OPAL is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// You should have received a copy of the GNU General Public License
// along with OPAL. If not, see <https://www.gnu.org/licenses/>.
//
#ifndef __COMM_TYPES__
#define __COMM_TYPES__
......
//
// Class Expression
// Expression to be evaluated in the framework.
//
// @see GlobalFunctions.h
//
// This class uses the Boost Spirit parser to parse and evaluate string
// expressions (objectives or constraints).
// Custom functions called in the expression should be registered by the
// driver. A collection of C math default functions is always included.
// For constraints the operator type can be queried.
//
// Copyright (c) 2010 - 2013, Yves Ineichen, ETH Zürich
// All rights reserved
//
// Implemented as part of the PhD thesis
// "Toward massively parallel multi-objective optimization withapplication to
// particle accelerators" (https://doi.org/10.3929/ethz-a-009792359)
//
// This file is part of OPAL.
//
// OPAL is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// You should have received a copy of the GNU General Public License
// along with OPAL. If not, see <https://www.gnu.org/licenses/>.
//
#ifndef __EXPRESSION_H__
#define __EXPRESSION_H__
......@@ -62,16 +91,6 @@ namespace Expressions {
#include "Expression/GlobalFunctions.h"
/**
* \brief Expression to be evaluated in the framework.
* @see GlobalFunctions.h
*
* This class uses the Boost Spirit parser to parse and evaluate string
* expressions (objectives or constraints).
* Custom functions called in the expression should be registered by the
* driver. A collection of C math default functions is always included.
* For constraints the operator type can be queried.
*/
class Expression {
public:
......
//
// Struct FromFile
// Simple functor that reads vector data from a file. If the file contains
// more than one value the sum is returned.
// \f[
// result = \sum_{i=0}^n value_i
// \f]
//
// Copyright (c) 2010 - 2013, Yves Ineichen, ETH Zürich
// All rights reserved
//
// Implemented as part of the PhD thesis
// "Toward massively parallel multi-objective optimization withapplication to
// particle accelerators" (https://doi.org/10.3929/ethz-a-009792359)
//
// This file is part of OPAL.
//
// OPAL is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// You should have received a copy of the GNU General Public License
// along with OPAL. If not, see <https://www.gnu.org/licenses/>.
//
#include "Expression/FromFile.h"
/// reads a simple list of double values
......
//
// Struct FromFile
// Simple functor that reads vector data from a file. If the file contains
// more than one value the sum is returned.
// \f[
// result = \sum_{i=0}^n value_i
// \f]
//
// Copyright (c) 2010 - 2013, Yves Ineichen, ETH Zürich
// All rights reserved
//
// Implemented as part of the PhD thesis
// "Toward massively parallel multi-objective optimization withapplication to
// particle accelerators" (https://doi.org/10.3929/ethz-a-009792359)
//
// This file is part of OPAL.
//
// OPAL is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// You should have received a copy of the GNU General Public License
// along with OPAL. If not, see <https://www.gnu.org/licenses/>.
//
#ifndef __FROMFILE_H__
#define __FROMFILE_H__
......@@ -16,14 +41,6 @@
#include "Util/OptPilotException.h"
#include "Expression/Parser/function.hpp"
/**
* Simple functor that reads vector data from a file. If the file contains
* more than one value the sum is returned.
* \f[
* result = \sum_{i=0}^n value_i
* \f]
*/
struct FromFile {
static const std::string name;
......
//
// Namespace GlobalFunctions
// Defines multiple expressions to be evaluated in
// objectives.
//
// Copyright (c) 2010 - 2013, Yves Ineichen, ETH Zürich
// All rights reserved
//
// Implemented as part of the PhD thesis
// "Toward massively parallel multi-objective optimization withapplication to
// particle accelerators" (https://doi.org/10.3929/ethz-a-009792359)
//
// This file is part of OPAL.
//
// OPAL is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// You should have received a copy of the GNU General Public License
// along with OPAL. If not, see <https://www.gnu.org/licenses/>.
//
#ifndef __GLOBAL_FUNCTIONS_H__
#define __GLOBAL_FUNCTIONS_H__
......
//
// Struct ProbeVariable
//
// Copyright (c) 2010 - 2013, Yves Ineichen, ETH Zürich
// All rights reserved
//
// Implemented as part of the PhD thesis
// "Toward massively parallel multi-objective optimization withapplication to
// particle accelerators" (https://doi.org/10.3929/ethz-a-009792359)
//
// This file is part of OPAL.
//
// OPAL is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// You should have received a copy of the GNU General Public License
// along with OPAL. If not, see <https://www.gnu.org/licenses/>.
//
#ifndef __PROBEVARIABLE_H__
#define __PROBEVARIABLE_H__
......
//
// Struct PythonExpression
// Execute a python script using all given arguments (except for the first
// being the script name) and return the value of the "result" variable in
// the python script.
// Expression arguments can be accessed in the Python script using the vector
// variable "arguments", like i.e. in file "test.py":
// \verbatim
// result = 2.0 * arguments[0]
// \endverbatim
// to double the value passed as second argument to the Python expression.
// For example the expression
// \verbatim
// EXPR="python("test.py", 15.0)";
// \endverbatim
// evaluates to a value of 30.0 (test.py contains the line shown above).
//
// Copyright (c) 2010 - 2013, Yves Ineichen, ETH Zürich
// All rights reserved
//
// Implemented as part of the PhD thesis
// "Toward massively parallel multi-objective optimization withapplication to
// particle accelerators" (https://doi.org/10.3929/ethz-a-009792359)
//
// This file is part of OPAL.
//
// OPAL is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// You should have received a copy of the GNU General Public License
// along with OPAL. If not, see <https://www.gnu.org/licenses/>.
//
#ifndef __PYTHON_EXPR_H__
#define __PYTHON_EXPR_H__
......@@ -15,22 +49,6 @@
using namespace boost::python;
/**
* Execute a python script using all given arguments (except for the first
* being the script name) and return the value of the "result" variable in
* the python script.
* Expression arguments can be accessed in the Python script using the vector
* variable "arguments", like i.e. in file "test.py":
* \verbatim
result = 2.0 * arguments[0]
\endverbatim
* to double the value passed as second argument to the Python expression.
* For example the expression
* \verbatim
EXPR="python("test.py", 15.0)";
\endverbatim
* evaluates to a value of 30.0 (test.py contains the line shown above).
*/
struct PythonExpression {
Expressions::Result_t operator()(client::function::arguments_t args) {
......
//
// Struct SDDSVariable
// A simple expression to get SDDS (filename) value near a
// specific position (ref_val, default: spos) of a reference
// variable (ref_name) for a variable (var_name). Possible
// argument orders:
// args = [var_name, ref_val, filename]
// args = [var_name, ref_name, ref_val, filename]
//
// Copyright (c) 2010 - 2013, Yves Ineichen, ETH Zürich
// All rights reserved
//
// Implemented as part of the PhD thesis
// "Toward massively parallel multi-objective optimization withapplication to
// particle accelerators" (https://doi.org/10.3929/ethz-a-009792359)
//
// This file is part of OPAL.
//
// OPAL is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// You should have received a copy of the GNU General Public License
// along with OPAL. If not, see <https://www.gnu.org/licenses/>.
//
#ifndef __SDDSVARIABLE_H__
#define __SDDSVARIABLE_H__
......@@ -13,14 +39,6 @@
#include "Expression/Parser/function.hpp"
/**
* A simple expression to get SDDS (filename) value near a
* specific position (ref_val, default: spos) of a reference
* variable (ref_name) for a variable (var_name). Possible
* argument orders:
* args = [var_name, ref_val, filename]
* args = [var_name, ref_name, ref_val, filename]
*/
struct SDDSVariable {
static const std::string name;
......
//
// Struct SumErrSq
// A simple expression computing the sum of all measurement errors (given as
// first and third argument) for a variable (second argument) according to
//
// \f[
// result = \frac{1}{n} * \sqrt{\sum_{i=0}^n (measurement_i - value_i)^2}
// \f]
//
// Copyright (c) 2010 - 2013, Yves Ineichen, ETH Zürich
// All rights reserved
//
// Implemented as part of the PhD thesis
// "Toward massively parallel multi-objective optimization withapplication to
// particle accelerators" (https://doi.org/10.3929/ethz-a-009792359)
//
// This file is part of OPAL.
//
// OPAL is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// You should have received a copy of the GNU General Public License
// along with OPAL. If not, see <https://www.gnu.org/licenses/>.
//
#ifndef __SUMERRSQ_H__
#define __SUMERRSQ_H__
......@@ -23,15 +49,7 @@ public:
friend std::istream & operator>>(std::istream & stream, Measurement & measurement);
};
/**
* A simple expression computing the sum of all measurement errors (given as
* first and third argument) for a variable (second argument) according to
*
* \f[
* result = \frac{1}{n} * \sqrt{\sum_{i=0}^n (measurement_i - value_i)^2}
* \f]
*
*/
struct SumErrSq {
static const std::string name;
......
//
// Struct BlendCrossover
// BLX-alpha (interval schemata)
// Eshelman and Schaffer (1993)
// Pick random solution in interval
//
// [ x_i^(1,t) - \alpha(x_i^(2,t) - x_i^(1,t)),
// x_i^(2,t) + \alpha((x_i^(2,t) - x_i^(1,t)) ]
//
// at generation t.
//
// Copyright (c) 2010 - 2013, Yves Ineichen, ETH Zürich
// All rights reserved
//
// Implemented as part of the PhD thesis
// "Toward massively parallel multi-objective optimization withapplication to
// particle accelerators" (https://doi.org/10.3929/ethz-a-009792359)
//
// This file is part of OPAL.
//
// OPAL is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// You should have received a copy of the GNU General Public License
// along with OPAL. If not, see <https://www.gnu.org/licenses/>.
//
#include "boost/smart_ptr.hpp"
#include "Util/CmdArguments.h"
#include <cmath>
/**
* BLX-alpha (interval schemata)
* Eshelman and Schaffer (1993)
* Pick random solution in interval
*
* [ x_i^(1,t) - \alpha(x_i^(2,t) - x_i^(1,t)),
* x_i^(2,t) + \alpha((x_i^(2,t) - x_i^(1,t)) ]