osurs
0.0.1
|
Network for reservation optimization. More...
#include "osurs/types.h"
Go to the source code of this file.
Functions | |
Network * | new_network () |
Create a new network. More... | |
Node * | new_node (Network *network, const char *id, double x, double y) |
Create a new node and add it to the network. More... | |
Composition * | new_composition (Network *network, const char *id, int seat_count) |
Create a new composition and add it to the network. More... | |
Vehicle * | new_vehicle (Network *network, const char *id, Composition *composition) |
Create a new vehicle and add it to the network. More... | |
Route * | new_route (Network *network, const char *id, Node *nodes[], int arrival_offsets[], int departure_offsets[], size_t route_size, const char *trip_ids[], int departures[], Vehicle *vehicles[], size_t trip_size) |
Create a new route and add it to the network. More... | |
Node * | get_node (Network *network, const char *id) |
Get the node struct. More... | |
Vehicle * | get_vehicle (Network *network, const char *id) |
Get the vehicle struct. More... | |
Composition * | get_composition (Network *network, const char *id) |
Get the composition struct. More... | |
Route * | get_route (Network *network, const char *id) |
Get the route struct. More... | |
Trip * | get_trip (Route *route, const char *id) |
Get the trip struct. More... | |
void | delete_network (Network *network) |
Delete a network. More... | |
Network for reservation optimization.
The network consists of nodes with a name and coordinates. A route is defined by stops and trips. Each stop is associated to a node of the network and knows the previous and next stop if there is one. A route can have several trips, which are defined by departure times and their seat capacity. Each trip knows the next departing trip, if there is one.
void delete_network | ( | Network * | network | ) |
Delete a network.
All objects of the network are located on the heap and are directly or indirectly linked to the network structure. If the memory of the network is released all associated structures of the network are also cleared.
network | The network to delete and free. |
Composition* get_composition | ( | Network * | network, |
const char * | id | ||
) |
Get the composition struct.
network | An network to get the composition from. |
id | The identifier of the composition. |
Get the node struct.
network | An network to get the node from. |
id | The identifier of the node. |
Get the route struct.
network | An network to get the route from. |
id | The identifier of the route. |
Get the trip struct.
route | A route to get the trip from. |
id | The identifier of the trip. |
Get the vehicle struct.
network | An network to get the vehicle from. |
id | The identifier of the vehicle. |
Composition* new_composition | ( | Network * | network, |
const char * | id, | ||
int | seat_count | ||
) |
Create a new composition and add it to the network.
network | The network to add the composition. |
id | The id of the composition. |
seat_count | The seat capacity of the composition. |
Network* new_network | ( | ) |
Create a new network.
The network consists of nodes where vehicles stop and passengers can get on and off. A route stores the order in which the nodes are approached by a vehicle in a chain of stops. Each stop contains information about which stop is next and how long it takes to reach it. On routes, trips indicate the departure times at which a vehicle leaves from the route's root stop. Vehicle information such as capacity and reservations are stored at the trip level.
Create a new node and add it to the network.
network | The network to add the node. |
id | The id of the node. |
x | The x coordinate of the node. |
y | The y coordinate of the node. |
Route* new_route | ( | Network * | network, |
const char * | id, | ||
Node * | nodes[], | ||
int | arrival_offsets[], | ||
int | departure_offsets[], | ||
size_t | route_size, | ||
const char * | trip_ids[], | ||
int | departures[], | ||
Vehicle * | vehicles[], | ||
size_t | trip_size | ||
) |
Create a new route and add it to the network.
network | The network to add the route. |
id | The identifier of the route. |
nodes | A pointer to an array of nodes, which define the stops of the route (n=route_size). |
arrival_offsets | A pointer to an array of arrival offset times from the root stop. The offsets define the travel times between the departure of the root stop and the arrival at the current stop (n=route_size). |
departure_offsets | A pointer to an array of departure offset times from the root stop. The offsets define the travel times between the departure of the root stop and the departure at the current stop (n=route_size). |
route_size | The number of nodes (=stops) in the route. |
trip_ids | The identifier of the trips on the route (n=trip_size). |
departures | The departure times at the first node (=root_stop) of the route in seconds after midnight (00:00:00). Every departure time will define a new trip, which starts traveling along the route (n=trip_size) |
vehicles | An array of vehicles for each trip (n=trip_size). |
trip_size | The number of departures (=trips) on the route. |
Vehicle* new_vehicle | ( | Network * | network, |
const char * | id, | ||
Composition * | composition | ||
) |
Create a new vehicle and add it to the network.
network | The network to add the vehicle. |
id | The id of the vehicle. |
composition | The composition the vehicle has. |