-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun_EA.py
80 lines (60 loc) · 2.41 KB
/
run_EA.py
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
"""
================================================================================
Evolutionary Algorithm Main Routine
================================================================================
Author: Eric Johnson
Date Created: Monday, November 20, 2017
Date Revised: Wednesday, February 20, 2019
Email: [email protected]
================================================================================
================================================================================
This file will contain the main evolutionary algorithm program for this
project. The outline of the procedures here are as follows:
1. Population is initialized
- Individuals are evaluated (this is a distributed process)
2. Population is duplicated, children are mutated and crossed
3. Mutated individuals are evaluated (distributed)
4. Fitnesses of individuals are compared and members of the Pareto front
are saved to the Hall of Fame (HoF)
5. Repeat
================================================================================
================================================================================
"""
from copy import deepcopy
import datetime
import importlib.util as imputl
import logging
from mpi4py import MPI
import numpy as numpy
import os
import pickle as pkl
import socket
import sys
from time import sleep
# from Base.Individual import Individual
from Base.Population import Population
# from Base.halloffame import HallofFame
# from EAMPI.distributeEvaluation import distributeEvaluation
# from EAMPI.setupProcesses import setupProcesses
import Utility.runfile_util as rfu
#===============================================================================
#===============================================================================
# Get runtime and host name
time = datetime.datetime.now().strftime("%Y.%m.%d.%H.%M.%S")
host = str(socket.gethostname())
# Get infoDir
infoDir = str(sys.argv[-1]) # The infoDir should be provided as a command-line
# input.
infoDict = rfu.getInfo(infoDir, verbose=1)
infoDict['time'] = deepcopy(time)
infoDict['host'] = deepcopy(host)
# indSpec = imputl.spec_from_file_location("Individual",
# os.path.join(infoDict['modelDir'], "model_Ind.py"))
# foo = imputl.module_from_spec(indSpec)
# indSpec.loader.exec_module(foo)
# Individual = foo.Individual
if __name__ == "__main__":
comm = MPI.COMM_WORLD
rank = comm.Get_rank()
if rank == 0:
pass