osurs  0.0.1
Functions
network.h File Reference

Network for reservation optimization. More...

#include "osurs/types.h"
Include dependency graph for network.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

Networknew_network ()
 Create a new network. More...
 
Nodenew_node (Network *network, const char *id, double x, double y)
 Create a new node and add it to the network. More...
 
Compositionnew_composition (Network *network, const char *id, int seat_count)
 Create a new composition and add it to the network. More...
 
Vehiclenew_vehicle (Network *network, const char *id, Composition *composition)
 Create a new vehicle and add it to the network. More...
 
Routenew_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...
 
Nodeget_node (Network *network, const char *id)
 Get the node struct. More...
 
Vehicleget_vehicle (Network *network, const char *id)
 Get the vehicle struct. More...
 
Compositionget_composition (Network *network, const char *id)
 Get the composition struct. More...
 
Routeget_route (Network *network, const char *id)
 Get the route struct. More...
 
Tripget_trip (Route *route, const char *id)
 Get the trip struct. More...
 
void delete_network (Network *network)
 Delete a network. More...
 

Detailed Description

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.

Date
: 2022-07-12
Author
: Merlin Unterfinger

Function Documentation

◆ delete_network()

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.

Parameters
networkThe network to delete and free.

◆ get_composition()

Composition* get_composition ( Network network,
const char *  id 
)

Get the composition struct.

Parameters
networkAn network to get the composition from.
idThe identifier of the composition.
Returns
Returns the composition.

◆ get_node()

Node* get_node ( Network network,
const char *  id 
)

Get the node struct.

Parameters
networkAn network to get the node from.
idThe identifier of the node.
Returns
Returns the node.

◆ get_route()

Route* get_route ( Network network,
const char *  id 
)

Get the route struct.

Parameters
networkAn network to get the route from.
idThe identifier of the route.
Returns
Returns the route.

◆ get_trip()

Trip* get_trip ( Route route,
const char *  id 
)

Get the trip struct.

Parameters
routeA route to get the trip from.
idThe identifier of the trip.
Returns
Trip* Returns the trip.

◆ get_vehicle()

Vehicle* get_vehicle ( Network network,
const char *  id 
)

Get the vehicle struct.

Parameters
networkAn network to get the vehicle from.
idThe identifier of the vehicle.
Returns
Returns the vehicle.

◆ new_composition()

Composition* new_composition ( Network network,
const char *  id,
int  seat_count 
)

Create a new composition and add it to the network.

Parameters
networkThe network to add the composition.
idThe id of the composition.
seat_countThe seat capacity of the composition.
Returns
A pointer to the newly allocated node (Composition*).

◆ new_network()

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.

Note
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 (delete_network(Network *)) all associated structures of the network are also cleared.
Returns
Network*

◆ new_node()

Node* new_node ( Network network,
const char *  id,
double  x,
double  y 
)

Create a new node and add it to the network.

Parameters
networkThe network to add the node.
idThe id of the node.
xThe x coordinate of the node.
yThe y coordinate of the node.
Returns
A pointer to the newly allocated node (Node*).

◆ new_route()

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.

Parameters
networkThe network to add the route.
idThe identifier of the route.
nodesA pointer to an array of nodes, which define the stops of the route (n=route_size).
arrival_offsetsA 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_offsetsA 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_sizeThe number of nodes (=stops) in the route.
trip_idsThe identifier of the trips on the route (n=trip_size).
departuresThe 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)
vehiclesAn array of vehicles for each trip (n=trip_size).
trip_sizeThe number of departures (=trips) on the route.
Returns
A pointer to the newly allocated node (Route*).

◆ new_vehicle()

Vehicle* new_vehicle ( Network network,
const char *  id,
Composition composition 
)

Create a new vehicle and add it to the network.

Parameters
networkThe network to add the vehicle.
idThe id of the vehicle.
compositionThe composition the vehicle has.
Returns
A pointer to the newly allocated vehicle (Vehicle*).