Class Negotiation::Table

Nested Relationships

This class is a nested type of Class Negotiation.

Nested Types

Inheritance Relationships

Base Type

  • public std::enable_shared_from_this< Table >

Class Documentation

class Table : public std::enable_shared_from_this<Table>

The Negotiation::Table class gives a view of what the other negotiation participants have proposed.

A Table instance is meant to be viewed by a specific participant and displays the proposals of other participants for a specific hierarchies of accommodations. See the documentation of Negotiation::table().

Alongside the views of the other Negotiation participants, the View provided by the Table instance will show the itineraries of schedule participants that are not part of the Negotiation. That way the external itineraries can also be accounted for when planning a submission based on this Table.

Public Types

using ViewerPtr = std::shared_ptr<const Viewer>

Public Functions

ViewerPtr viewer() const

Get a viewer for this Table. The Viewer can be safely used across multiple threads.

const Itinerary *submission() const

Return the submission on this Negotiation Table if it has one.

Version version() const

The a pointer to the latest itinerary version that was submitted to this table, if one was submitted at all.

const Proposal &proposal() const

The proposal on this table so far. This will include the latest itinerary that has been submitted to this Table if anything has been submitted. Otherwise it will only include the submissions that underlie this table.

ParticipantId participant() const

The participant that is meant to submit to this Table.

const VersionedKeySequence &sequence() const

The sequence key that refers to this table. This is equivalent to [to_accommodate…, for_participant]

std::vector<ParticipantId> unversioned_sequence() const

The versioned sequence key that refers to this table.

bool submit(PlanId plan_id, std::vector<Route> itinerary, Version version)

Submit a proposal for a participant that accommodates some of the other participants in the negotiation (or none if an empty vector is given for the to_accommodate argument).

Parameters:
  • plan_id[in] A unique identifier for this plan. If this plan is selected by the negotiation, then this ID will be submitted to the traffic schedule as the PlanId for this participant.

  • itinerary[in] The itinerary that is being submitted by this participant.

  • version[in] A version number assigned to the submission. If this is less or equal to the last version number given, then nothing will change.

Returns:

True if the submission was accepted. False if the version was out of date and nothing changed in the negotiation.

bool reject(Version version, ParticipantId rejected_by, Alternatives alternatives)

Reject the submission of this Negotiation::Table. This indicates that the underlying proposals are infeasible for the Participant of this Table to accommodate. The rejecter should give a set of alternative rollouts that it is capable of. That way the proposer for this Table can submit an itinerary that accommodates it.

Parameters:
  • version[in] A version number assigned to the submission. If this is equal to or greater than the last version number given, then this table will be put into a rejected state until a higher proposal version is submitted.

  • rejected_by[in] The participant who is rejecting this proposal

  • alternatives[in] A set of rollouts that could be used by the participant that is rejecting this proposal. The proposer should use this information to offer a proposal that can accommodate at least one of these rollouts.

Returns:

True if the rejection was accepted. False if the version was out of date and nothing changed in the negotiation.

bool rejected() const

Returns true if the proposal put on this Table has been rejected.

void forfeit(Version version)

Give up on this Negotiation Table. This should be called when the participant that is supposed to submit to this Table is unable to find a feasible proposal.

bool forfeited() const

Returns true if the proposer for this Table has forfeited.

bool defunct() const

Returns true if any of this table’s ancestors were rejected or forfeited. When that happens, this Table will no longer have any effect on the Negotiation.

TablePtr respond(ParticipantId by_participant)

If by_participant can respond to this table, then this will return a TablePtr that by_participant can submit a proposal to.

If this function is called before anything has been submitted to this Table, then it will certainly return a nullptr.

ConstTablePtr respond(ParticipantId by_participant) const
TablePtr parent()

Get the parent Table of this Table if it has a parent.

ConstTablePtr parent() const
std::vector<TablePtr> children()

Get the children of this Table if any children exist.

std::vector<ConstTablePtr> children() const
bool ongoing() const

Return true if the negotiation is ongoing (i.e. the Negotiation instance that created this table is still alive). When the Negotiation instance that this Table belongs to has destructed, this will begin to return false.

class Viewer

Public Types

using View = schedule::Viewer::View
using AlternativeMap = std::unordered_map<ParticipantId, std::shared_ptr<Alternatives>>

Public Functions

View query(const Query::Spacetime &parameters, const VersionedKeySequence &alternatives) const

View this table with the given parameters.

Parameters:
  • parameters[in] The spacetime parameters to filter irrelevant routes out of the view

  • rollouts[in] The selection of which rollout alternatives should be viewed for the participants who have rejected this proposal in the past.

std::unordered_map<ParticipantId, Endpoint> initial_endpoints(const VersionedKeySequence &alternatives) const

Get the set of initial waypoints for the negotiation participants.

std::unordered_map<ParticipantId, Endpoint> final_endpoints(const VersionedKeySequence &alterantives) const

Get the set of final waypoints for the negotiation participants.

const AlternativeMap &alternatives() const

When a Negotiation::Table is rejected by one of the participants who is supposed to respond, they can offer a set of rollout alternatives. If the proposer can accommodate one of the alternatives for each responding participant, then the negotiation might be able to proceed. This map gives the alternatives for each participant that has provided them.

const Proposal &base_proposals() const

The proposals submitted to the predecessor tables.

std::shared_ptr<const ParticipantDescription> get_description(ParticipantId participant_id) const

Get the description of a participant in this Viewer.

ParticipantId participant_id() const

Get the Participant ID of the participant who should submit to this table.

rmf_utils::optional<ParticipantId> parent_id() const

If the Table has a parent, get its Participant ID.

const VersionedKeySequence &sequence() const

The sequence of the table that is being viewed.

bool defunct() const

Returns true if the table of this viewer is no longer relevant. Unlike the other fields of the Viewer, this is not a snapshot of the table’s state when the Viewer was created; instead this defunct status will remain in sync with the state of the source Table.

bool rejected() const

Returns true if the proposal put on this Table has been rejected.

bool forfeited() const

Returns true if the proposer for this Table has forfeited.

const Itinerary *submission() const

Return the submission on this Negotiation Table if it has one.

std::optional<rmf_traffic::Time> earliest_base_proposal_time() const

The earliest start time of any of the proposals in the table.

std::optional<rmf_traffic::Time> latest_base_proposal_time() const

The latest finish time of any of the proposals in the table.

class Endpoint

View the first or last (depending on context) waypoint in a negotiation participant’s itinerary or alternative.

Public Functions

ParticipantId participant() const

The ID of the participant.

PlanId plan_id() const

The ID of the plan for this endpoint.

RouteId route_id() const

The ID of the route for this endpoint.

const rmf_traffic::Trajectory::Waypoint &waypoint() const

The first or last (depending on context) waypoint.

const std::string &map() const

The map that the endpoint is on.

const ParticipantDescription &description() const

The description of the participant.