-
Notifications
You must be signed in to change notification settings - Fork 2
/
Function.py
executable file
·75 lines (61 loc) · 2.45 KB
/
Function.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
75
# Copyright (c) 2012 EPFL (Ecole Polytechnique federale de Lausanne)
# Laboratory for Biomolecular Modeling, School of Life Sciences
#
# POW is free software ;
# you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation ;
# either version 2 of the License, or (at your option) any later version.
# POW is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY ;
# without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the GNU General Public License for more details.
# You should have received a copy of the GNU General Public License along with POW ;
# if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
#
# Author : Matteo Degiacomi, [email protected]
# Web site : http://lbm.epfl.ch
from Default import Parser as P
from Default import Space as S
from Default import Postprocess as PP
import numpy as np
import sys
class Parser(P):
def __init__(self):
pass
def check_variables(self):
pass
class Data:
def __init__(self,params):
pass
class Space(S):
def __init__(self,params,data):
#assign low boundaries
if params.low_input!="NA" :
self.low=np.zeros(len(params.low_input))
for i in xrange(0,len(params.low_input),1):
self.low[i]=params.low_input[i]
else:
print "ERROR: boundaryMin should be defined"
sys.exit(1)
#assign high boundaries
if params.high_input!="NA" :
self.high=np.zeros(len(params.low_input))
for i in xrange(0,len(params.high_input),1):
self.high[i]=params.high_input[i]
else:
print "ERROR: boundaryMax should be defined"
sys.exit(1)
#set boundary type (default is periodic)
self.boundary_type=np.zeros(len(params.low_input))
if params.boundary_type!="NA":
for i in xrange(0,len(params.low_input),1):
self.boundary_type[i]=params.boundary_type[i]
class Fitness:
def __init__(self,data,params):
pass
def evaluate(self,num,pos):
#rastrigin function (used for benchmark)
return 10*len(pos)+np.sum(pos**2-10*np.cos(2*np.pi*pos))
class Postprocess(PP):
def __init__(self,data,params):
pass
def run(self) :
pass