How to use the easyvvuq.sampling.SCSampler function in easyvvuq

To help you get started, we’ve selected a few easyvvuq examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github UCL-CCS / EasyVVUQ / tests / test_jinja_encoder.py View on Github external
vary = {
        "Nc_0": cp.Uniform(50e6, 100e6),
        # "cf": cp.Uniform(2.4, 2.6),
        # "cn": cp.Uniform(0.5, 0.9),
        # "Rigc": cp.Uniform(0.1, 0.4),
        # "Prandtl": cp.Uniform(0.2, 0.4),
        # "z0": cp.Uniform(1e-4, 2e-4),
        "l_sb": cp.DiscreteUniform(0, 1),
        # "Nh": cp.DiscreteUniform(10, 20),
        # "extent": cp.Uniform(1000, 2000),
        "seed": cp.Uniform(1, 2000),
    }

    output_columns = ['cfrac', 'lwp', 'rwp', 'zb', 'zi', 'prec', 'wq', 'wtheta', 'we', 'walltime']
    my_sampler = uq.sampling.SCSampler(vary=vary, polynomial_order=2,
                                       quadrature_rule="C")
    my_campaign = uq.Campaign(name='dales', work_dir=tmpdir, db_location='sqlite:///')
    encoder = JinjaEncoder(template_fname='tests/jinjaencoder/namoptions.template',
                           target_filename='namoptions.001')
    decoder = uq.decoders.SimpleCSV(
        target_filename='results.csv',
        output_columns=output_columns,
        header=0)
    collater = uq.collate.AggregateSamples(average=False)
    my_campaign.add_app(name="dales",
                        params=params,
                        encoder=encoder,
                        decoder=decoder,
                        collater=collater)
    my_campaign.verify_all_runs = False  # to prevent errors on integer quantities
    my_campaign.set_sampler(my_sampler)
github UCL-CCS / EasyVVUQ / tests / test_hierarchical_sparse_grid_sc.py View on Github external
# 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 = {
        "x1": cp.Uniform(0.0, 1.0),
        "x2": cp.Uniform(0.0, 1.0)}

    # To use 'next_level_sparse_grid' below, we must select a nested
    # sparse grid here
    my_sampler = uq.sampling.SCSampler(vary=vary, polynomial_order=poly_order,
                                       quadrature_rule="C", sparse=True,
                                       growth=True)

    # Associate the sampler with the campaign
    my_campaign.set_sampler(my_sampler)

    print('Number of samples:', my_sampler._number_of_samples)

    # Will draw all (of the finite set of samples)
    my_campaign.draw_samples()
    my_campaign.populate_runs_dir()

    # Use this instead to run the samples using EasyVVUQ on the localhost
    my_campaign.apply_for_each_run_dir(uq.actions.ExecuteLocal(
        "tests/sc/poly_model.py poly_in.json"))
github UCL-CCS / EasyVVUQ / tests / test_anisotropic_order.py View on Github external
# 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 = {
        "Pe": cp.Uniform(100.0, 200.0),
        "f": cp.Uniform(0.95, 1.05)
    }

    # different orders for the 2 parameters
    my_sampler = uq.sampling.SCSampler(vary=vary, polynomial_order=[2, 5],
                                       quadrature_rule="G")

    # 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()

    #   Use this instead to run the samples using EasyVVUQ on the localhost
    my_campaign.apply_for_each_run_dir(uq.actions.ExecuteLocal(
        "tests/sc/sc_model.py ade_in.json"))

    my_campaign.collate()

    # Post-processing analysis
github UCL-CCS / EasyVVUQ / tests / test_vector.py View on Github external
},
    }

    vary = {
        "mu": cp.Uniform(1.0, 100.0),
    }

    encoder = uq.encoders.GenericEncoder(template_fname='tests/gauss/gauss.template',
                                         target_filename='gauss_in.json')
   # decoder = JSONDecoder(target_filename='output.csv.json', output_columns=['numbers'])
    decoder = uq.decoders.SimpleCSV(target_filename="output.csv",
                                    output_columns=["numbers"],
                                    header=0)
    collater = uq.collate.AggregateSamples(average=False)
    actions = uq.actions.ExecuteLocal("tests/gauss/gauss_json.py gauss_in.json")
    sampler = uq.sampling.SCSampler(vary=vary, polynomial_order=4)
    my_campaign = uq.Campaign(name='gauss_vector', work_dir=tmpdir)
    my_campaign.add_app(name="gauss_vector",
                        params=params,
                        encoder=encoder,
                        decoder=decoder,
                        collater=collater)
    my_campaign.set_sampler(sampler)
    my_campaign.draw_samples()
    my_campaign.populate_runs_dir()
    my_campaign.apply_for_each_run_dir(actions)
    my_campaign.collate()

    data = my_campaign.get_collation_result()
    print("===== DATA:\n ", data)
    analysis = uq.analysis.SCAnalysis(sampler=sampler, qoi_cols=["numbers"])
    my_campaign.apply_analysis(analysis)
github UCL-CCS / EasyVVUQ / tests / test_sc.py View on Github external
# Add the SC app (automatically set as current app)
    my_campaign.add_app(name="sc",
                        params=params,
                        encoder=encoder,
                        decoder=decoder,
                        collation=collation
                        )

    # Create the sampler
    vary = {
        "Pe": cp.Uniform(100.0, 200.0),
        "f": cp.Normal(1.0, 0.1)
    }

    my_sampler = uq.sampling.SCSampler(vary=vary, polynomial_order=4)

    # 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()
    my_campaign.apply_for_each_run_dir(uq.actions.ExecuteLocal("tests/sc/sc_model.py sc_in.json"))

    my_campaign.collate()

    # Post-processing analysis
    sc_analysis = uq.analysis.SCAnalysis(sampler=my_sampler, qoi_cols=output_columns)

    my_campaign.apply_analysis(sc_analysis)