This code, so far in a notebook form, implements and experiments with a Genetic Algorithm (GA) based sky observation scheduler and a neural-network surrogate model for fitness prediction. It is intended as a research / prototyping toolkit for optimizing telescope pointings against probabilistic sky maps (HEALPix) and operational constraints.
- Purpose: evaluate and evolve observation schedules (chromosomes) composed of ordered pointings (genes). Fitness accounts for detection probability from HEALPix maps and operational costs (airmass, slew, overlap, visibility).
- Inputs: HEALPix probability map(s) and optional tile grids in
data/. - Outputs: console logs, Matplotlib / healpy visualizations (fitness evolution, best chromosome overlay), and a summary table of chromosomes and scores.
-
𧬠Chromosome representation
-
Each chromosome is a list of genes. A gene is a dict containing
id,ra_deg,dec_deg,start_time,exposure_s, and optionalquality/probabilityfields. -
π Derived fields
-
recompute_derived_fields()computes per-gene airmass and slew (angular separation) using Astropy and stores them asairmassandslew_from_prev_deg. -
βοΈ Fitness function (
compute_fitness) -
Reward: HEALPix probability integrated over a small circular patch around each pointing (or per-gene probability if present), time-weighted to prefer earlier observations.
-
Penalties: airmass above a threshold, slew-time (proportional to angular movement), overlap duration between pointings, and hard penalties for infeasible (below-horizon) pointings.
-
Parameters:
AIRMAX,LAMBDA_SLEW,LAMBDA_AIRMASS,LAMBDA_OVERLAP,LAMBDA_HARDlocated in the notebook for easy tuning. -
β»οΈ Genetic Algorithm operators
-
mutate()β small random perturbations to RA/Dec or start time. -
crossover()β single crossover point mixing parents. -
evolve_population()β selection (retain fraction), elitism, breeding, and mutation. -
π€ Neural-network surrogate
-
Encodes chromosomes into fixed-length feature vectors (
encode_chromosome) and trains a PyTorch MLP (FitnessNN) to regress real fitness values. -
After training, the NN predicts fitness for chromosomes and an NN-assisted GA loop demonstrates evolution using predicted fitness.
- Ensure required Python packages are installed:
numpy,astropy,healpy,pandas,matplotlib,torch,python-dateutil. - Open and run
testing.ipynbin Jupyter / VS Code. The notebook is organized to run end-to-end, but you can selectively execute sections (data load, GA-only loop, NN training, NN-assisted GA).
Example environment setup (pip):
python -m pip install -r requirements.txt
# or install packages individually:
pip install numpy astropy healpy pandas matplotlib torch python-dateutildata/LALInference_v2.fits.gz(HEALPix probability map used by default in the example)data/GW170817_Generic_GRID.txt(optional tile grid used bymake_population)
normalize_chromosome()β normalizes input gene fields and datetimes.recompute_derived_fields()β computes airmass and slew from prior pointing.compute_fitness()β core reward / penalty aggregation used by the GA.evolve_population(),mutate(),crossover()β GA operators.encode_chromosome(),FitnessNNβ NN encoding and model.
