MXMC
General
MXMCPy is an open source package that implements many existing multi-model Monte Carlo methods (MLMC, MFMC, ACV) for estimating statistics from expensive, high-fidelity models by leveraging faster, low-fidelity models for speedup.
Getting Started
Installation
MXMCPy can be easily installed using pip:
pip install mxmcpy
or conda:
conda install mxmcpy
Alternatively, the MXMCPy repository can be cloned:
git clone https://github.com/nasa/mxmcpy.git
and the dependencies can be installed manually as follows.
Dependencies
MXMCPy is intended for use with Python 3.x. MXMCPy requires installation of a few dependencies which are relatively common for optimization/numerical methods with Python:
- numpy
- scipy
- pandas
- matplotlib
- h5py
- pytorch
- pytest, pytest-mock (if the testing suite is to be run)
A requirements.txt file is included for easy installation of dependencies with
pip or conda.
Installation with pip:
pip install -r requirements.txt
Installation with conda:
conda install --yes --file requirements.txt
Documentation
Sphynx is used for automatically generating API documentation for MXMCPy. The
most recent build of the documentation can be found in the repository at:
doc/index.html
Running Tests
An extensive unit test suite is included with MXMCPy to help ensure proper installation. The tests can be run using pytest on the tests directory, e.g., by running:
python -m pytest tests
from the root directory of the repository.
Example Usage
The following code snippet shows the determination of an optimal sample allocation for three models with assumed costs and covariance matrix using the MFMC algorithm:
import numpy as np
from mxmc import Optimizer
model_costs = np.array([1.0, 0.05, 0.001])
covariance_matrix = np.array([[11.531, 11.523, 12.304],
[11.523, 11.518, 12.350],
[12.304, 12.350, 14.333]])
optimizer = Optimizer(model_costs, covariance_matrix)
opt_result = optimizer.optimize(algorithm="mfmc", target_cost=1000)
print("Optimal variance: ", opt_result.variance)
print("# samples per model: ", opt_result.allocation.get_number_of_samples_per_model())
For more detailed examples using MXMCPy including end-to-end construction of estimators, see the scripts in the examples directory.
Contributing
- Fork it (https://github.com/nasa/mxmcpy/fork)
- Create your feature branch (
git checkout -b feature/fooBar) - Commit your changes (
git commit -am 'Add some fooBar') - Push to the branch (
git push origin feature/fooBar) - Create a new Pull Request
Versioning
Authors
- Geoffrey Bomarito
- James Warner
- Patrick Leser
- William Leser
- Luke Morrill
License
Notices: Copyright 2020 United States Government as represented by the Administrator of the National Aeronautics and Space Administration. No copyright is claimed in the United States under Title 17, U.S. Code. All Other Rights Reserved.
Disclaimers No Warranty: THE SUBJECT SOFTWARE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY OF ANY KIND, EITHER EXPRESSED, IMPLIED, OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, ANY WARRANTY THAT THE SUBJECT SOFTWARE WILL CONFORM TO SPECIFICATIONS, ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR FREEDOM FROM INFRINGEMENT, ANY WARRANTY THAT THE SUBJECT SOFTWARE WILL BE ERROR FREE, OR ANY WARRANTY THAT DOCUMENTATION, IF PROVIDED, WILL CONFORM TO THE SUBJECT SOFTWARE. THIS AGREEMENT DOES NOT, IN ANY MANNER, CONSTITUTE AN ENDORSEMENT BY GOVERNMENT AGENCY OR ANY PRIOR RECIPIENT OF ANY RESULTS, RESULTING DESIGNS, HARDWARE, SOFTWARE PRODUCTS OR ANY OTHER APPLICATIONS RESULTING FROM USE OF THE SUBJECT SOFTWARE. FURTHER, GOVERNMENT AGENCY DISCLAIMS ALL WARRANTIES AND LIABILITIES REGARDING THIRD-PARTY SOFTWARE, IF PRESENT IN THE ORIGINAL SOFTWARE, AND DISTRIBUTES IT "AS IS."
Waiver and Indemnity: RECIPIENT AGREES TO WAIVE ANY AND ALL CLAIMS AGAINST THE UNITED STATES GOVERNMENT, ITS CONTRACTORS AND SUBCONTRACTORS, AS WELL AS ANY PRIOR RECIPIENT. IF RECIPIENT'S USE OF THE SUBJECT SOFTWARE RESULTS IN ANY LIABILITIES, DEMANDS, DAMAGES, EXPENSES OR LOSSES ARISING FROM SUCH USE, INCLUDING ANY DAMAGES FROM PRODUCTS BASED ON, OR RESULTING FROM, RECIPIENT'S USE OF THE SUBJECT SOFTWARE, RECIPIENT SHALL INDEMNIFY AND HOLD HARMLESS THE UNITED STATES GOVERNMENT, ITS CONTRACTORS AND SUBCONTRACTORS, AS WELL AS ANY PRIOR RECIPIENT, TO THE EXTENT PERMITTED BY LAW. RECIPIENT'S SOLE REMEDY FOR ANY SUCH MATTER SHALL BE THE IMMEDIATE, UNILATERAL TERMINATION OF THIS AGREEMENT.
Metadata
Release files for mxmcpy 1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| mxmcpy-1.0.tar.gz | 21.6 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| mxmcpy-1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 73.6 kB
Release files / mxmcpy-1.0.tar.gz
| Download URL | mxmcpy-1.0.tar.gz |
|---|---|
| Size | 21.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
83142e81c38a028d02fd818c00bb2ba100ff3146eca64e4aaa1f22057a49ca3c
|
|
BLAKE2b-256 checksum How to use checksums |
289c61c5967f2c79f2920ba9809e5307ddd39269c634d9fe961f05c01ffb75cc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.3.2 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.6.8
|
Release files / mxmcpy-1.0-py3-none-any.whl
| Download URL | mxmcpy-1.0-py3-none-any.whl |
|---|---|
| Size | 52.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
30853fd4b0738efbd1c395c966bd2d1a003651fbff1234a82ebfec9b7cd81e26
|
|
BLAKE2b-256 checksum How to use checksums |
064b2bf975b045531944f20529d98e749865084e0dac090a281918874022ca0e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.3.2 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.6.8
|
Security for mxmcpy 1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.