mirror of
https://github.com/kuhyx/WUT_Computer_Science.git
synced 2026-07-06 21:03:14 +02:00
fix: fix for Windows
This commit is contained in:
parent
69c2aa4116
commit
0e0a3db307
11
lab3/main.py
11
lab3/main.py
@ -4,9 +4,10 @@ Program that optimizes Rastrigin function: file_ (x_point_value, y_point_value)
|
|||||||
Using Evolutionary Strategy (μ, λ).
|
Using Evolutionary Strategy (μ, λ).
|
||||||
"""
|
"""
|
||||||
import sys
|
import sys
|
||||||
|
import os
|
||||||
import time
|
import time
|
||||||
import tempfile
|
import tempfile
|
||||||
from cv2 import cv2
|
import cv2
|
||||||
import matplotlib.pyplot as plt
|
import matplotlib.pyplot as plt
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
|
||||||
@ -109,7 +110,7 @@ def output(population_output):
|
|||||||
# define the visualization params
|
# define the visualization params
|
||||||
colors = np.random.rand(output_length)
|
colors = np.random.rand(output_length)
|
||||||
|
|
||||||
with tempfile.NamedTemporaryFile(suffix=".png") as file_:
|
with tempfile.NamedTemporaryFile(suffix=".png", delete=False) as file_:
|
||||||
# iterate over the optimization steps
|
# iterate over the optimization steps
|
||||||
# generate random 2D data - replace it with the results from your
|
# generate random 2D data - replace it with the results from your
|
||||||
# algorithm
|
# algorithm
|
||||||
@ -142,6 +143,12 @@ def output(population_output):
|
|||||||
|
|
||||||
cv2.destroyAllWindows()
|
cv2.destroyAllWindows()
|
||||||
|
|
||||||
|
try:
|
||||||
|
file_.close()
|
||||||
|
os.unlink(file_.name)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
def user_input():
|
def user_input():
|
||||||
""" Handle user terminal arguments"""
|
""" Handle user terminal arguments"""
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user