OPAL (Object Oriented Parallel Accelerator Library) 2024.2
OPAL
Types.h
Go to the documentation of this file.
1//
2// File Types
3//
4// Copyright (c) 2010 - 2013, Yves Ineichen, ETH Zürich
5// All rights reserved
6//
7// Implemented as part of the PhD thesis
8// "Toward massively parallel multi-objective optimization with application to
9// particle accelerators" (https://doi.org/10.3929/ethz-a-009792359)
10//
11// This file is part of OPAL.
12//
13// OPAL is free software: you can redistribute it and/or modify
14// it under the terms of the GNU General Public License as published by
15// the Free Software Foundation, either version 3 of the License, or
16// (at your option) any later version.
17//
18// You should have received a copy of the GNU General Public License
19// along with OPAL. If not, see <https://www.gnu.org/licenses/>.
20//
21#ifndef __TYPES_H__
22#define __TYPES_H__
23
24#include <iomanip>
25#include <istream>
26#include <limits>
27#include <map>
28#include <ostream>
29#include <string>
30#include <tuple>
31#include <utility>
32#include <vector>
33
35
36//FIXME: add namespaces
37
40
41
42// Variables
43
44// information the optimizer can request: either wants a derivative or a
45// function evaluation.
48
49typedef std::pair<std::string, double> namedVariable_t;
50typedef std::map<std::string, double> namedVariableCollection_t;
51
54
57//typedef std::variant< double, std::tuple<double, double, double> >
58 //reqVarValue_t;
59
60//FIXME: do we need InfoType_t ?
69typedef struct reqVarInfo {
71 std::vector<double> value;
73
75 void writeState(std::ostream& os) const {
76 os << std::setprecision(std::numeric_limits<double>::max_digits10);
77 os << static_cast<int>(type) << ' ' << value.size();
78 for (double v : value) os << ' ' << v;
79 os << ' ' << is_valid;
80 }
81
83 void readState(std::istream& is) {
84 int t = 0;
85 is >> t;
86 type = static_cast<InfoType_t>(t);
87 std::size_t n = 0;
88 is >> n;
89 value.resize(n);
90 for (double& v : value) is >> v;
91 is >> is_valid;
92 }
94
95typedef std::pair<std::string, reqVarInfo_t> namedReqVar_t;
96typedef std::map<std::string, reqVarInfo_t> reqVarContainer_t;
97
99typedef std::tuple<std::string, double, double> DVar_t;
100
106
107typedef std::pair<std::string, DVar_t> namedDVar_t;
108typedef std::map<std::string, DVar_t> DVarContainer_t;
109
110#endif
std::map< std::string, double > namedVariableCollection_t
Definition Types.h:50
Position_t
Definition Types.h:47
@ POSITION
Definition Types.h:47
@ TIME
Definition Types.h:47
std::map< std::string, DVar_t > DVarContainer_t
Definition Types.h:108
namedVariableCollection_t variableDictionary_t
Definition Types.h:53
std::tuple< std::string, double, double > DVar_t
type of design variables
Definition Types.h:99
InfoType_t
Definition Types.h:46
@ EVALUATE
Definition Types.h:46
@ DERIVATE
Definition Types.h:46
Role_t
roles a processor can attain
Definition Types.h:39
@ POLLER
Definition Types.h:39
@ UNASSIGNED
Definition Types.h:39
@ OPTIMIZER
Definition Types.h:39
@ WORKER
Definition Types.h:39
std::pair< std::string, double > namedVariable_t
Definition Types.h:49
std::map< std::string, reqVarInfo_t > reqVarContainer_t
Definition Types.h:96
DVar_tIdx
Definition Types.h:101
@ LOWER_BOUND
Definition Types.h:103
@ UPPER_BOUND
Definition Types.h:104
@ VAR_NAME
Definition Types.h:102
struct reqVarInfo reqVarInfo_t
namedVariableCollection_t Param_t
Definition Types.h:52
std::pair< std::string, DVar_t > namedDVar_t
Definition Types.h:107
std::pair< std::string, reqVarInfo_t > namedReqVar_t
Definition Types.h:95
void writeState(std::ostream &os) const
write this info to a stream, replaces boost::serialization
Definition Types.h:75
std::vector< double > value
Definition Types.h:71
void readState(std::istream &is)
read this info from a stream, replaces boost::serialization
Definition Types.h:83
InfoType_t type
Definition Types.h:70
bool is_valid
Definition Types.h:72