module algorithm.classroom

Short summary

module code_beatrix.algorithm.classroom

Positions in a classroom

source on GitHub

Functions

function truncated documentation
distance Computes the distance between two positions.
find_best_positions_greedy Finds the best position for name, explore all positions.
measure_positions Returns the sum of edges weights.
optimize_positions Optimizes the positions.
plot_positions Draws positions and first names into a graph.
random_positions Draws random position for some person in a classroom.

Documentation

Positions in a classroom

source on GitHub

code_beatrix.algorithm.classroom.distance(p1, p2)[source]

Computes the distance between two positions.

Paramètres:
  • p1 – position 1
  • p2 – position 2
Renvoie:

distance

source on GitHub

code_beatrix.algorithm.classroom.find_best_positions_greedy(positions, edges, name)[source]

Finds the best position for name, explore all positions.

Paramètres:
  • positions – dictionary { name : (x, y) }
  • edges – list of affinities as a dictionary { name: [names] }
  • name – name to optimize
Renvoie:

list of positions

source on GitHub

code_beatrix.algorithm.classroom.measure_positions(positions, edges)[source]

Returns the sum of edges weights.

Paramètres:
  • positions – dictionary { name : (x, y) }
  • edges – list of affinities (name1, name2)
Renvoie:

distance

source on GitHub

code_beatrix.algorithm.classroom.optimize_positions(positions, edges, max_iter=100, fLOG=<function noLOG>, plot_folder=None)[source]

Optimizes the positions.

Paramètres:
  • positions – dictionary { name : (x, y) }
  • edges – list of affinities (name1, name2)
  • max_iter – maximum number of iterations
  • plot_folder – if not None, saves images into this folder
Renvoie:

positions, iterations

source on GitHub

code_beatrix.algorithm.classroom.plot_positions(positions, edges=None, ax=None, **options)[source]

Draws positions and first names into a graph.

Paramètres:
  • positions – list of 3-uple (name, x, y)
  • ax – axis
  • edges – edges
  • options – options for matplotlib
Renvoie:

ax

First position: 0

source on GitHub

code_beatrix.algorithm.classroom.random_positions(nb, names=None)[source]

Draws random position for some person in a classroom.

Paramètres:
  • nb – number of persons
  • names – names (None for default)
Renvoie:

list of 3-uple(name, x, y)

source on GitHub