-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpyProblem.py
More file actions
72 lines (52 loc) · 1.72 KB
/
pyProblem.py
File metadata and controls
72 lines (52 loc) · 1.72 KB
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
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# Copyright (c) 2016 Vesa Ojalehto
#
# This work was supported by the Academy of Finland (grant number 287496)
'''
Mockup of python interface for MOEAFremework problems
'''
class Variable(object):
def __init__(self,lb,ub):
self.value=None
self.ub=lb
self.lb=ub
def setValue(self,val):
self.value=val
def getUpperBound(self):
return self.ub
def getLowerBound(self):
return self.lb
class Solution(object):
def __init__(self,problem,nx,nf):
self.problem=problem
self.objectives = [None]*nf
def getVariable(self,i):
return self.problem.variables[i]
def getObjectives(self):
return self.objectives[:]
class Problem(object):
'''
'''
def __init__(self, nf=3,nx=2,lb=[1,1],ub=[3,3]):
'''
'''
self.nf=nf
self.nx=nx
self.variables=[]
self.ideal=[ 132.7119,540.6497,20.0]
self.nadir=[4175.257,7299.239,780.3944]
for xi in range(nx):
self.variables.append(Variable(lb[xi],ub[xi]))
def newSolution(self):
return Solution(self,self.nx,self.nf)
def getNumberOfVariables(self):
return len(self.variables)
def evaluate(self,solution):
map
x=[x.value for x in self.variables]
solution.objectives[0]=50*x[0]**4+10*x[1]**4
solution.objectives[1]=30*(x[0]-5)**4+100*(x[1]-3)**4
solution.objectives[2]=70*(x[0]-2)**4+20*(x[1]-4)**4