Skip to content
Koza-TTP

Documentation / History

Historic: the thesis (2026)

Genetic programming in baseball season planning. Feasibility and optimization problem. Computer Engineering Thesis, ITAM. Advisor: Dr. Andrés Gómez de Silva Garza. Approved on July 23, 2026.

The problem

MLB schedules 2,430 games for 30 teams in about 180 days. Each team travels between cities, and the distance varies greatly from team to team. In 2016, Seattle traveled 76,683 km, and the Chicago Cubs traveled 39,015 km.

Finding the schedule with the lowest total distance is known as the Tournament Transportation Problem (PTT). It's an NP-hard problem: the number of possible schedules grows so fast that you can't check them all.

The method

Genetic programming (PG), proposed by John Koza in 1992, mimics evolution. It creates a population of solutions, takes the best ones, and combines and modifies them to form a new generation.

  1. Representation: Each calendar is a tree. Its nodes are operations such as crear_juego (date, home team, away team) and obtener_calendario, which joins two lists of games.
  2. Viability (C1): Each team must play exactly the number of games that the tournament calls for. A value of 0 means that the schedule is valid.
  3. Distance (C2): the sum of the transfers, calculated with haversine's formula on the coordinates of each stadium.
  4. Software: three modules (planner, calculator and genetic program) with the DEAP library, separate from a web application in Django.

The results

Try 30 teams, 163 games per team, 5-game series, and 20 generations.

Comparison of Random Search and Genetic Programming
Method Prob. of crossing Prob. of mutation Feasibility (C1) Total distance (C2) Time
Random search 0.0 0.0 0 (valid) 2,663,470.70 km Shorter distance 200.25 s
Genetic programming 0.8 0.2 0 (valid) 3,182,738.33 km 3,337.81 s

The main finding

Genetic programming did not outperform random search. It gave a 19.5% greater distance and took almost 17 times longer. The best calendar always came from the initial generation, which is random.

The thesis identified these causes:

  • Generic crossover and mutation operators change nodes without knowing the problem. They almost always produce invalid calendars.
  • The fitness function gives much more weight to viability than to distance. An invalid child always loses to a valid parent.
  • The algorithm soon converged on a local optimum and retained only the initial solutions.

A negative result is also a result. It shows that the representation and operators matter as much as the algorithm.

Future work

The thesis proposed contextual operators: instead of changing nodes randomly, swap entire series or blocks that keep the calendar valid. He also mentioned quantum computing to explore many configurations at once.

See what was done after the thesis

Timeline

  1. · Pre-official version of the thesis document.
  2. · Defense in Mexico City. Thesis approved.

Materials and citation

Citation in APA format:

Brenes Valencia, L. P. (2026). Programación genética en la planificación de temporadas de béisbol (Tesis de Ingeniería en Computación). Instituto Tecnológico Autónomo de México (ITAM), Ciudad de México, México.