Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
OPAL
src
Commits
35bbee5b
Commit
35bbee5b
authored
Apr 08, 2020
by
frey_m
Browse files
add header to optimiser classes
parent
021aa428
Changes
95
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
528 additions
and
135 deletions
+528
-135
optimizer/Comm/CommSplitter.h
optimizer/Comm/CommSplitter.h
+34
-18
optimizer/Comm/MasterGraph/NDimMesh.h
optimizer/Comm/MasterGraph/NDimMesh.h
+20
-0
optimizer/Comm/MasterGraph/NoMasterGraph.h
optimizer/Comm/MasterGraph/NoMasterGraph.h
+21
-1
optimizer/Comm/MasterGraph/SocialNetworkGraph.h
optimizer/Comm/MasterGraph/SocialNetworkGraph.h
+37
-19
optimizer/Comm/MasterNode.h
optimizer/Comm/MasterNode.h
+30
-13
optimizer/Comm/types.h
optimizer/Comm/types.h
+20
-0
optimizer/Expression/Expression.h
optimizer/Expression/Expression.h
+29
-10
optimizer/Expression/FromFile.cpp
optimizer/Expression/FromFile.cpp
+25
-0
optimizer/Expression/FromFile.h
optimizer/Expression/FromFile.h
+25
-8
optimizer/Expression/GlobalFunctions.h
optimizer/Expression/GlobalFunctions.h
+22
-0
optimizer/Expression/ProbeVariable.h
optimizer/Expression/ProbeVariable.h
+20
-0
optimizer/Expression/PythonExpr.h
optimizer/Expression/PythonExpr.h
+34
-16
optimizer/Expression/SDDSVariable.h
optimizer/Expression/SDDSVariable.h
+26
-8
optimizer/Expression/SumErrSq.h
optimizer/Expression/SumErrSq.h
+27
-9
optimizer/Optimizer/EA/BlendCrossover.h
optimizer/Optimizer/EA/BlendCrossover.h
+28
-10
optimizer/Optimizer/EA/FixedPisaNsga2.h
optimizer/Optimizer/EA/FixedPisaNsga2.h
+33
-15
optimizer/Optimizer/EA/FixedPisaNsga2.tcc
optimizer/Optimizer/EA/FixedPisaNsga2.tcc
+32
-0
optimizer/Optimizer/EA/IndependentBitMutation.h
optimizer/Optimizer/EA/IndependentBitMutation.h
+21
-1
optimizer/Optimizer/EA/Individual.h
optimizer/Optimizer/EA/Individual.h
+24
-7
optimizer/Optimizer/EA/NaiveOnePointCrossover.h
optimizer/Optimizer/EA/NaiveOnePointCrossover.h
+20
-0
No files found.
optimizer/Comm/CommSplitter.h
View file @
35bbee5b
//
// 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
{
...
...
optimizer/Comm/MasterGraph/NDimMesh.h
View file @
35bbee5b
//
// 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__
...
...
optimizer/Comm/MasterGraph/NoMasterGraph.h
View file @
35bbee5b
//
// 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
{
...
...
optimizer/Comm/MasterGraph/SocialNetworkGraph.h
View file @
35bbee5b
//
// 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:
//
// n_m = n_g * n_g
//
// 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__
...
...
@@ -7,25 +44,6 @@
#include <boost/random/mersenne_twister.hpp>
#include <boost/random/discrete_distribution.hpp>
// Here, we use a simple mapping from processor ID's to 2D grid
// (determining neigborhood) assuming the total number of masters:
//
// n_m = n_g * n_g
//
// 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.
/**
* \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
{
...
...
optimizer/Comm/MasterNode.h
View file @
35bbee5b
//
// 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
...
...
optimizer/Comm/types.h
View file @
35bbee5b
//
// 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__
...
...
optimizer/Expression/Expression.h
View file @
35bbee5b
//
// 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:
...
...
optimizer/Expression/FromFile.cpp
View file @
35bbee5b
//
// 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
...
...
optimizer/Expression/FromFile.h
View file @
35bbee5b
//
// 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
;
...
...
optimizer/Expression/GlobalFunctions.h
View file @
35bbee5b
//
// 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__
...
...
optimizer/Expression/ProbeVariable.h
View file @
35bbee5b
//
// 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__
...
...
optimizer/Expression/PythonExpr.h
View file @
35bbee5b
//
// 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
)
{
...
...
optimizer/Expression/SDDSVariable.h
View file @
35bbee5b
//
// 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
;
...
...
optimizer/Expression/SumErrSq.h
View file @
35bbee5b
//
// 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
;
...
...
optimizer/Optimizer/EA/BlendCrossover.h
View file @
35bbee5b
//
// 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)) ]
*
* at generation t.