Class CentralizedNegotiation

Nested Relationships

Nested Types

Class Documentation

class CentralizedNegotiation

Public Types

using Proposal = std::unordered_map<schedule::ParticipantId, Plan>

When a proposal is found, it will provide a plan for each agent.

Public Functions

CentralizedNegotiation(std::shared_ptr<const schedule::Viewer> viewer)

Constructor

Parameters:

viewer[in] A viewer for the traffic schedule. You may provide a std::shared_ptr<const schedule::Database> for this. The negotiation will avoid creating any new conflicts with schedule participants that are not part of the negotiation.

const std::shared_ptr<const schedule::Viewer> &viewer() const

Get the schedule viewer.

CentralizedNegotiation &viewer(std::shared_ptr<const schedule::Viewer> v)

Set the schedule viewer.

CentralizedNegotiation &optimal(bool on = true)

Require the negotiation to consider all combinations so that it finds the (near-)optimal solution. Off by default.

CentralizedNegotiation &log(bool on = true)

Toggle on/off whether to log the progress of the negotiation and save it in the Result. Off by default.

CentralizedNegotiation &print(bool on = true)

Toggle on/off whether to print the progress of the negotiation while it is running. Off by default.

Result solve(const std::vector<Agent> &agents) const

Solve a centralized negotiation for the given agents.

class Agent

Public Functions

Agent(schedule::ParticipantId id, Plan::Start start, Plan::Goal goal, std::shared_ptr<const Planner> planner, std::optional<SimpleNegotiator::Options> options = std::nullopt)

Constructor

Parameters:
  • id[in] This agent’s ID within the schedule database. If multiple agents are given the same ID in a negotiation, then a runtime exception will be thrown.

  • starts[in] The starting condition for this agent.

  • goal[in] The goal for this agent.

  • planner[in] The single-agent planner used for this agent. Each agent can have its own planner or they can share planners. If this is set to nullptr when the negotiation begins, then a runtime exception will be thrown.

  • options[in] Options to use for the negotiator of this agent. If nullopt is provided, then the default options of the SimpleNegotiator will be used.

Agent(schedule::ParticipantId id, std::vector<Plan::Start> starts, Plan::Goal goal, std::shared_ptr<const Planner> planner, std::optional<SimpleNegotiator::Options> options = std::nullopt)

Constructor

The planner will use whichever starting condition provides the optimal plan.

Parameters:
  • id[in] This agent’s ID within the schedule database. If multiple agents are given the same ID in a negotiation, then a runtime exception will be thrown.

  • starts[in] One or more starting conditions for this agent. If no starting conditions are provided before the negotiation begins, then a runtime exception will be thrown.

  • goal[in] The goal for this agent.

  • planner[in] The single-agent planner used for this agent. Each agent can have its own planner or they can share planners. If this is set to nullptr when the negotiation begins, then a runtime exception will be thrown.

  • options[in] Options to use for the negotiator of this agent. If nullopt is provided, then the default options of the SimpleNegotiator will be used.

schedule::ParticipantId id() const

Get the ID for this agent.

Agent &id(schedule::ParticipantId value)

Set the ID for this agent.

const std::vector<Plan::Start> &starts() const

Get the starts for this agent.

Agent &starts(std::vector<Plan::Start> values)

Set the starts for this agent.

const Plan::Goal &goal() const

Get the goal for this agent.

Agent &goal(Plan::Goal value)

Set the goal for this agent.

const std::shared_ptr<const Planner> &planner() const

Get the planner for this agent.

Agent &planner(std::shared_ptr<const Planner> value)

Set the planner for this agent.

const std::optional<SimpleNegotiator::Options> &options() const

Get the options for this agent.

Agent &options(std::optional<SimpleNegotiator::Options> value)

Set the options for this agent.

class Result

Public Functions

const std::optional<Proposal> &proposal() const

If a solution was found, it will be provided by this proposal.

const std::unordered_set<schedule::ParticipantId> &blockers() const

This is a list of schedule Participants that were not part of the negotiation who blocked the planning effort. Blockers do not necessarily prevent a solution from being found, but they do prevent the optimal solution from being available.

const std::vector<std::string> &log() const

A log of messages related to the negotiation. This will be empty unless the log() function of the CentralizedNegotiation is toggled on before solving.