Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
marionmari committed Oct 7, 2013
1 parent cc500a9 commit ff22781
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
24 changes: 12 additions & 12 deletions Core/opt.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def findMin(self, inffunc, meanfunc, covfunc, likfunc, x, y):

if self.searchConfig:
searchRange = self.searchConfig.meanRange + self.searchConfig.covRange + self.searchConfig.likRange
if not (self.searchConfig.max_trails or self.searchConfig.min_threshold):
if not (self.searchConfig.num_restarts or self.searchConfig.min_threshold):
raise Exception('Specify at least one of the stop conditions')
while True:
self.trailsCounter += 1 # increase counter
Expand All @@ -96,10 +96,10 @@ def findMin(self, inffunc, meanfunc, covfunc, likfunc, x, y):
optimalHyp = thisopt[0]
except:
self.errorCounter += 1
if self.searchConfig.max_trails and self.errorCounter > self.searchConfig.max_trails/2:
if self.searchConfig.num_restarts and self.errorCounter > self.searchConfig.num_restarts/2:
print "[CG] %d out of %d trails failed during optimization" % (self.errorCounter, self.trailsCounter)
raise Exception("Over half of the trails failed for conjugate gradient")
if self.searchConfig.max_trails and self.trailsCounter > self.searchConfig.max_trails-1: # if exceed max_trails
if self.searchConfig.num_restarts and self.trailsCounter > self.searchConfig.num_restarts-1: # if exceed num_restarts
print "[CG] %d out of %d trails failed during optimization" % (self.errorCounter, self.trailsCounter)
return optimalHyp, funcValue
if self.searchConfig.min_threshold and funcValue <= self.searchConfig.min_threshold: # reach provided mininal
Expand Down Expand Up @@ -133,7 +133,7 @@ def findMin(self,inffunc, meanfunc, covfunc, likfunc, x, y):

if self.searchConfig:
searchRange = self.searchConfig.meanRange + self.searchConfig.covRange + self.searchConfig.likRange
if not (self.searchConfig.max_trails or self.searchConfig.min_threshold):
if not (self.searchConfig.num_restarts or self.searchConfig.min_threshold):
raise Exception('Specify at least one of the stop conditions')
while True:
self.trailsCounter += 1 # increase counter
Expand All @@ -147,10 +147,10 @@ def findMin(self,inffunc, meanfunc, covfunc, likfunc, x, y):
optimalHyp = thisopt[0]
except:
self.errorCounter += 1
if self.searchConfig.max_trails and self.errorCounter > self.searchConfig.max_trails/2:
if self.searchConfig.num_restarts and self.errorCounter > self.searchConfig.num_restarts/2:
print "[BFGS] %d out of %d trails failed during optimization" % (self.errorCounter, self.trailsCounter)
raise Exception("Over half of the trails failed for BFGS")
if self.searchConfig.max_trails and self.trailsCounter > self.searchConfig.max_trails-1: # if exceed max_trails
if self.searchConfig.num_restarts and self.trailsCounter > self.searchConfig.num_restarts-1: # if exceed num_restarts
print "[BFGS] %d out of %d trails failed during optimization" % (self.errorCounter, self.trailsCounter)
return optimalHyp, funcValue
if self.searchConfig.min_threshold and funcValue <= self.searchConfig.min_threshold: # reach provided mininal
Expand Down Expand Up @@ -179,7 +179,7 @@ def findMin(self,inffunc, meanfunc, covfunc, likfunc, x, y):

if self.searchConfig:
searchRange = self.searchConfig.meanRange + self.searchConfig.covRange + self.searchConfig.likRange
if not (self.searchConfig.max_trails or self.searchConfig.min_threshold):
if not (self.searchConfig.num_restarts or self.searchConfig.min_threshold):
raise Exception('Specify at least one of the stop conditions')
while True:
self.trailsCounter += 1 # increase counter
Expand All @@ -193,10 +193,10 @@ def findMin(self,inffunc, meanfunc, covfunc, likfunc, x, y):
optimalHyp = thisopt[0]
except:
self.errorCounter += 1
if self.searchConfig.max_trails and self.errorCounter > self.searchConfig.max_trails/2:
if self.searchConfig.num_restarts and self.errorCounter > self.searchConfig.num_restarts/2:
print "[Minimize] %d out of %d trails failed during optimization" % (self.errorCounter, self.trailsCounter)
raise Exception("Over half of the trails failed for minimize")
if self.searchConfig.max_trails and self.trailsCounter > self.searchConfig.max_trails-1: # if exceed max_trails
if self.searchConfig.num_restarts and self.trailsCounter > self.searchConfig.num_restarts-1: # if exceed num_restarts
print "[Minimize] %d out of %d trails failed during optimization" % (self.errorCounter, self.trailsCounter)
return optimalHyp, funcValue
if self.searchConfig.min_threshold and funcValue <= self.searchConfig.min_threshold: # reach provided mininal
Expand Down Expand Up @@ -224,7 +224,7 @@ def findMin(self,inffunc, meanfunc, covfunc, likfunc, x, y):

if self.searchConfig:
searchRange = self.searchConfig.meanRange + self.searchConfig.covRange + self.searchConfig.likRange
if not (self.searchConfig.max_trails or self.searchConfig.min_threshold):
if not (self.searchConfig.num_restarts or self.searchConfig.min_threshold):
raise Exception('Specify at least one of the stop conditions')
while True:
self.trailsCounter += 1 # increase counter
Expand All @@ -238,10 +238,10 @@ def findMin(self,inffunc, meanfunc, covfunc, likfunc, x, y):
optimalHyp = thisopt[0]
except:
self.errorCounter += 1
if self.searchConfig.max_trails and self.errorCounter > self.searchConfig.max_trails/2:
if self.searchConfig.num_restarts and self.errorCounter > self.searchConfig.num_restarts/2:
print "[SCG] %d out of %d trails failed during optimization" % (self.errorCounter, self.trailsCounter)
raise Exception("Over half of the trails failed for Scaled conjugate gradient")
if self.searchConfig.max_trails and self.trailsCounter > self.searchConfig.max_trails-1: # if exceed max_trails
if self.searchConfig.num_restarts and self.trailsCounter > self.searchConfig.num_restarts-1: # if exceed num_restarts
print "[SCG] %d out of %d trails failed during optimization" % (self.errorCounter, self.trailsCounter)
return optimalHyp, funcValue
if self.searchConfig.min_threshold and funcValue <= self.searchConfig.min_threshold: # reach provided mininal
Expand Down
2 changes: 1 addition & 1 deletion Optimization/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

class random_init_conf(object):
def __init__(self, mean, cov, lik):
self.max_trails = None
self.num_restarts = None
self.min_threshold = None
self.mean = mean
self.cov = cov
Expand Down

0 comments on commit ff22781

Please sign in to comment.