module algorithm.classroom
¶
Short summary¶
module code_beatrix.algorithm.classroom
Positions in a classroom
Functions¶
function |
truncated documentation |
---|---|
Computes the distance between two positions. |
|
Finds the best position for name, explore all positions. |
|
Returns the sum of edges weights. |
|
Optimizes the positions. |
|
Draws positions and first names into a graph. |
|
Draws random position for some person in a classroom. |
Documentation¶
Positions in a classroom
- code_beatrix.algorithm.classroom.distance(p1, p2)¶
Computes the distance between two positions.
- Paramètres:
p1 – position 1
p2 – position 2
- Renvoie:
distance
- code_beatrix.algorithm.classroom.find_best_positions_greedy(positions, edges, name)¶
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
- code_beatrix.algorithm.classroom.measure_positions(positions, edges)¶
Returns the sum of edges weights.
- Paramètres:
positions – dictionary
{ name : (x, y) }
edges – list of affinities
(name1, name2)
- Renvoie:
distance
- code_beatrix.algorithm.classroom.optimize_positions(positions, edges, max_iter=100, fLOG=<function noLOG>, plot_folder=None)¶
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
- code_beatrix.algorithm.classroom.plot_positions(positions, edges=None, ax=None, **options)¶
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
- code_beatrix.algorithm.classroom.random_positions(nb, names=None)¶
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)