Skip to content

Commit

Permalink
slight change to how infill works
Browse files Browse the repository at this point in the history
  • Loading branch information
dronecfd committed Jun 19, 2015
1 parent 1674c1d commit afbd96c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
5 changes: 3 additions & 2 deletions pyKriging/krige.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ def infill_objective_ei(self,candidates, args):
fitness.append(-1 * self.expimp(entry))
return fitness

def infill(self, points, method='error'):
def infill(self, points, method='error', addPoint=True):
'''
The function identifies where new points are needed in the model.
:param points: The number of points to add to the model. Multiple points are added via imputation.
Expand Down Expand Up @@ -287,7 +287,8 @@ def infill(self, points, method='error'):
final_pop.sort(reverse=True)
newpoint = final_pop[0].candidate
returnValues[i][:] = newpoint
self.addPoint(returnValues[i], self.predict(returnValues[i]), norm=False)
if addPoint:
self.addPoint(returnValues[i], self.predict(returnValues[i]), norm=True)

self.X = np.copy(initX)
self.y = np.copy(inity)
Expand Down
14 changes: 7 additions & 7 deletions pyKriging/regressionkrige.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,9 @@ def __init__(self, X, y, testfunction=None, name='', testPoints=None, **kwargs):
self.sp = samplingplan(self.k)
self.updateData()
self.updateModel()

self.thetamin = 1e-4
self.thetamax = 100
self.pmin = 1
self.thetamax =100
self.pmin = 1.81231
self.pmax = 2

# Setup functions for tracking history
Expand Down Expand Up @@ -172,14 +171,15 @@ def updateModel(self):
# print Exception, err
raise Exception("bad params")

def predict(self, X):
def predict(self, X, norm=True):
'''
This function returns the prediction of the model at the real world coordinates of X
:param X: Design variable to evaluate
:return: Returns the 'real world' predicted value
'''
X = copy.deepcopy(X)
X = self.normX(X)
if norm:
X = self.normX(X)
return self.inversenormy(self.predict_normalized(X))

def predict_var(self, X, norm=True):
Expand Down Expand Up @@ -373,7 +373,7 @@ def train(self, optimizer='pso'):
# ea.observer = inspyred.ec.observers.stats_observer
final_pop = ea.evolve(generator=self.generate_population,
evaluator=self.fittingObjective,
pop_size=300,
pop_size=150,
maximize=False,
bounder=ec.Bounder(lowerBound, upperBound),
max_evaluations=30000,
Expand All @@ -388,7 +388,7 @@ def train(self, optimizer='pso'):
ea.terminator = self.no_improvement_termination
final_pop = ea.evolve(generator=self.generate_population,
evaluator=self.fittingObjective,
pop_size=300,
pop_size=50,
maximize=False,
bounder=ec.Bounder(lowerBound, upperBound),
max_evaluations=30000,
Expand Down

0 comments on commit afbd96c

Please sign in to comment.