nenupy.schedule.schedule
Schedule
- class nenupy.schedule.schedule.Schedule(time_min, time_max, dt=<TimeDelta object: scale='None' format='sec' value=3600.0>)[source]
Bases:
_TimeSlots
Foundation class of observation scheduling.
- Parameters:
- Example:
>>> from nenupy.schedule import Schedule >>> from astropy.time import Time, TimeDelta >>> schedule = Schedule( >>> time_min=Time('2021-01-11 00:00:00'), >>> time_max=Time('2021-01-15 00:00:00'), >>> dt=TimeDelta(3600, format='sec') >>> )
See also
Attributes Summary
time_min
Start time of the shedule.
time_max
Stop time of the shedule.
dt
Schedule granularity (time slot duration).
Observation blocks included in the schedule.
Reserved blocks included in the schedule.
Methods Summary
set_free_slots
(start_times, stop_times)Assign a
ReservedBlock
to every Schedule time interval that is not comprised bewteenstart_times
andstop_times
.match_booking
(booking_file, key_program)insert
(*blocks)Inserts observation blocks or reserved blocks in the schedule.
plot
([days_per_line])Plots the current schedule.
plot_range
(start_time, stop_time, **kwargs)Plots the current schedule.
book
([optimize])Distributes the
observation_blocks
over the schedule time slots.export
([score_min])Exports the current schedule once
book()
has been called.Attributes and Methods Documentation
- book(optimize=False, **kwargs)[source]
Distributes the
observation_blocks
over the schedule time slots. The observing constraints are evaluated over the whole schedule.- Parameters:
optimize (
bool
) – If set toFalse
an heuristic algorithm is used to perfom the booking. However faster, this could result in sub-optimized time slots filling. If set toTrue
, a genetic algorithm is used (see below the configuration keywords). This method delivers more optimized scheduling solutions. However, due to the random nature of genetic algorithm behaviors, the results may not be reproducible and may vary from one run to the other. Default isFalse
.
Genetic algorithm configuration keywords
- Parameters:
population_size (
int
) – Size of the solution population, i.e., how many distinct soluttions are evolving at the same time. Default is 20.random_individuals (
int
) – At each generation, the population of solutions will replace its lower-scorerandom_individuals
solutions by random genome ones. This allows for genetic diversity. Default is1
.score_threshold (
float
) – Score value (between0
and1
) at which the evolution may stop. Default is0.8
.generation_max (
int
) – Maximum generation number at which the evolution has to stop (even ifscore_threshold
is not reached). Default is1000
.max_stagnating_generations (
int
) – If the score does not evolve aftermax_stagnating_generations
generations, the evolution is stopped. Default is100
.selection (
str
) – At each generation, pairs of individuals (solutions) are selected to give birth to new children with a mix of their genomes (seecrossover
). This selection can be perfomed according to three methods.'FPS'
(Fitness Proportionate Selection): parents are as likely to be picked as their score is high.'TNS'
(Tournament Selection): \(k\) individuals from the population are selected, the best becomes a parent (where \(k = \max( 2, \rm{population\ size}/10 )\)).'RKS'
(Rank Selection): individuals are ranked according to their scores, and are more likely to be picked according to their rank. The amplitude of score differences doesn’t count. Default is'FPS'
.crossover – Whenever parents give birth to children, their genome (i.e., time slot indices for each observation block) is mixed. This cross-over can be performed according to three methods.
'SPCO'
(Single-point crossover): genes from ‘parent1’ and ‘parent2’ are interverted after a random index.'TPCO'
(Two-point crossover): genes from ‘parent1’ and ‘parent2’ are interverted between two random indices.'UNCO'
(Uniform crossover): every genes from ‘parent1’ and ‘parent2’ are interverted with a uniform probability. Default is'SPCO'
.
- Returns:
If
optimize
is set toFalse
, nothing is returned. Ifoptimize
is set toTrue
, theGeneticAlgorithm
instance is returned. The methodplot
can then be called to visualize the evolution of the solution populations.- Return type:
None
orGeneticAlgorithm
- export(score_min=0)[source]
Exports the current schedule once
book()
has been called. Every observation with ascore
higher thanscore_min
is included in the export.
- insert(*blocks)[source]
Inserts observation blocks or reserved blocks in the schedule.
- Parameters:
*blocks (
Block
,ObsBlock
orReservedBlock
) – Observation blocks or reserved blocks.- Example:
from nenupy.schedule import Schedule, ESTarget, ObsBlock from astropy.time import Time, TimeDelta schedule = Schedule( time_min=Time('2021-01-11 00:00:00'), time_max=Time('2021-01-15 00:00:00'), dt=TimeDelta(3600, format='sec') ) cas_a = ObsBlock( name="Cas A", program="ES00", target=ESTarget.fromName("Cas A"), duration=TimeDelta(2*3600, format='sec'), ) schedule.insert(cas_a)
- property observation_blocks
Observation blocks included in the schedule.
- Setter:
Observation blocks.
- Getter:
Observation blocks.
- Type:
ScheduleBlocks
- plot(days_per_line=1, **kwargs)[source]
Plots the current schedule.
Data display keywords
- Parameters:
days_per_line (
int
) – Number of days to plots per line. Default is1
.
Plotting layout keywords
- plot_range(start_time, stop_time, **kwargs)[source]
Plots the current schedule.
Data display keywords
- Parameters:
Plotting layout keywords
- property reserved_blocks
Reserved blocks included in the schedule. No observation can be planned on these time slots.
- Setter:
Reserved blocks.
- Getter:
Reserved blocks.
- Type:
- property score
Returns the current schedule score.
- set_free_slots(start_times, stop_times)[source]
Assign a
ReservedBlock
to every Schedule time interval that is not comprised bewteenstart_times
andstop_times
.