tourcalc.calculator module¶
This module should be used to create a tournament
it does all the mathematics and return the right order of the categories
- tourcalc.calculator.cal_cat(age_select, dis_select)[source]¶
calculation of weight categories
Parameters¶
- age_select
selected age divisions [list]
- dis_select
selected disciplines [list]
- tourcalc.calculator.calculate_fight_time(dict_inp, final, bronze_final, ms_mode)[source]¶
calculate the fight time
Parameters¶
- dict_inp
contains the number of athletes per category [dict]
- tatami
number of competition areas [int]
- final
does the event have a final block [bool]
- ms_mode
add an extra fight for bronze[bool]
- tourcalc.calculator.descition_matrix(cat_time_dict, av_time, tatami, break_t, breaktime, breaklength)[source]¶
to find the best solution based on penalty and weighting of the results
Parameters¶
- cat_time_dict
dictionary with categories and time of each category [dict]
- av_time
reference time for average tatami [float] (sec)
- tatami
number of tatamis [int]
- break_t
type of the break that is used [individual, block, no break]
- breaktime
time when the break should happen [dateime]
- breaklength
length of the break [datetime]
- tourcalc.calculator.distr_cat_alg(jobs, av_time, cur_per, cur_pen_time, tatami, break_t, breaktime, breaklength)[source]¶
Run the algorithm. Create List of dictionaries with, where each discipline has its own dictionary. And fill it with the existing categories. Sort each dictionary by size (longest competitions in beginning of list)
Parameters¶
- jobs
dict of categories that need to be distributed (dict)
- av_time
reference time for average tatami (float [s])
- cur_per
current order of disciplines [list]
- DIS_CHA_TIME
penalty time for changing a discipline [fload [s]]
- DIS_CHA
indicate change of discipline [str]
- tatami
number of tatamis [int]
- break_type
“block” ; “Individual” [str]
- breaktime
time when the break should happen [dateime]
- breaklength
length of the break [datetime]
- tourcalc.calculator.minloadtatami(loads)[source]¶
Find the tatami with the minimum load. Break the tie of tatamis having same load on first come first serve basis.
Parameters¶
- loads
list of loads [float]
- tourcalc.calculator.read_in_file(fname)[source]¶
- Read in file
HELPER FUNCTION TO READ IN THE CSV FILE
Parameters¶
- fname
name of the tournament [str]
- tourcalc.calculator.split_categories(cat_time_dict, av_time)[source]¶
If a category is longer than the average time for the day plus 30 min (1800 sec), the category is split in 1/3 and 2/3 and can be planned parallel
Parameters¶
- cat_time_dict
dict that links the category to a day [dict (string -> int)]
- av_time
average time per day [timedelta]
- tourcalc.calculator.write_tour_file(tour_name, df, i_tatami, days, final, start_time, date, break_t)[source]¶
create a new tournament file
Parameters¶
- tour_name
name of the tournament [str]
- cat_par
dict that links the category to a number of participants [dict (string -> int)]
- cat_dict_day
dict that links the category to a day [dict (string -> int)]
- i_tatami
number of tatamis [int]
- days
number of days [int]
- final
does the event have a final block [bool]
- start_time
time when the event should happen [dateime]
- date
date of the first day of the event [dateime]
- break_t
type of the break that is used [individual, block, no break]