Closed itsdawei closed 2 years ago
Visualizing using the new sigma0
parameter.
from ribs.archives import GridArchive
from ribs.emitters import GaussianEmitter, IsoLineEmitter
from ribs.optimizers import Optimizer
import numpy as np
import matplotlib.pyplot as plt
from ribs.visualize import grid_archive_heatmap
archive = GridArchive(
dims=[20, 20],
ranges=[(-1, 1), (-1, 1)],
)
# emitters = [
# GaussianEmitter(
# archive,
# x0=[0.0] * 10,
# sigma=1,
# sigma0=0.1, # should generate a small circle of solutions around (0,0)
# )
# ]
emitters = [
IsoLineEmitter(
archive,
x0=[0.0] * 10,
iso_sigma=1,
sigma0=0.1, # should generate a small circle of solutions around (0,0)
)
]
optimizer = Optimizer(archive, emitters)
for itr in range(1000):
solutions = optimizer.ask()
# Optimize the 10D negative Sphere function.
objectives = -np.sum(np.square(solutions), axis=1)
# BCs: first 2 coordinates of each 10D solution.
bcs = solutions[:, :2]
optimizer.tell(objectives, bcs)
# plot every 100 iteration
if itr % 100 == 0:
plt.figure()
grid_archive_heatmap(archive)
plt.savefig(f"img/plot{itr}.png", dpi=300)
plt.close()
sigma0
=0)sigma0
=0.1)sigma0
=0)sigma0
=0.1)
Description
Allow user to configure different standard deviations (
sigma
,sigma0
) for initialization and sampling steps ofgaussian_emitter
andiso_line_emitter
.TODO / DONE
sigma0
to optional parameter (defaults tosigma
).sigma0
is used to generate new solutions when the archive is empty, and added parametersigma
, which used to sample solutions from a non-empty archive.sigma0
toIso_Line_Emitter
.iso_line_emitter_test::test_properties_are_correct
to test for sigma0.factory_test
to reflect constructor changeiso_line_emitter_test::test_sigma0_is_correct
andgaussian_emitter_test::test_sigma0_is_correct
Status
yapf
pytest
pylint
HISTORY.md
.