Skip to content

Commit

Permalink
[estimate] add bounds. Hopefully fixes #81
Browse files Browse the repository at this point in the history
  • Loading branch information
terhorst committed Apr 18, 2018
1 parent a059152 commit 1858d07
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
6 changes: 6 additions & 0 deletions smcpp/commands/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,12 @@ def add_common_estimation_args(parser):
default=smcpp.defaults.xtol,
help=r"x tolerance for optimizer. "
"optimizer will stop when |x' - x|_\infty < xtol")
optimizer.add_argument('--Nmax', type=float,
default=smcpp.defaults.maximum_population_size,
help="upper bound on scaled effective population size")
optimizer.add_argument('--Nmin', type=float,
default=smcpp.defaults.minimum_population_size,
help="lower bound on scaled effective population size")
optimizer.add_argument('--regularization-penalty', '-rp',
type=float, help="regularization penalty",
default=smcpp.defaults.regularization_penalty)
Expand Down
4 changes: 3 additions & 1 deletion smcpp/defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
maximum = 1e4
t1 = None
tK = None
regularization_degree = 1
regularization_degree = 2
spline = "piecewise"
cores = None
perplexity_threshold = .5
minimum_population_size = 1e-3
maximum_population_size = 1e3
6 changes: 5 additions & 1 deletion smcpp/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,11 @@ def f(x):
self[:] = res.x

def stepwise_values(self):
return self(np.cumsum(self.s))
ret = np.clip(self(np.cumsum(self.s)),
smcpp.defaults.minimum_population_size,
smcpp.defaults.maximum_population_size)
# logger.debug("self[:]: %s\ns: %s\nstep(): %s", self[:], self.s, ret)
return ret

def reset(self):
self[:] = 0.
Expand Down

0 comments on commit 1858d07

Please sign in to comment.