cppyabm  1.0.17
An agent-based library to integrate C++ and Python
common.h
Go to the documentation of this file.
1 #pragma once
2 #include <memory>
3 
4 using namespace std;
5 
6 //! Configuration of hatch order
7 template<class ENV, class AGENT, class PATCH>
8 struct HATCH_CONFIG{
9  HATCH_CONFIG (bool flag = false,
10  shared_ptr<PATCH> _patch = nullptr,
11  bool inherit = false,
12  bool quiet = false,
13  bool reset = false
14  ):
15  _flag(flag),_patch(_patch),_inherit(inherit),
16  _quiet(quiet),_reset(reset)
17  {
18 
19  };
20  bool _flag; //!< if false, the entire hatching process is skipped.
21  shared_ptr<PATCH> _patch; //!< the patch that the new agent will be set. If null, a random patch will be selected.
22  bool _inherit; //!< Inherit from current patch. `Agent::inherit` should be defined for this purpose.
23  bool _quiet; //!< Silent exceptions if hatch fails
24  bool _reset; //!< Resets upon failure in hatching. If false, the agent will try in the next steps again
25 };
26 //! Configuration of move order
27 template<class ENV, class AGENT, class PATCH>
28 struct MOVE_CONFIG{
29  MOVE_CONFIG (bool flag = false,
30  shared_ptr<PATCH> _patch = nullptr,
31  bool quiet = false,
32  bool reset = false
33  ):
34  _flag(flag),_patch(_patch), _quiet(quiet), _reset(reset)
35  {};
36  bool _flag; //!< if false, the entire process is skipped.
37  shared_ptr<PATCH> _patch;//!< the patch that the new agent will be set. If null, a random patch will be selected.
38  bool _quiet; //!< Silent exceptions if hatch fails
39  bool _reset; //!< Resets upon failure in hatching. If false, the agent will try in the next steps again
40 };
41 //! Configuration of switch order from one agent type to another
43  SWITCH_CONFIG (bool flag = false,
44  string to = ""
45  ):
46  _flag(flag),_to(to)
47  {};
48  bool _flag;
49  string _to;//!< the target agent class name
50 };
51 //! Base exception class
53  base_exception_class(std::string msg):message(msg){}
54  std::string message;
55  const char *what() const throw() {
56  return message.c_str();
57  }
58 };
61 };
64 };
67 };
70 };
73 };
74 
75 
76 // const std::string main_output_folder = "outputs/";
77 
invalid_pointer
Definition: common.h:71
SWITCH_CONFIG
Configuration of switch order from one agent type to another.
Definition: common.h:42
HATCH_CONFIG::_quiet
bool _quiet
Silent exceptions if hatch fails.
Definition: common.h:23
HATCH_CONFIG::HATCH_CONFIG
HATCH_CONFIG(bool flag=false, shared_ptr< PATCH > _patch=nullptr, bool inherit=false, bool quiet=false, bool reset=false)
Definition: common.h:9
SWITCH_CONFIG::SWITCH_CONFIG
SWITCH_CONFIG(bool flag=false, string to="")
Definition: common.h:43
MOVE_CONFIG::MOVE_CONFIG
MOVE_CONFIG(bool flag=false, shared_ptr< PATCH > _patch=nullptr, bool quiet=false, bool reset=false)
Definition: common.h:29
HATCH_CONFIG::_reset
bool _reset
Resets upon failure in hatching. If false, the agent will try in the next steps again.
Definition: common.h:24
undefined_member
Definition: common.h:68
invalid_directory
Definition: common.h:59
SWITCH_CONFIG::_flag
bool _flag
Definition: common.h:47
MOVE_CONFIG::_patch
shared_ptr< PATCH > _patch
the patch that the new agent will be set. If null, a random patch will be selected.
Definition: common.h:37
base_exception_class::message
std::string message
Definition: common.h:54
MOVE_CONFIG::_quiet
bool _quiet
Silent exceptions if hatch fails.
Definition: common.h:38
SWITCH_CONFIG::_to
string _to
the target agent class name
Definition: common.h:49
HATCH_CONFIG::_flag
bool _flag
if false, the entire hatching process is skipped.
Definition: common.h:19
MOVE_CONFIG
Configuration of move order.
Definition: common.h:28
MOVE_CONFIG::_flag
bool _flag
if false, the entire process is skipped.
Definition: common.h:35
HATCH_CONFIG
Configuration of hatch order.
Definition: common.h:8
base_exception_class::base_exception_class
base_exception_class(std::string msg)
Definition: common.h:53
MOVE_CONFIG::_reset
bool _reset
Resets upon failure in hatching. If false, the agent will try in the next steps again.
Definition: common.h:39
base_exception_class::what
const char * what() const
Definition: common.h:55
patch_availibility
Definition: common.h:65
base_exception_class
Base exception class.
Definition: common.h:52
HATCH_CONFIG::_inherit
bool _inherit
Inherit from current patch. Agent::inherit should be defined for this purpose.
Definition: common.h:22
HATCH_CONFIG::_patch
shared_ptr< PATCH > _patch
the patch that the new agent will be set. If null, a random patch will be selected.
Definition: common.h:21
convergence_error
Definition: common.h:62
setup.msg
msg
Definition: setup.py:47