Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
encoder=encoder,
decoder=decoder,
collater=collater)
# Set the active app to be cannonsim (this is redundant when only one app
# has been added)
my_campaign.set_app("cannonsim")
# Make a random sampler
vary = {
"angle": cp.Uniform(0.0, 1.0),
"height": cp.DiscreteUniform(0, 100),
"velocity": cp.Normal(10.0, 1.0),
"mass": cp.Uniform(5.0, 1.0)
}
sampler1 = uq.sampling.RandomSampler(vary=vary)
print("Serialized sampler:", sampler1.serialize())
# Set the campaign to use this sampler
my_campaign.set_sampler(sampler1)
# Draw 5 samples
my_campaign.draw_samples(num_samples=5)
# Print the list of runs now in the campaign db
print("List of runs added:")
pprint(my_campaign.list_runs())
print("---")
# User defined function
def encode_and_execute_cannonsim(run_id, run_data):
collater = uq.collate.AggregateSamples(average=False)
actions = uq.actions.ExecuteLocal("/home/hpc/pn69ju/di73kuj2/cannonsim/bin/cannonsim in.cannon output.csv")
campaign.add_app(name='cannonsim',
params=params,
encoder=encoder,
decoder=decoder,
collater=collater)
stats = uq.analysis.BasicStats(qoi_cols=['Dist', 'lastvx', 'lastvy'])
# Make a random sampler
vary = {
"angle": cp.Uniform(0.0, 1.0),
"height": cp.Uniform(2.0, 10.0),
"velocity": cp.Normal(10.0, 1.0),
"mass": cp.Uniform(5.0, 1.0)
}
sampler = uq.sampling.RandomSampler(vary=vary)
campaign.set_sampler(sampler)
campaign.draw_samples(num_samples=56, replicas=1)
cluster = SLURMCluster(job_extra=['--cluster=mpp2'], queue='mpp2_batch', cores=56, processes=56, memory='64 GB')
print(cluster.job_script())
cluster.scale(4)
client = Client(cluster)
campaign.populate_runs_dir()
campaign.apply_for_each_run_dir(actions, client)
campaign.collate()
campaign.apply_analysis(stats)
print(campaign.get_last_analysis())
# has been added)
my_campaign.set_app("cannonsim")
# Create a collation element for this campaign
collater = uq.collate.AggregateSamples(average=False)
my_campaign.set_collater(collater)
print("Serialized collation:", collater.serialize())
# Make a random sampler
vary = {
"angle": cp.Uniform(0.0, 1.0),
"height": cp.Uniform(2.0, 10.0),
"velocity": cp.Normal(10.0, 1.0),
"mass": cp.Uniform(5.0, 1.0)
}
sampler1 = uq.sampling.RandomSampler(vary=vary)
print("Serialized sampler:", sampler1.serialize())
# Set the campaign to use this sampler
my_campaign.set_sampler(sampler1)
# Draw 5 samples
my_campaign.draw_samples(num_samples=5)
# Print the list of runs now in the campaign db
print("List of runs added:")
pprint(my_campaign.list_runs())
print("---")
# Encode all runs into a local directory
pprint(
def test_lhc():
vary = {'a': cp.Uniform(-5, 3), 'b': cp.Uniform(2, 10)}
sampler = uq.sampling.quasirandom.LHCSampler(vary, max_num=10)
for sample in sampler:
assert(sample['a'] >= -5.0)
assert(sample['a'] <= 3.0)
assert(sample['b'] >= 2.0)
assert(sample['b'] <= 10.0)
assert(sampler.n_samples() == 10)
header=0)
collater = uq.collate.AggregateSamples(average=False)
# Add the SC app (automatically set as current app)
my_campaign.add_app(name="sc",
params=params,
encoder=encoder,
decoder=decoder,
collater=collater)
# Create the sampler
vary = {}
for i in range(d):
vary["x%d" % (i + 1)] = cp.Uniform(0, 1)
my_sampler = uq.sampling.SCSampler(vary=vary, polynomial_order=1,
quadrature_rule="C",
sparse=True, growth=True,
midpoint_level1=True,
dimension_adaptive=True)
# Associate the sampler with the campaign
my_campaign.set_sampler(my_sampler)
# Will draw all (of the finite set of samples)
my_campaign.draw_samples()
my_campaign.populate_runs_dir()
# Run the samples using EasyVVUQ on the localhost
my_campaign.apply_for_each_run_dir(uq.actions.ExecuteLocal(
"tests/sc/poly_model_anisotropic.py poly_in.json"))
collater = uq.collate.AggregateSamples(average=False)
# Add the app (automatically set as current app)
my_campaign.add_app(name="cooling",
params=params,
encoder=encoder,
decoder=decoder,
collater=collater)
# Create the sampler
vary = {
"kappa": cp.Uniform(0.025, 0.075),
"t_env": cp.Uniform(15, 25)
}
my_sampler = uq.sampling.quasirandom.LHCSampler(vary)
# Associate the sampler with the campaign
my_campaign.set_sampler(my_sampler)
# Will draw all (of the finite set of samples)
my_campaign.draw_samples(1)
my_campaign.populate_runs_dir()
cwd = os.getcwd()
cmd = f"{cwd}/cooling_model.py cooling_in.json"
my_campaign.apply_for_each_run_dir(uq.actions.ExecuteLocal(cmd, interpret='python3'))
my_campaign.collate()
df = my_campaign.get_collation_result()