module algorithm.classroom

Short summary

module code_beatrix.algorithm.classroom

Position in a classroom

source on GitHub

Functions

function truncated documentation
distance computes the distance between two positions
find_best_positions_greedy find the best position for name, explore all positions
measure_positions returns the sum of edges weights
optimize_positions optimize the positions
plot_positions draw positions and first names into a graph
random_positions draws random position for some person in a classroom

Documentation

Position 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
Retourne:

distance

source on GitHub

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

find 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
Retourne:

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)
Retourne:

distance

source on GitHub

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

optimize the positions

Paramètres:
  • positions – dictionary { name : (x, y) }
  • edges – list of affinities (name1, name2)
  • max_iter – maximum number of iterations
Retourne:

positions, iterations

source on GitHub

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

draw 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
Retourne:

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)
Retourne:

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

source on GitHub