Skip to content

Commit e84489f

Browse files
committed
pass kwargs in demos
1 parent 2a0bc5c commit e84489f

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

demos/bbo_discrete/main.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
# Custom fitness function resembling the concatenated deceptive trap function of size k
55
class CustomTrapFunction(gomea.fitness.BBOFitnessFunctionDiscrete):
66
# Any members must be assigned in __new__ to make them accessible during instantiation of superclass
7-
def __new__(self, number_of_variables, k, value_to_reach):
7+
def __new__(self, number_of_variables, k, **kwargs):
88
assert( number_of_variables % k == 0 )
99
self.k = k
10-
return super().__new__(self,number_of_variables,value_to_reach)
10+
return super().__new__(self,number_of_variables,**kwargs)
1111

1212
def objective_function(self, objective_index, variables):
1313
f = 0

demos/gbo_discrete/main.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
# Custom fitness function resembling the concatenated deceptive trap function of size k
55
class CustomTrapFunction(gomea.fitness.GBOFitnessFunctionDiscrete):
66
# Any members must be assigned in __new__ to make them accessible during instantiation of superclass
7-
def __new__(self, number_of_variables, k, value_to_reach):
7+
def __new__(self, number_of_variables, k, **kwargs):
88
assert( number_of_variables % k == 0 )
99
self.k = k
10-
return super().__new__(self,number_of_variables,value_to_reach)
10+
return super().__new__(self,number_of_variables,**kwargs)
1111

1212
def number_of_subfunctions( self ):
1313
return self.number_of_variables // self.k

gomea/fitness.pyx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ cdef class GBOFitnessFunctionDiscrete(GBOFitnessFunction):
9999
number_of_variables : int,
100100
value_to_reach : float = 1e308,
101101
alphabet_size : int = 2,
102+
**kwargs
102103
):
103104
self.number_of_variables = number_of_variables
104105
self.alphabet_size = alphabet_size
@@ -111,7 +112,8 @@ cdef class GBOFitnessFunctionDiscrete(GBOFitnessFunction):
111112
cdef class GBOFitnessFunctionRealValued(GBOFitnessFunction):
112113
def __cinit__(self,
113114
number_of_variables : int,
114-
value_to_reach : float = 0.0
115+
value_to_reach : float = 0.0,
116+
**kwargs
115117
):
116118
self.number_of_variables = number_of_variables
117119
self.value_to_reach = value_to_reach
@@ -132,6 +134,7 @@ cdef class BBOFitnessFunctionDiscrete(BBOFitnessFunction):
132134
number_of_variables : int,
133135
value_to_reach : float = 1e308,
134136
alphabet_size : int = 2,
137+
**kwargs
135138
):
136139
self.number_of_variables = number_of_variables
137140
self.alphabet_size = alphabet_size
@@ -144,7 +147,8 @@ cdef class BBOFitnessFunctionDiscrete(BBOFitnessFunction):
144147
cdef class BBOFitnessFunctionRealValued(BBOFitnessFunction):
145148
def __cinit__(self,
146149
number_of_variables : int,
147-
value_to_reach : float = 0.0
150+
value_to_reach : float = 0.0,
151+
**kwargs
148152
):
149153
self.number_of_variables = number_of_variables
150154
self.value_to_reach = value_to_reach

0 commit comments

Comments
 (0)