osurs  0.0.1
Functions
optimize.h File Reference

Optimization of space utilization on routs. More...

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

Go to the source code of this file.

Functions

Seatnew_seat (int seat_id)
 Create a new seat. More...
 
void seat_add_reservation (Seat *seat, int res_id)
 Adds a new reservation to the seat. More...
 
void delete_seat (Seat *seat)
 Delete a seat. More...
 
SeatCollectionnew_seat_collection (int seat_count, int seat_ids[])
 Create a new seat collection. More...
 
void delete_seat_collection (SeatCollection *collection)
 Delete a seat collection. More...
 
int space_available (unsigned int res_arr[], int res_count, int segment_count, unsigned int seat_count, unsigned int new_res)
 Check if there is enough space available. More...
 
SeatCollectionoptimize_reservation (unsigned int res_arr[], int res_arr_count, int res_ids[], int segment_count, int seat_ids[], int seat_count)
 Optimize the reservations. More...
 

Detailed Description

Optimization of space utilization on routs.

This module contains an algorithm to optimally distribute reservations along a route to the available seats.

Date
: 2022-08-22
Author
: Tobias Meier, Merlin Unterfinger

Function Documentation

◆ delete_seat()

void delete_seat ( Seat seat)

Delete a seat.

Frees the memory of the given seat on the heap.

Parameters
seatThe seat to delete.

◆ delete_seat_collection()

void delete_seat_collection ( SeatCollection collection)

Delete a seat collection.

Frees the memory of the given seat collection on the heap.

Parameters
collectionThe seat collection to delete.

◆ new_seat()

Seat* new_seat ( int  seat_id)

Create a new seat.

Initializes the seat properties and allocates the memory for the reservation array.

Parameters
seat_idThe id of the seat.
Returns
Returns a pointer to the new Seat struct.

◆ new_seat_collection()

SeatCollection* new_seat_collection ( int  seat_count,
int  seat_ids[] 
)

Create a new seat collection.

Initializes the seat collection properties and allocates the memory for the seat array.

Parameters
seat_countThe Number of seats.
seat_ids[]Array that contains all the seat ids.
Returns
Returns a pointer to the new Seat_collection struct.

◆ optimize_reservation()

SeatCollection* optimize_reservation ( unsigned int  res_arr[],
int  res_arr_count,
int  res_ids[],
int  segment_count,
int  seat_ids[],
int  seat_count 
)

Optimize the reservations.

Places the reservations on the seats in a way that optimizes the capacity.

Parameters
res_arr[]The logical representation of each reservation.
res_arr_countThe number of reservations in the res_array.
res_ids[]Array that contains the reservation ids
segment_countThe number of segments on the route. (stops - 1)
seat_ids[]Array that contains the seat ids
seat_countThe number of seats in the composition.
Returns
Returns a pointer of the optimized Seat_collection.

◆ seat_add_reservation()

void seat_add_reservation ( Seat seat,
int  res_id 
)

Adds a new reservation to the seat.

Initializes the seat properties and allocates the memory for the reservation array.

Parameters
seatThe seat to which the reservation should be added.
res_idThe reservation id.

◆ space_available()

int space_available ( unsigned int  res_arr[],
int  res_count,
int  segment_count,
unsigned int  seat_count,
unsigned int  new_res 
)

Check if there is enough space available.

Checks if the given reservation fits into the current configuration.

Parameters
res_arr[]The logical representation of each reservation.
res_countThe number of reservations in the res_array.
segment_countThe number of segments on the route. (stops - 1)
seat_countThe number of seats.
new_resThe logical representation of the new reservation.
Returns
Returns 1 if there is enough space available otherwise 0.