Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ml searcher #71

Merged
merged 69 commits into from
Aug 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
15c27d7
Do not create symlink on last test to prevent conflict during parall…
gsvgit Jun 1, 2023
fa3ae5b
Merge branch 'mlSearcher' of https://github.com/gsvgit/VSharp into ml…
gsvgit Jun 2, 2023
4cbd7dd
added common model and new predictor for training this model
Anya497 Jul 20, 2023
04376be
Merge branch 'mlSearcher' of https://github.com/Anya497/VSharp into c…
Anya497 Jul 20, 2023
346a1c7
fixed play_map
Anya497 Jul 21, 2023
a11b1f6
Ignore new python env
Anya497 Jul 21, 2023
efe35fe
fixed play_map
Anya497 Jul 21, 2023
42fa132
Merge branch 'mlSearcher' of https://github.com/gsvgit/VSharp into ml…
gsvgit Jul 21, 2023
a090739
Merge remote-tracking branch 'anya/mlSearcher' into mlSearcher
gsvgit Jul 21, 2023
458b4e2
Do not wait exploration task on timeout.
gsvgit Jul 21, 2023
3becb0c
Merge branch 'mlSearcher' of https://github.com/Anya497/VSharp into c…
Anya497 Jul 21, 2023
09bb8e5
Merge branch 'mlSearcher' of https://github.com/gsvgit/VSharp into co…
Anya497 Jul 21, 2023
8da717c
added some functions for CommonModel training
Anya497 Jul 21, 2023
301c0e0
new maps
Anya497 Jul 28, 2023
5aa6ada
Merge branch 'mlSearcher' of https://github.com/Anya497/VSharp into m…
Anya497 Jul 28, 2023
262282c
Merge branch 'gsvgit:mlSearcher' into mlSearcher
Anya497 Aug 3, 2023
4702f01
Remove new timeout, shorten dict upd
emnigma Aug 6, 2023
1c4f1c6
Upd socket manager
emnigma Aug 7, 2023
60a82e7
Add retries count logging
emnigma Aug 7, 2023
622b374
Add retries to acquire_instance call, fix minor issues
emnigma Aug 7, 2023
c7f127d
Add try count
emnigma Aug 7, 2023
eb45f9b
Add error raise on empty dequeue
emnigma Aug 8, 2023
4c2d924
Bring socket instantiation up from try-catch
emnigma Aug 8, 2023
7393d97
Add logging to server
emnigma Aug 8, 2023
80d8337
Add killed server status display
emnigma Aug 8, 2023
a1532cd
Add process status check with retries
emnigma Aug 8, 2023
2d9d9ad
Fix typo
emnigma Aug 8, 2023
581b3ff
Decrease sleep time
emnigma Aug 8, 2023
9671445
Up wait reset time
emnigma Aug 8, 2023
eefc438
1 -> 0.1 wait time
emnigma Aug 8, 2023
8a6b842
Up retry time
emnigma Aug 8, 2023
7659fb8
Add config
emnigma Aug 8, 2023
c1bba65
Wait for server alive
emnigma Aug 8, 2023
5ca475a
Fix desc
emnigma Aug 8, 2023
8c027d0
Add url
emnigma Aug 8, 2023
66c8fe7
Verbose message
emnigma Aug 8, 2023
16dc283
Fix rare server state case
emnigma Aug 8, 2023
2a8f21a
View process status when try connecting
emnigma Aug 8, 2023
af8edfa
Fix typo
emnigma Aug 8, 2023
51ee70a
Solve issue on server
emnigma Aug 8, 2023
359c88e
Upd logs msg
emnigma Aug 9, 2023
1ef5e4b
More verbosity
emnigma Aug 9, 2023
cac8880
View server info when deque
emnigma Aug 9, 2023
d80937f
Add not ok responce logging
emnigma Aug 9, 2023
ab8c187
Launch servers on dequeue
emnigma Aug 9, 2023
d5eb307
Add status check
emnigma Aug 10, 2023
2162201
Upd status check
emnigma Aug 10, 2023
3d30cca
Add error ignoring
emnigma Aug 10, 2023
0550cdd
Port code
gsvgit Aug 10, 2023
add882d
added some code
gsvgit Aug 10, 2023
7ca8d00
added model validation and best_models updating after each epoch
Anya497 Aug 10, 2023
3957cf1
Merge branch 'rebased_common_model' of https://github.com/Anya497/VSh…
gsvgit Aug 10, 2023
ba0dc1b
Merge branch 'gsvgit:mlSearcher' into mlSearcher
Anya497 Aug 11, 2023
57b45c6
merging changes in VSharp core
Anya497 Aug 11, 2023
26f408a
added maps names to logs, deleted difficult maps from train dataset
Anya497 Aug 8, 2023
173f15a
Remove obsolete file
Anya497 Aug 11, 2023
6087f56
added best_models dict saving
gsvgit Aug 14, 2023
ede21a7
new model output format is included
gsvgit Aug 14, 2023
fd3ed54
Merge branch 'rebased_common_model' of https://github.com/Anya497/VSh…
Anya497 Aug 14, 2023
5f4b649
maps shuffle is added
gsvgit Aug 14, 2023
896f7c3
Merge branch 'rebased_common_model' of https://github.com/Anya497/VSh…
Anya497 Aug 14, 2023
70e14a2
Merge branch 'mlSearcher' of https://github.com/gsvgit/VSharp into re…
Anya497 Aug 14, 2023
da67a47
some bugs in the best models dict saving are fixed, tuple results pro…
gsvgit Aug 15, 2023
0c3d810
Merge branch 'mlSearcher' of https://github.com/gsvgit/VSharp into re…
gsvgit Aug 15, 2023
0d23c06
Merge branch 'rebased_common_model' of https://github.com/Anya497/VSh…
Anya497 Aug 15, 2023
291da59
Merge branch 'rebased_common_model' of https://github.com/Anya497/VSh…
gsvgit Aug 15, 2023
17585ac
Ignore pretrained models and reports.
gsvgit Aug 15, 2023
5fea8de
merge mlSearcher
gsvgit Aug 15, 2023
ee0e59d
Merge branch 'rebased_common_model' into mlSearcher
gsvgit Aug 15, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -244,12 +244,12 @@ VSharp.Test/GeneratedTests/**

#Pytjon environments
**/.env/**
/torch_venv/**

#Python caches
**/__pycache__/**

#logs
**/logs_full*/**

/output/**
/References/*.dll
3 changes: 2 additions & 1 deletion VSharp.ML.AIAgent/.gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# python cache and venv
.env
__pycache__/
report/
report**/
ml/pretrained_models/
*.pkl
*.onnx
3 changes: 3 additions & 0 deletions VSharp.ML.AIAgent/learning/play_game.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from statistics import StatisticsError
from time import perf_counter
from typing import TypeAlias
import random

import tqdm
from func_timeout import FunctionTimedOut, func_set_timeout
Expand Down Expand Up @@ -83,6 +84,7 @@ def play_map(
actual_coverage_percent=actual_coverage,
)

with_predictor.update(with_connector.map.MapName, model_result)
return model_result, end_time - start_time


Expand Down Expand Up @@ -116,6 +118,7 @@ def play_map_with_timeout(
def play_game(with_predictor: Predictor, max_steps: int, maps_type: MapsType):
with game_server_socket_manager() as ws:
maps = get_maps(websocket=ws, type=maps_type)
random.shuffle(maps)
with tqdm.tqdm(
total=len(maps),
desc=f"{with_predictor.name():20}: {maps_type.value}",
Expand Down
209 changes: 0 additions & 209 deletions VSharp.ML.AIAgent/ml/common_model.py

This file was deleted.

89 changes: 89 additions & 0 deletions VSharp.ML.AIAgent/ml/common_model/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
import torch
from torch import nn
from torch_geometric.nn import (
GATConv,
SAGEConv,
TAGConv,
)
from torchvision.ops import MLP


class CommonModel(torch.nn.Module):
def __init__(
self,
hidden_channels,
num_gv_layers=2,
num_sv_layers=2,
):
super().__init__()
self.tag_conv1 = TAGConv(5, hidden_channels, 2)
self.tag_conv2 = TAGConv(6, hidden_channels, 3)
self.gv_layers = nn.ModuleList()
self.gv_layers.append(self.tag_conv1)
self.gv_layers.append(SAGEConv(-1, hidden_channels))
for i in range(num_gv_layers - 1):
sage_gv = SAGEConv(-1, hidden_channels)
self.gv_layers.append(sage_gv)

self.sv_layers = nn.ModuleList()
self.sv_layers.append(self.tag_conv2)
self.sv_layers.append(SAGEConv(-1, hidden_channels))
for i in range(num_sv_layers - 1):
sage_sv = SAGEConv(-1, hidden_channels)
self.sv_layers.append(sage_sv)

self.history1 = GATConv((-1, -1), hidden_channels, add_self_loops=False)

self.in1 = SAGEConv((-1, -1), hidden_channels)

self.sv_layers2 = nn.ModuleList()
self.sv_layers2.append(SAGEConv(-1, hidden_channels))
for i in range(num_sv_layers - 1):
sage_sv = SAGEConv(-1, hidden_channels)
self.sv_layers2.append(sage_sv)

self.mlp = MLP(hidden_channels, [1])

def forward(self, x_dict, edge_index_dict, edge_attr_dict):
game_x = self.gv_layers[0](
x_dict["game_vertex"],
edge_index_dict[("game_vertex", "to", "game_vertex")],
).relu()
for layer in self.gv_layers[1:]:
game_x = layer(
game_x,
edge_index_dict[("game_vertex", "to", "game_vertex")],
).relu()

state_x = self.sv_layers[0](
x_dict["state_vertex"],
edge_index_dict[("state_vertex", "parent_of", "state_vertex")],
).relu()
for layer in self.sv_layers[1:]:
state_x = layer(
state_x,
edge_index_dict[("state_vertex", "parent_of", "state_vertex")],
).relu()

history_x = self.history1(
(game_x, state_x),
edge_index_dict[("game_vertex", "history", "state_vertex")],
edge_attr_dict,
size=(game_x.size(0), state_x.size(0)),
).relu()

in_x = self.in1(
(game_x, history_x), edge_index_dict[("game_vertex", "in", "state_vertex")]
).relu()

state_x = self.sv_layers2[0](
in_x,
edge_index_dict[("state_vertex", "parent_of", "state_vertex")],
).relu()
for layer in self.sv_layers2[1:]:
state_x = layer(
state_x,
edge_index_dict[("state_vertex", "parent_of", "state_vertex")],
).relu()
x = self.mlp(in_x)
return x
6 changes: 6 additions & 0 deletions VSharp.ML.AIAgent/ml/common_model/paths.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import os

csv_path = os.path.join("report", "epochs_tables")
models_path = os.path.join("report", "epochs_best")
common_models_path = os.path.join("report", "common_models")
best_models_dict_path = os.path.join("report", "updated_best_models_dicts")
Loading
Loading