-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
30 lines (22 loc) · 833 Bytes
/
Copy pathmain.py
File metadata and controls
30 lines (22 loc) · 833 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# main.py
# Entry point for the Firewall Rule Optimization GA.
# Run this file to execute the full pipeline.
import json
from ga.engine import run_ga
from visualizer.dashboard import show_dashboard
def main():
# Step 1: Load test packets generated by simulator/packets.py
with open("data/sample_packets.json", "r") as f:
packets = json.load(f)
# Step 2: Run the GA (200 generations, population of 50)
print("Starting GA...")
results = run_ga(packets, population_size=50, generations=200)
# Step 3: Print the best firewall found
best = results["best_chromosome"]
print(f"\nBest firewall found ({len(best.rules)} rules):")
for rule in best.rules:
print(f" {rule}")
# Step 4: Show the dashboard
show_dashboard(results["history"])
if __name__ == "__main__":
main()