Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

Commit

Permalink
updates the automation scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
brenomfviana committed Nov 1, 2021
1 parent 00a3ba1 commit 7247355
Show file tree
Hide file tree
Showing 2 changed files with 97 additions and 52 deletions.
22 changes: 14 additions & 8 deletions plot.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import copy
import os
import sys
from pathlib import Path
import copy
import json
import numpy as np
from pandas.core import base
Expand Down Expand Up @@ -62,13 +62,20 @@ def plot_heatmap(map, folder, filename, max, title):
os.mkdir(CHART_FOLDER)

# Calculate the basename
basename = sys.argv[1] + '-' # Maximum time
basename += sys.argv[2] + '-' # Initial population size
basename += sys.argv[3] + '-' # Mutation chance
basename += sys.argv[4] # Number of competitors
basename = sys.argv[1] + '-' # maximum time
basename += sys.argv[2] + '-' # initial population size
basename += sys.argv[3] + '-' # mutation chance
basename += sys.argv[4] + '-' # number of tournament competitors
basename += sys.argv[5] + '-' # weight or not the enemy sparsity
basename += sys.argv[6] + '-' # include or not empty rooms in enemy STD
basename += sys.argv[7] + '-' # number of rooms
basename += sys.argv[8] + '-' # number of keys
basename += sys.argv[9] + '-' # number of locks
basename += sys.argv[10] + '-' # number of enemies
basename += sys.argv[11] # linear coefficient

# Get the number of executions
executions = int(sys.argv[5])
executions = int(sys.argv[12])

# Calculate the mean duration
duration = []
Expand Down Expand Up @@ -218,5 +225,4 @@ def plot_heatmap(map, folder, filename, max, title):
jsonString = json.dumps(dict)
jsonFile = open(target + os.path.sep + 'duration.json', 'w')
jsonFile.write(jsonString)
jsonFile.close()

jsonFile.close()
127 changes: 83 additions & 44 deletions run.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,19 @@
# Competitors
competitors = [3]

weigths = ["True", "False"]

includes = ["True", "False"]

rooms = [20]

keys = [4]

locks = [4]

enemies = [30]

linear_coefficients = [1.7]


# --- Perform experiment
Expand All @@ -52,62 +65,88 @@
os.system('dotnet publish')


def run(ge, po, mu, co):
# Generate a random seed
rs = random.randint(0, np.iinfo(np.int32).max - 1)
def get_parameters(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11):
# Build the parameters
parameters = ""
for i in [rs, ge, po, mu, co]:
for i in [p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11]:
parameters += str(i) + ' '
parameters += '20 4 4 30 1.7'
return parameters

def get_total():
return len(times) * \
len(populations) * \
len(mutations) * \
len(competitors) * \
len(weigths) * \
len(includes) * \
len(rooms) * \
len(keys) * \
len(locks) * \
len(enemies) * \
len(linear_coefficients) * \
len(executions)

def run(parameters):
# Generate a random seed
rs = random.randint(0, np.iinfo(np.int32).max - 1)
parameters = str(rs) + ' ' + parameters
# Print parameters
print('Parameters=[', parameters, ']')
print('Parameters=[ ' + parameters + ']')
# Run algoritm for the current set of parameters
os.system(executable + parameters)

# Variables to control the experiment progress
total = len(times) * \
len(populations) * \
len(mutations) * \
len(competitors) * \
len(executions)
total = get_total()
i = 1

for ge in times:
for po in populations:
for mu in mutations:
for co in competitors:
for e in executions:
# Run execuble
run(ge, po, mu, co)
# Print progress
print("%.2f" % ((i / total) * 100))
i += 1


def plot(ge, po, mu, co, ex):
# Plot the charts for the current set of parameters
parameters = ''
for i in [ge, po, mu, co, ex]:
parameters += str(i) + ' '
for p1 in times:
for p2 in populations:
for p3 in mutations:
for p4 in competitors:
for p5 in weigths:
for p6 in includes:
for p7 in rooms:
for p8 in keys:
for p9 in locks:
for p10 in enemies:
for p11 in linear_coefficients:
for e in executions:
# Run execuble
parameters = get_parameters(p1, p2, p3, p4, p5, p6,
p7, p8, p9, p10, p11)
run(parameters)
# Print progress
print("%.2f" % ((i / total) * 100))
i += 1


# --- Plot charts of the experiment results

def plot(parameters):
os.system('python plot.py ' + parameters)

# Variables to control the experiment progress
total = len(times) * \
len(populations) * \
len(mutations) * \
len(competitors) * \
len(executions)
# Variables to control the plotting progress
total = get_total()
i = 1

# Plot all the results
# Plot charts for all sets of parameters
print('Plotting')
for ge in times:
for po in populations:
for mu in mutations:
for co in competitors:
# Plot charts
plot(ge, po, mu, co, len(executions))
# Print progress
print("%.2f" % ((i / total) * 100))
i += 1
for p1 in times:
for p2 in populations:
for p3 in mutations:
for p4 in competitors:
for p5 in weigths:
for p6 in includes:
for p7 in rooms:
for p8 in keys:
for p9 in locks:
for p10 in enemies:
for p11 in linear_coefficients:
# Plot charts
parameters = get_parameters(p1, p2, p3, p4, p5, p6,
p7, p8, p9, p10, p11)
parameters += str(len(executions))
plot(parameters)
# Print progress
print("%.2f" % ((i / total) * 100))
i += 1

0 comments on commit 7247355

Please sign in to comment.