Skip to content

Commit 5207bfa

Browse files
committed
Fix some codacy issues
1 parent 7cd7d28 commit 5207bfa

File tree

6 files changed

+31
-64
lines changed

6 files changed

+31
-64
lines changed

docs/actions.md

Lines changed: 25 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ However, in some configurations, flip action can lead to problematic configurati
1818
<img src="img/actions/flip_c_after.png" width="350"/>
1919

2020
* **triangular quad:** This configuration should be avoided, as it results in the creation of a degenerate (flat) triangle. As illustrated in the figures below, flipping dart 0 leads to a flattened face between nodes 2, 0, and 7.
21-
*
21+
2222
<img src="img/actions/flip_before_tri.png" width="350"/>
2323
<img src="img/actions/flip_after_tri.png" width="350"/>
2424

@@ -51,7 +51,6 @@ However, in some configurations, collapse action can also lead to problematic co
5151
* **Adjacency too high :** When nodes A already has an adjacency higher than 10, collapse is not possible.
5252
* **Configuration who tends to imply edge reversal**: To detect these situations, we look a the type of darts in the surrounding. When there are some darts with concave surrounding, collapse action can lead to edge reversal.
5353

54-
5554
<img src="img/actions/collapse_reversal_before.png" width="400"/>
5655
<img src="img/actions/collapse_reversal_after.png" width="360"/>
5756

@@ -65,41 +64,41 @@ However, in some configurations, collapse action can also lead to problematic co
6564

6665
The **flip** action can be decomposed as follows:
6766

68-
- Check whether the dart `d` exists.
69-
- Update the **beta1** relations.
70-
- Update the links from nodes `n1` and `n2`, if they were previously linked to the flipped dart.
71-
- Update the links from faces `F1` and `F2`, if they were previously linked to the flipped dart.
72-
- Update the node links for `d` and `d2`.
73-
- Update the face links depending on the orientation (darts which change of face):
74-
- If **counterclockwise**: update links for `d1` and `d21`.
75-
- If **clockwise**: update links for `d2111` and `d111`.
76-
- Update the scores of the nodes.
67+
* Check whether the dart `d` exists.
68+
* Update the **beta1** relations.
69+
* Update the links from nodes `n1` and `n2`, if they were previously linked to the flipped dart.
70+
* Update the links from faces `F1` and `F2`, if they were previously linked to the flipped dart.
71+
* Update the node links for `d` and `d2`.
72+
* Update the face links depending on the orientation (darts which change of face):
73+
* If **counterclockwise**: update links for `d1` and `d21`.
74+
* If **clockwise**: update links for `d2111` and `d111`.
75+
* Update the scores of the nodes.
7776

7877
## Split
7978

8079
<img src="img/actions/split_quad.png" width="600"/>
8180

8281
The **split** action can be decomposed as follows:
8382

84-
- Check whether the dart `d` exists.
85-
- Create a new node **n10** in the middle of [n1,n2]
86-
- Update node links of `d` and `d21`, they are now linked to `n10`
87-
- Create a new face with yellow darts
88-
- Update the **beta2** relations (`d1112`, `d111`,`d212`, `d21`).
89-
- Update the scores of the nodes.
83+
* Check whether the dart `d` exists.
84+
* Create a new node **n10** in the middle of [n1,n2]
85+
* Update node links of `d` and `d21`, they are now linked to `n10`
86+
* Create a new face with yellow darts
87+
* Update the **beta2** relations (`d1112`, `d111`,`d212`, `d21`).
88+
* Update the scores of the nodes.
9089

9190
## Collapse
9291

9392
<img src="img/actions/collapse_quad.png" width="600"/>
9493

9594
The **collapse** action can be decomposed as follows:
9695

97-
- Check whether the dart `d` exists.
98-
- Save the score of node `n1` for later computation.
99-
- If `n3` is not on the boundary, move its coordinates to the midpoint between `n3` and `n1`.
100-
- Check if nodes `n2` and `n4` are linked to the dart being deleted. If so, reassign their links to existing darts (node `n3` will be checked later).
101-
- Delete the face associated with `d`, along with its related darts.
102-
- Reassign all darts previously linked to `n1` so they now point to `n3`.
103-
- Link the dart associated with `n3` to an existing node.
104-
- Update the **beta2** relations (`d2`/`d12`, `d112`/`d1112`).
105-
- Recalculate the scores of the affected nodes.
96+
* Check whether the dart `d` exists.
97+
* Save the score of node `n1` for later computation.
98+
* If `n3` is not on the boundary, move its coordinates to the midpoint between `n3` and `n1`.
99+
* Check if nodes `n2` and `n4` are linked to the dart being deleted. If so, reassign their links to existing darts (node `n3` will be checked later).
100+
* Delete the face associated with `d`, along with its related darts.
101+
* Reassign all darts previously linked to `n1` so they now point to `n3`.
102+
* Link the dart associated with `n3` to an existing node.
103+
* Update the **beta2** relations (`d2`/`d12`, `d112`/`d1112`).
104+
* Recalculate the scores of the affected nodes.

mesh_model/mesh_analysis/trimesh_analysis.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
import math
22
from math import radians, cos, sin
33

4-
from networkx.classes import nodes
54
from scipy.spatial import ConvexHull, Delaunay
65
from shapely import affinity
7-
from shapely.constructive import centroid
86

97
from shapely.geometry import Polygon, Point, LineString
108

training/config/quadmesh_config_PPO_SB3.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
project_name : "Quadmesh"
2-
experiment_name : "test"
2+
experiment_name : "TEST"
33
description : ""
44

55
total_timesteps : 10000
@@ -12,8 +12,8 @@ paths:
1212
observation_counts_dir: "training/results/quad-sb3/observation_counts/"
1313

1414
dataset:
15-
evaluation_mesh_file_path : "../mesh_files/simple_quad.msh"
16-
training_mesh_file_path : "../mesh_files/simple_quad.msh"
15+
evaluation_mesh_file_path : "mesh_files/simple_quad.msh"
16+
training_mesh_file_path : "mesh_files/simple_quad.msh"
1717

1818
seed : 1
1919

training/config/quadmesh_config_PPO_perso.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
project_name : "Quadmesh"
2-
experiment_name : "random_basic_quad_test_config-TEST"
2+
experiment_name : "TEST"
33
description : ""
44

55
paths:

training/train_quadmesh.py

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -129,34 +129,4 @@ def log_end(log_writer, config, obs_registry):
129129
# SAVING POLICY
130130
torch.save(actor.state_dict(), config["paths"]["policy_saving_dir"]+config["experiment_name"]+".pth")
131131
writer.close()
132-
wandb.finish()
133-
134-
135-
136-
def train():
137-
mesh_size = 30
138-
lr = 0.0001
139-
gamma = 0.9
140-
feature = LOCAL_MESH_FEAT
141-
142-
dataset = [TM.random_mesh(30) for _ in range(9)]
143-
plot_dataset(dataset)
144-
145-
env = TriMesh(None, mesh_size, max_steps=80, feat=feature)
146-
147-
# Choix de la politique Actor Critic
148-
# actor = Actor(env, 30, 5, lr=0.0001)
149-
# critic = Critic(30, lr=0.0001)
150-
# policy = NNPolicy(env, 30, 64,5, 0.9, lr=0.0001)
151-
152-
model = PPO(env, lr, gamma, nb_iterations=3, nb_episodes_per_iteration=10, nb_epochs=2, batch_size=8)
153-
actor, rewards, wins, steps = model.train()
154-
if rewards is not None:
155-
plot_training_results(rewards, wins, steps)
156-
157-
# torch.save(actor.state_dict(), 'policy_saved/actor_network.pth')
158-
avg_steps, avg_wins, avg_rewards, final_meshes = testPolicy(actor, 5, dataset, 60)
159-
160-
if rewards is not None:
161-
plot_test_results(avg_rewards, avg_wins, avg_steps, avg_rewards)
162-
plot_dataset(final_meshes)
132+
wandb.finish()

training/train_quadmesh_SB3.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ def _on_training_end(self) -> None:
231231
if __name__ == '__main__':
232232

233233
# PARAMETERS CONFIGURATION
234-
with open("../training/config/quadmesh_config_PPO_SB3.yaml", "r") as f:
234+
with open("training/config/quadmesh_config_PPO_SB3.yaml", "r") as f:
235235
config = yaml.safe_load(f)
236236

237237
experiment_name = config["experiment_name"]

0 commit comments

Comments
 (0)