Skip to content

Commit 593d95b

Browse files
committed
'0328'
1 parent c167e80 commit 593d95b

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

UQPyL/problems/single_objective/single_simple_problem.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,7 @@ class Ackley(ProblemABC):
323323
X*=0 0 0 ... 0
324324
F*=0
325325
'''
326+
name = "Ackley"
326327
def __init__(self, nInput:int =30,
327328
ub: Union[int, float, list, np.ndarray] =32,
328329
lb: Union[int, float, list, np.ndarray] =-32):
@@ -335,7 +336,7 @@ def objFunc(self, X: np.ndarray) -> np.ndarray:
335336

336337
Temp1 = np.exp(np.sqrt(np.sum(np.square(X),axis=1)/self.nInput)*-0.2)*-20
337338
Temp2 = np.exp(np.sum(np.cos(2*np.pi*X),axis=1)/self.nInput)*-1+20+np.e
338-
F = (Temp1+Temp2).reshape[:, np.newaxis]
339+
F = (Temp1+Temp2)[:, np.newaxis]
339340

340341
return F
341342

@@ -507,12 +508,12 @@ def objFunc(self, X: np.ndarray) -> np.ndarray:
507508
K = np.atleast_2d(np.linspace(1, self.kMax, self.kMax))
508509
aK = np.power(self.a, K)
509510
bK = np.power(self.b, K)
510-
aK_expand = np.tile(aK.transpose(),(1, self.nInput))[:, np.newaxis]
511-
bK_expand = np.tile(bK.transpose(),(1, self.nInput))[:, np.newaxis]
511+
aK_expand = np.tile(aK,(1, self.nInput))
512+
bK_expand = np.tile(bK,(1, self.nInput))
512513

513514

514515
X_expand = np.tile(X, (1, self.kMax))
515-
Addition = np.sum(aK * np.cos(bK * np.pi), axis=1)[:, np.newaxis] * self.nInput
516+
Addition = np.sum(aK * np.cos(bK * np.pi)) * self.nInput
516517
F = np.sum(np.cos(2 * np.pi * (X_expand + 0.5) * bK_expand) * aK_expand, axis=1)[:, np.newaxis] - Addition
517518

518519
return F

examples/test_problem.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
import numpy as np
55
from UQPyL.problems import Problem, ProblemABC
66

7+
from UQPyL.problems.single_objective.single_simple_problem import Ackley, Weierstrass
8+
from UQPyL.DoE import LHS
9+
710
#-----------------------------------------------#
811
#Type1: Objective Function and Constraint Function are separate
912

0 commit comments

Comments
 (0)