BioDynaMo  v1.05.120-25dc9790
optimization_param_type.h
Go to the documentation of this file.
1 // -----------------------------------------------------------------------------
2 //
3 // Copyright (C) 2021 CERN & University of Surrey for the benefit of the
4 // BioDynaMo collaboration. All Rights Reserved.
5 //
6 // Licensed under the Apache License, Version 2.0 (the "License");
7 // you may not use this file except in compliance with the License.
8 //
9 // See the LICENSE file distributed with this work for details.
10 // See the NOTICE file distributed with this work for additional information
11 // regarding copyright ownership.
12 //
13 // -----------------------------------------------------------------------------
14 
15 #ifndef CORE_MULTI_SIMULATION_OPTIMIZATION_PARAM_TYPE_OPTIMIZATION_PARAM_TYPE_H_
16 #define CORE_MULTI_SIMULATION_OPTIMIZATION_PARAM_TYPE_OPTIMIZATION_PARAM_TYPE_H_
17 
18 #include <string>
19 #include <vector>
20 
21 #include "core/real_t.h"
22 #include "core/util/io.h"
23 
24 namespace bdm {
25 
28  OptimizationParamType() = default;
29  explicit OptimizationParamType(const std::string& name) : param_name(name) {}
30  virtual ~OptimizationParamType() = default;
31 
32  virtual OptimizationParamType* GetCopy() const = 0;
33 
34  virtual uint32_t GetNumElements() const = 0;
35  virtual real_t GetValue(int n) const = 0;
36  virtual void Validate() const {};
37 
38  // Return the substring before the last "::", which should be
39  // bdm::<ParamGroup>
40  std::string GetGroupName() {
41  size_t found = param_name.find_last_of("::");
42  return param_name.substr(0, found - 1);
43  }
44 
45  // Return the substring after the last "::", which should be <param_name>
46  std::string GetParamName() {
47  size_t found = param_name.find_last_of("::");
48  return param_name.substr(found + 1);
49  }
50 
51  // Must be in format bdm::<ParamGroup>::<param_name>
52  std::string param_name;
54 };
55 
56 } // namespace bdm
57 
58 #endif // CORE_MULTI_SIMULATION_OPTIMIZATION_PARAM_TYPE_OPTIMIZATION_PARAM_TYPE_H_
bdm::OptimizationParamType::GetValue
virtual real_t GetValue(int n) const =0
bdm::OptimizationParamType::GetGroupName
std::string GetGroupName()
Definition: optimization_param_type.h:40
bdm
Definition: agent.cc:39
bdm::OptimizationParamType::OptimizationParamType
OptimizationParamType(const std::string &name)
Definition: optimization_param_type.h:29
bdm::real_t
double real_t
Definition: real_t.h:21
bdm::OptimizationParamType
An interface for creating different types of optimization parameters.
Definition: optimization_param_type.h:27
bdm::OptimizationParamType::param_name
std::string param_name
Definition: optimization_param_type.h:52
bdm::OptimizationParamType::Validate
virtual void Validate() const
Definition: optimization_param_type.h:36
bdm::OptimizationParamType::GetCopy
virtual OptimizationParamType * GetCopy() const =0
bdm::OptimizationParamType::~OptimizationParamType
virtual ~OptimizationParamType()=default
bdm::OptimizationParamType::GetNumElements
virtual uint32_t GetNumElements() const =0
io.h
bdm::OptimizationParamType::BDM_CLASS_DEF
BDM_CLASS_DEF(OptimizationParamType, 1)
real_t.h
bdm::OptimizationParamType::GetParamName
std::string GetParamName()
Definition: optimization_param_type.h:46
bdm::OptimizationParamType::OptimizationParamType
OptimizationParamType()=default