Cython Data Structures
This cython module wraps the struct templates exposed from C++ by
data_structures_cython.pxd
into extension types. Since an extension type
obviously cannot be templated, we will use the The Explicit Runtime Dispatch approach approach.
- class ridepy.data_structures_cython.LocType
Representing the kind of location objects the simulator supports. either of:
R2LOC
(for points in \(\mathbb{R}^2\), holds atuple[float, float]
).INT
(for e.g. graphs).
Note
Use this for simulations using the cythonic components. For simulations using pure pythonic components, the python version of this enum i.e.
data_structures.LocType
has to be used.
- class TransportationRequest(int request_id, double creation_timestamp, origin, destination, pickup_timewindow_min=0, pickup_timewindow_max=inf, delivery_timewindow_min=0, delivery_timewindow_max=inf)
Cython equivalent of pure python dataclass
data_structures.TransportationRequest
. See its docstring for details of its attributes.Implementation details for developers
Wraps the C++ templated struct
data_structures_cython.cdata_structures.pxd::TransportationRequest[Loc]
into a cython extension type. The template parameterLoc
defines the type of location objects (Tuple[float, float]
for simulations in \(\mathbb{R}^2\)),int
for graphs.However a cython extension type obviously cannot be templated (at compile time, all possible variations of a template must be known). So we will use the Explicit Run-Time Dispatch approach, see this module’s docstring or The Explicit Runtime Dispatch approach for details.
Holds a
shared_ptr
to C++ templated classTransportationRequest
. This class can be instantiated from an existingshared_ptr
(only from the cython side and not from the calling python code). See the staticmethodscdef TransportationRequest from_c_r2loc
andcdef TransportationRequest from_c_int
for details.Note
We will try to infer
Loc
from whatorigin
contains. The inference can be easily fooled by passing e.g.origin = 2, destination = (0.3, 1.5)
.- __reduce__(self)
- asdict(self)
Returns a dict representation of itself.
- class InternalRequest(int request_id, double creation_timestamp, location)
Cython equivalent of pure python dataclass
data_structures.InternalRequest
. See its docstring for details of its attributes.Implementation details for developers
Wraps the C++ templated struct
data_structures_cython.cdata_structures.pxd::InternalRequest[Loc]
into a cython extension type. The template parameterLoc
defines the type of location objects (Tuple[float, float]
for simulations in \(\mathbb{R}^2\)),int
for graphs.However a cython extension type obviously cannot be templated (at compile time, all possible variations of a template must be known). So we will use the Explicit Run-Time Dispatch approach, see this module’s docstring or The Explicit Runtime Dispatch approach for details.
Holds a
shared_ptr
to C++ templated classInternalRequest
. This class can be instantiated from an existingshared_ptr
(only from the cython side and not from the calling python code). See the staticmethodscdef InternalRequest from_c_r2loc
andcdef InternalRequest from_c_int
for details.Note
We will try to infer
Loc
from whatlocation
contains.- __reduce__(self)
- asdict(self)
- class Stop(location, Request request, StopAction action, double estimated_arrival_time, int occupancy_after_servicing, double time_window_min=0, double time_window_max=inf)
Cython equivalent of pure python dataclass
data_structures.Stop
. See its docstring for details of its attributes.Implementation details for developers
Wraps the C++ templated struct
data_structures_cython.cdata_structures.pxd::Stop[Loc]
into a cython extension type. The template parameterLoc
defines the type of location objects (Tuple[float, float]
for simulations in \(\mathbb{R}^2\)),int
for graphs.However a cython extension type obviously cannot be templated (at compile time, all possible variations of a template must be known). So we will use the Explicit Run-Time Dispatch approach, see this module’s docstring or The Explicit Runtime Dispatch approach for details.
Holds a pointer to C++ templated class
Stop
. This class can be instantiated from an existing pointer (only from the cython side and not from the calling python code). See the staticmethodscdef Stop from_c_r2loc
andcdef Stop from_c_int
for details.Note
We will try to infer the
LocType
from whatlocation
contains. Do not pass incompatible combinations like aRequest
withLocType=R2LOC
andlocation
of typeint
.- __deepcopy__(self, *args, **kwargs)
- __reduce__(self)
- asdict(self)
- class Stoplist(python_stoplist, loc_type)
The cythonic equivalent of
data_structures.Stoplist
, which is just a python list ofdata_structures.Stop
.Note
An instance of this class doies not support most of the functionalities of python lists, e.g. slicing. Please take a look at the available methods. In particular, use
stoplist.remove_nth_elem(int)
instead ofstoplist.pop(int)
ordel stoplist[i]
.Implementation details for developers
Wraps a C++ vector of
data_structures_cython.cdata_structures.pxd::Stop[Loc]
into a cython extension type. The template parameterLoc
defines the type of location objects (Tuple[float, float]
for simulations in \(\mathbb{R}^2\)),int
for graphs.However a cython extension type obviously cannot be templated (at compile time, all possible variations of a template must be known). So we will use the Explicit Run-Time Dispatch approach, see this module’s docstring or The Explicit Runtime Dispatch approach for details.
This class can be instantiated from an existing C++
vector
, only from the cython side and not from the calling python code. See the staticmethodsStoplist from_c_r2loc
andStoplist from_c_int
for details.- Parameters:
Note
Do not pass a list of pure pythonic
Stop
objects to__init__
, this will lead to a crash. Only pass a list of cython extensionStop
objects.The
Stop
objects are copied here, therefore the originalStop
objects can safely be garbage collected/ otherwise deleted.- __reduce__(self)
- remove_nth_elem(self, int n)
Removes the nth element. Does not return anything.
- to_pys(self)