12 #include <type_safe/reference.hpp>
24 namespace permit_public_status
38 std::span<const trade_value_t>
trades;
49 std::variant<permit_public_status::unavailable, permit_public_status::available, permit_public_status::owned>;
67 template <region_compatible R>
struct agent
69 using region_type = R;
117 virtual auto on_bought([[maybe_unused]]
const R& region, [[maybe_unused]]
uint_t time, [[maybe_unused]]
value_t value) ->
void
128 virtual auto on_sold([[maybe_unused]]
const R& region, [[maybe_unused]]
uint_t time, [[maybe_unused]]
value_t value) ->
void {}
142 template <
typename T>
143 concept
agent_compatible = std::movable<T> && std::derived_from<T, agent<typename T::region_type>>;
151 class agent_interface
154 virtual ~agent_interface() =
default;
162 virtual auto stop(
uint_t,
int) ->
bool = 0;
166 template <agent_compatible Agent>
class agent_model :
public agent_interface
170 virtual ~agent_model() =
default;
174 agent_.bid_phase(t, std::move(b), std::move(i), seed);
179 agent_.ask_phase(t, std::move(a), std::move(i), seed);
184 agent_.on_bought(s.
downcast<
typename Agent::region_type>(), t, v);
189 agent_.on_sold(s.
downcast<
typename Agent::region_type>(), t, v);
192 auto stop(
uint_t t,
int seed) ->
bool override {
return agent_.stop(t, seed); }
201 template <agent_compatible Agent>
any_agent(Agent a) : interface_(new agent_model<Agent>(std::move(a))) {}
217 auto stop(
uint_t time,
int seed) ->
bool;
220 std::unique_ptr<agent_interface> interface_;
type_safe::function_ref< bool(region_view, uint_t, value_t)> bid_fn
Function reference that allows the agent to bid for a permit.
Definition: agent.hpp:52
type_safe::function_ref< bool(region_view, uint_t, value_t)> ask_fn
Function reference that allows the agent to ask for a permit.
Definition: agent.hpp:55
type_safe::function_ref< permit_public_status_t(region_view, uint_t)> permit_public_status_fn
Function reference that returns the public status of a permit.
Definition: agent.hpp:58
std::variant< permit_public_status::unavailable, permit_public_status::available, permit_public_status::owned > permit_public_status_t
Variant that represents the possible public status of a permit.
Definition: agent.hpp:49
concept agent_compatible
Concept that defines the requirements for an agent.
Definition: agent.hpp:143
A type-erased class that represents an agent in the simulation.
Definition: agent.hpp:149
any_agent(Agent a)
Definition: agent.hpp:201
A non-owning wrapper to an atomic region in the airspace.
Definition: permit.hpp:21
auto downcast() const -> const R &
Definition: permit.hpp:38
Defines region utilities and the permit class.
Class to define the default behavior of an agent.
Definition: agent.hpp:68
virtual auto stop(uint_t time, int seed) -> bool=0
virtual auto on_bought([[maybe_unused]] const R ®ion, [[maybe_unused]] uint_t time, [[maybe_unused]] value_t value) -> void
Definition: agent.hpp:117
virtual auto bid_phase([[maybe_unused]] uint_t time, [[maybe_unused]] bid_fn bid, [[maybe_unused]] permit_public_status_fn status, [[maybe_unused]] int seed) -> void
Definition: agent.hpp:86
virtual auto ask_phase([[maybe_unused]] uint_t time, [[maybe_unused]] ask_fn ask, [[maybe_unused]] permit_public_status_fn status, [[maybe_unused]] int seed) -> void
Definition: agent.hpp:105
virtual auto on_sold([[maybe_unused]] const R ®ion, [[maybe_unused]] uint_t time, [[maybe_unused]] value_t value) -> void
Definition: agent.hpp:128
Represents the public status of a permit that is available for trading.
Definition: agent.hpp:33
value_t min_value
The minimum value that can be offered for the permit.
Definition: agent.hpp:34
std::span< const trade_value_t > trades
Definition: agent.hpp:38
Represents the public status of a permit that is owned by the agent.
Definition: agent.hpp:43
Represents the public status of a permit that is not available for trading.
Definition: agent.hpp:29
Represents the public values in a trade of a permit.
Definition: agent.hpp:19
value_t highest_bid
The highest bid for the permit.
Definition: agent.hpp:21
value_t min_value
The minimum value the owner asked for the permit.
Definition: agent.hpp:20
std::size_t uint_t
Default unsigned integer type.
Definition: type.hpp:29
double value_t
Default type for price.
Definition: type.hpp:35