Code Monkey home page Code Monkey logo

bet's Introduction

BET

Build Status DOI codecov Binder

BET is a Python package for data-consistent stochastic forward and inverse problems. The package is very flexible and is applicable to a wide variety of problems.

BET is an initialism of Butler, Estep and Tavener, the primary authors of a series of papers that introduced the mathematical framework for measure-based data-consistent stochastic inversion, for which BET included a computational implementation. However, since its initial inception it has grown to include a broad range of data-consistent methods. It has been applied to a wide variety of application problems, many of which can be found here.

Installation

The current development branch of BET can be installed from GitHub, using pip:

pip install git+https://github.com/UT-CHG/BET

Another option is to clone the repository and install BET using python setup.py install

Dependencies

BET is tested on Python 3.6, 3.7, and 3.8 (but should work on most recent Python 3 versions) and depends on NumPy, SciPy, matplotlib, pyDOE, pytest, and mpi4py (optional) (see requirements.txt for version information). For some optional features LUQ is also required. mpi4py is required to take advantage of parallel features and requires an mpi implementation. It can be installed by:

pip install mpi4py

License

GNU Lesser General Public License (LGPL)

Citing BET

Please include the citation:

Lindley Graham, Steven Mattis, Michael Pilosov, Scott Walsh, Troy Butler, Michael Pilosov, โ€ฆ Damon McDougall. (2020, July 9). UT-CHG/BET: BET v3.0.0 (Version v3.0.0). Zenodo. http://doi.org/10.5281/zenodo.3936258

or in BibTEX:

@software{BET,
          author = {Lindley Graham and
                    Steven Mattis and
                    Michael Pilosov and
                    Scott Walsh and
                    Troy Butler and
                    Wenjuan Zhang and
                    Damon McDougall},
          title = {UT-CHG/BET: BET v3.0.0},
          month = jul,
          year = 2020,
          publisher = {Zenodo},
          version = {v3.0.0},
          doi = {10.5281/zenodo.3936258},
          url = {https://doi.org/10.5281/zenodo.3936258}
          }

Documentation

This code has been documented with sphinx. the documentation is available online at http://ut-chg.github.io/BET. To build documentation run make html in the doc/ folder.

To build/update the documentation use the following commands:

sphinx-apidoc -f -o doc bet
cd doc/
make html
make html

This creates the relevant documentation at bet/gh-pages/html. To change the build location of the documentation you will need to update doc/makefile.

You will need to run sphinx-apidoc and reinstall bet anytime a new module or method in the source code has been added. If only the *.rst files have changed then you can simply run make html twice in the doc folder. Building the docs requires Sphinx and the Read the Docs Sphinx theme, which can be installed with pip by:

pip install Sphinx sphinx_rtd_theme

Examples

Examples scripts are contained in here.

You can also try out BET in your browser using Binder.

Testing

To run the tests in the root directory with pytest in serial call:

pytest ./test/

Some features of BET (primarily those associated with the measure-based approach) have the ability to work in parallel. To run tests in parallel call:

mpirun -np NPROC pytest ./test/

Make sure to have a working MPI environment (we recommend mpich) if you want to use parallel features.

(Note: you may need to set ~/.config/matplotlib/matplotlibrc to include backend:agg if there is no DISPLAY port in your environment).

Contributors

See the GitHub contributors page.

Contact

BET is in active development. Hence, some features are still being added and you may find bugs we have overlooked. If you find something please report these problems to us through GitHub so that we can fix them. Thanks!

Please note that we are using continuous integration and issues for bug tracking.

bet's People

Contributors

dmcdougall avatar eecsu avatar lcgraham avatar mathematicalmichael avatar mpilosov avatar scottw13 avatar smattis avatar user-zwj avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

bet's Issues

Verify Calculate P

Add a test to verify that prob_emulated(samples, data, rho_D_M, d_distr_samples) = prob(samples, data, rho_D_M, d_distr_samples)

Add indicatorFunctions to master

Add indicatorFunctions.py to master from dev branch. Create a class/set of methods that returns the indicator functions and their simple function approximations together since most of these methods take the same arguments. We can create a similar set up in sampling on the dev branch for the gradient based adaptive samplers.

docstrings and comments lacking in plotDomains

The docstrings are not very descriptive in plotDomains, and there are almost no comments. Variable names are not descriptive enough for not having commments. Also, default input arguments should be added to many of the functions.

Tangled Dimensions

Currently the dimensions for samples in the parameter space (\Lambda) and samples in the data space (D) are:

param, lambda -- (ndim, num_samples)
data -- (num_samples, mdim)

We desire the dimensions of samples from both spaces to match (num_samples, dim). Possible modules this needs to be fixed in are:

adaptiveSampling
basicSampling
simpleFunP
calculateP
plot_D_2D

Update install instructions

Add nose as a dependency. Make sure the install documentation via Sphinx is up to date. Add note on how to run tests after installation.

clean up vis package

make sure names for plotP and plotDomains match up with respect to function calls, same syntax

Testing: loadmat

loadmat tests are failing in parallel with bet.sampling.adaptiveSampling and bet.sampling.basicSampling

top_percentile=1.0 returns all samples, postTools.sample_highest_prob

In postTools.sample_highest_prob, if you set top_percentile=1.0, it returns the correct volume of the region in Lambda, but it return num_samples= all samples. It looks like this is because in line 63 postTools

num_samples = np.sum(P_sum <= top_percentile)

So Psum is always <= 1.0, and it returns all samples. Maybe <= top_percentile - epsilon, or an

if top_percentile==1.0
num_samples = numbers of nonzeros in P_samples

Bring dev up to date with master

Merge master into dev without clobbering developmental portions of dev that differ from master. This is to keep dev in line with the current state of master since there were bugs/issues that were resolved with the addition of the sensitivity package to master.

heurstics

Properly reclass the heuristics in adaptiveSampling so that they all inherit from the heuristic class.

Possible bad parallelism in adaptiveSampling

There is some troubling parallelism in adaptiveSampling.sampler.generalized_chains regarding all_step_ratios. Especially the lines :
MYall_step_ratios = np.copy(all_step_ratios)
all_step_ratios = np.empty((self.num_chains, self.chain_length), dtype=np.float64)
comm.Allgather([MYall_step_ratios, MPI.DOUBLE], [all_step_ratios, MPI.DOUBLE])

In this process, all_step_ratios is being broadcast into a different shape. We need to be careful about the ordering here, I think. The order of entries in all_step_ratios is different after this than doing numpy.reshape. Tests were failing without mpi4py because of this.

I put a temporary fix in the tests_and_parallel branch. I would like @lcgraham to look over this and make sure that there are no errors, and that my fix for the case of no mpi4py is valid. It does make all of the test pass. If you do make changes, please do it in the tests_and_parallel branch, to avoid conflicts when that is merged with master, which should be done very soon.

Add sensitivity package

Finish creating sensitivity package. Create master-sensitivity branch from dev-sensitivity. Remove developmental code from master-sensitivity. Merge master-sensitivity into master. Update documentation. Release as version 0.3 or version 1.0 if all examples are finished.

Copyright update

Change copyright at the tops of files to "The BET Development Team" instead of "Lindley Graham and Steven Mattis".

Backward compatibility broken in postTools

Be careful with old code using postTools. Recent additions by @lcgraham break backward compatibility. I didn't realize this when I merged it in because the tests were rewritten for the new syntax. I am going to make this more user friendly, but I guess I'll follow the new form.

PlotDomains

Update plotDomains so that the dimensions of Q_ref (and similar variables) are automatically fixed if necessary. Automatically create a figs folder if it doesn't already exist and if a custom file name is not specified.

create empty templates to run bet

these templates should be for parallel and serial versions. make sure PolyADCIRC examples and other examples conform to these templates

emulate_iid_lebesgue re-defines num_l_emulate incorrectly

In line 35 of calculateP in the emulate_iid_lebesgue method:

num_l_emulate = int(num_l_emulate/size)+1

Apparently size comes from bet.Comm and is the number of processors used in the computation, so when this operation is called with only a single processor it creates 1 more emulated sample than called for by num_l_emulate parameter.

I came across this while creating the verification example to re-create a uniform distribution on \Lambda and worked around it by passing num_l_emulate-1 into this method. I think the fix is to compute

remainder = num_l_emulate % size

and then for the first "remainder" number of processors add 1 to num_l_emulate. I am not quite sure how to code this though.

Links in example .rst files

Change the links in the example .rst files to point to the github repo for the example rather than download the file.

marginal plots

Plotting 2d and then 1d (or reversing the order) marginals will combine the plots in the last saved files.

Clean up calculateP

eliminate unnecessary returns and collecting of lambda_emulate for prob at least.
make sure to not return inputs as outputs.

Big issues with changes parallelism

Allreduce calculations for integers are all wrong. They are begin treated as numpy arrays of integers which is not giving an error but is doing something completely wrong. Should be switched to allreduce. Many parts of simpleFunP and calculateP are affected.

Testing: plotP

Tests for bet.postProcess.plotP fail when run in parallel.

Testing: adaptiveSampling

Need to make sure *.mat files from parallel and serial runs are getting properly removed in the tearDown method

Tests_and_parallel

@smattis is the tests_and_parallel branch ready for merging? If so want me to go ahead and merge it to master?

Forward Problem

Add forward problem capabilities and remove the references to a specific \D or \Lambda space and just say metric space.

Invaild Divide

BET/bet/calculateP/calculateP.py:262: RuntimeWarning: invalid value encountered in divide
P[Itemp] = rho_D_M[i]*lam_vol[Itemp]/np.sum(lam_vol[Itemp])

Verify Calculate P

The solutions, P, from prob,prob_samples_mc, prob_samples_qhull need to be compared to the solutions from the corresponding MATLAB codes Q_singleV, Q_singleVmc, and Q_singleVex (make sure the bin_sizes are equivalent). The bin_size in the MATLAB code is 1/bin_size in the Python code.

Dimensions flipped in adaptiveSampling

In line 348 the data arrays are concatenated along the 0-axis, but it should be done along the 1-axis. This may mess up the fromMap example, so I didn't want to change it yet.

Robustize center_pts_per_edge

Check methods that use center_pts_per_edge. Update these methods so that the argument can be either an int or a list(). If the method receives a list check it to make sure the length matches the dimension of data. If the method receives a int, expand it into an appropriately sized array.

Write loadBalance, lbPADCIRC, etc.

Write model running rig that takes care of load balancing within a single TACC(or other HPC) job allocation. We should use mpi4py and maybe look into Pylauncher by TACC. This should take care of running both serial and parallel jobs in parallel. It might make sense to use GNU parallel (but it probably doesn't make sense). Pushkar is interested in this so we should include him.

Port features from PolySim (adaptive_sampling)

Port stable features from polysim.run_framework.adaptive_sampling into bet.sampling.adaptiveSampling. Eventually, the adaptive sampling module in PolySim should be completely removed and examples/data in hershel_bin/nonsubdomain/adaptive and the corresponding scripts in lonestar_landuse_bin should reflect this change.

Renaming

Change all references to "true" or "truth" to "reference" i.e. "q_true" changes to "q_ref" and "heuristic" to "kernel."

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.