Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
annick
Contributor III
Contributor III

Compute a Maximum value (via set analysis or load script)?

Hello,

I have the following problem:

The following load script:

BusTimeTable:
Load *,
BusNumber&StartJourney&EndJourney as KeyBusPax;
Load * inline
[
BusNumber, StartJourney, EndJourney, FromStation, ToStation, Section
201,   A,     B,    A,    B,   None     
201,  B,    C,    B,    C,   None   
201,   A,     C,    A,    B,   1
201,   A,     C,    B,    C,   2
202,   A,    C,    A,    C,   None];


Travellers:
Load Traveller,
BusNumber&StartJourney&EndJourney as KeyBusPax;
Load * inline
[
Traveller, BusNumber,  StartJourney, EndJourney
Jim,   201,  A,     B
Tom,   201,  A,     B
John,  201,  A,    C
Jane,   201,  B,     C
Daniel,     202,  A,    C];
 
 
 

generates this table:

TravellerBusNumberStartJourneyEndJourneyFromStationToStation
Daniel202ACAC
Jane201BCBC
Jim201ABAB
John201ACAB
John201ACBC
Tom201ABAB

 

I would like to compute the maximum number of occupied seats on a given bus (e.g. BusNumber 201) for a given Journey (e.g StartJourney = A; EndJourney = C) as follows:

1) Get all the lines with StartJourney A, EndJourney C and BusNumber 201, and  get all the sections FromStation - ToStation  with this Journey A C :

  • Station 1 FromStation A-ToStation B 
  • Station 2 FromStation B- ToStation C

3) For each section, compute the number of Travelers on this bus, regardless of the StartJourney and EndJourney A-C:

  • Station 1 FromStation A-ToStation B  : 3 (Jim, John, Tom)
  • Station 2 FromStation B- ToStation C: 2 (Jane, John)

4) Compute the max of these sections above : Max (3,2) = 3

==> The maximum number of occupied seats on a given bus (e.g. BusNumber 201) for a given Journey (e.g StartJourney = A; EndJourney = C)  = 3

 

 Thanks a lot

Annick

 

 

Labels (1)
2 Replies
sunny_talwar

This seems a little complicated, but can you provide how the final information is displayed? In a chart? in a text box? multiple objects? Can you provide the expected output you would want your users to see based on the inputs provided?

annick
Contributor III
Contributor III
Author

Thanks for your reply Sunny. I found a way to simplify this...