gpcam 4.8.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. gpcam-4.8.3/.claude-plugin/marketplace.json +19 -0
  2. gpcam-4.8.3/.claude-plugin/plugin.json +13 -0
  3. gpcam-4.8.3/.gitattributes +1 -0
  4. gpcam-4.8.3/.gitignore +155 -0
  5. gpcam-4.8.3/.readthedocs.yml +34 -0
  6. gpcam-4.8.3/AUTHORS.md +19 -0
  7. gpcam-4.8.3/CITATION.cff +47 -0
  8. gpcam-4.8.3/CLAUDE.md +113 -0
  9. gpcam-4.8.3/CONTRIBUTING.rst +25 -0
  10. gpcam-4.8.3/COPYING +674 -0
  11. gpcam-4.8.3/HISTORY.rst +34 -0
  12. gpcam-4.8.3/LEGAL.md +19 -0
  13. gpcam-4.8.3/LICENSE +31 -0
  14. gpcam-4.8.3/MANIFEST.in +13 -0
  15. gpcam-4.8.3/PKG-INFO +183 -0
  16. gpcam-4.8.3/README.md +102 -0
  17. gpcam-4.8.3/codecov.yml +19 -0
  18. gpcam-4.8.3/gpcam/__init__.py +19 -0
  19. gpcam-4.8.3/gpcam/_version.py +24 -0
  20. gpcam-4.8.3/gpcam/autonomous_experimenter.py +382 -0
  21. gpcam-4.8.3/gpcam/deep_kernel_network.py +1 -0
  22. gpcam-4.8.3/gpcam/gp_mcmc.py +1 -0
  23. gpcam-4.8.3/gpcam/gp_optimizer.py +821 -0
  24. gpcam-4.8.3/gpcam/gp_optimizer_base.py +707 -0
  25. gpcam-4.8.3/gpcam/kernels.py +1 -0
  26. gpcam-4.8.3/gpcam/surrogate_model.py +366 -0
  27. gpcam-4.8.3/obsolete/autonomous_experimenter_advanced.ipynb +95368 -0
  28. gpcam-4.8.3/obsolete/autonomous_experimenter_basic.ipynb +440 -0
  29. gpcam-4.8.3/obsolete/data.py +276 -0
  30. gpcam-4.8.3/obsolete/gp_optimizerBCK.py +1982 -0
  31. gpcam-4.8.3/obsolete/instrument_function.py +100 -0
  32. gpcam-4.8.3/obsolete/run_every_iteration.py +38 -0
  33. gpcam-4.8.3/pyproject.toml +95 -0
  34. gpcam-4.8.3/setup.cfg +19 -0
  35. gpcam-4.8.3/skills/acquisition-functions/SKILL.md +210 -0
  36. gpcam-4.8.3/skills/cost-functions/SKILL.md +200 -0
  37. gpcam-4.8.3/skills/experiment-designer/SKILL.md +287 -0
  38. gpcam-4.8.3/skills/gp2scale-advanced/SKILL.md +133 -0
  39. gpcam-4.8.3/skills/kernel-designer/SKILL.md +265 -0
  40. gpcam-4.8.3/skills/multi-task-advanced/SKILL.md +129 -0
  41. gpcam-4.8.3/skills/noise-functions/SKILL.md +150 -0
  42. gpcam-4.8.3/skills/prior-mean-functions/SKILL.md +153 -0
  43. gpcam-4.8.3/skills/transformed-optimizers-advanced/SKILL.md +120 -0
  44. gpcam-4.8.3/tox.ini +18 -0
@@ -0,0 +1,19 @@
1
+ {
2
+ "name": "gpcam",
3
+ "owner": {
4
+ "name": "CAMERA — Lawrence Berkeley National Laboratory",
5
+ "email": "MarcusNoack@lbl.gov",
6
+ "url": "https://gpcam.lbl.gov"
7
+ },
8
+ "description": "gpCAM Claude Code skills for Gaussian process modeling, Bayesian optimization, and autonomous experiment design.",
9
+ "plugins": [
10
+ {
11
+ "name": "gpcam",
12
+ "source": "./",
13
+ "description": "Skills that guide an AI assistant through designing autonomous experiments with gpCAM — kernels, acquisition, prior mean, noise, cost, gp2Scale, and multi-task GPs.",
14
+ "homepage": "https://gpcam.lbl.gov",
15
+ "category": "scientific-computing",
16
+ "keywords": ["gaussian-process", "bayesian-optimization", "autonomous-experiments", "gpcam", "scientific-computing"]
17
+ }
18
+ ]
19
+ }
@@ -0,0 +1,13 @@
1
+ {
2
+ "name": "gpcam",
3
+ "description": "Skills that guide an AI assistant through designing autonomous experiments with gpCAM — custom kernels, acquisition functions, prior means, noise, cost, gp2Scale, and multi-task GPs.",
4
+ "author": {
5
+ "name": "CAMERA — Lawrence Berkeley National Laboratory",
6
+ "email": "MarcusNoack@lbl.gov",
7
+ "url": "https://gpcam.lbl.gov"
8
+ },
9
+ "homepage": "https://gpcam.readthedocs.io",
10
+ "repository": "https://github.com/lbl-camera/gpCAM",
11
+ "license": "GPL-3.0",
12
+ "keywords": ["gaussian-process", "bayesian-optimization", "autonomous-experiments", "gpcam"]
13
+ }
@@ -0,0 +1 @@
1
+ gpcam/_version.py export-subst
gpcam-4.8.3/.gitignore ADDED
@@ -0,0 +1,155 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ share/python-wheels/
24
+ *.egg-info/
25
+ .installed.cfg
26
+ *.egg
27
+ MANIFEST
28
+ *.un~
29
+ # PyInstaller
30
+ # Usually these files are written by a python script from a template
31
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
32
+ *.manifest
33
+ *.spec
34
+
35
+ # Installer logs
36
+ pip-log.txt
37
+ pip-delete-this-directory.txt
38
+
39
+ # Unit test / coverage reports
40
+ htmlcov/
41
+ .tox/
42
+ .nox/
43
+ .coverage
44
+ .coverage.*
45
+ .cache
46
+ nosetests.xml
47
+ coverage.xml
48
+ *.cover
49
+ *.py,cover
50
+ .hypothesis/
51
+ .pytest_cache/
52
+ cover/
53
+
54
+ # Translations
55
+ *.mo
56
+ *.pot
57
+
58
+ # Django stuff:
59
+ *.log
60
+ local_settings.py
61
+ db.sqlite3
62
+ db.sqlite3-journal
63
+
64
+ # Flask stuff:
65
+ instance/
66
+ .webassets-cache
67
+
68
+ # Scrapy stuff:
69
+ .scrapy
70
+
71
+ # Sphinx documentation
72
+ docs/_build/
73
+ # Notebooks synced from examples/ at build time (see docs/source/conf.py).
74
+ # Only the synced notebooks are ignored — the examples/index.md landing page
75
+ # is tracked so the Examples section exists on fresh CI / ReadTheDocs checkouts.
76
+ docs/source/examples/*.ipynb
77
+
78
+ # PyBuilder
79
+ .pybuilder/
80
+ target/
81
+
82
+ # Jupyter Notebook
83
+ .ipynb_checkpoints
84
+
85
+ # IPython
86
+ profile_default/
87
+ ipython_config.py
88
+
89
+ # pyenv
90
+ # For a library or package, you might want to ignore these files since the code is
91
+ # intended to run in multiple environments; otherwise, check them in:
92
+ # .python-version
93
+
94
+ # pipenv
95
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
96
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
97
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
98
+ # install all needed dependencies.
99
+ #Pipfile.lock
100
+
101
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow
102
+ __pypackages__/
103
+
104
+ # Celery stuff
105
+ celerybeat-schedule
106
+ celerybeat.pid
107
+
108
+ # SageMath parsed files
109
+ *.sage.py
110
+
111
+ # Environments
112
+ .env
113
+ .venv
114
+ env/
115
+ venv/
116
+ ENV/
117
+ env.bak/
118
+ venv.bak/
119
+
120
+ # Spyder project settings
121
+ .spyderproject
122
+ .spyproject
123
+
124
+ # Rope project settings
125
+ .ropeproject
126
+
127
+ # mkdocs documentation
128
+ /site
129
+
130
+ # mypy
131
+ .mypy_cache/
132
+ .dmypy.json
133
+ dmypy.json
134
+
135
+ # Pyre type checker
136
+ .pyre/
137
+
138
+ # pytype static type analyzer
139
+ .pytype/
140
+
141
+ # Cython debug symbols
142
+ cython_debug/
143
+
144
+ # sphinx
145
+ docs/build/
146
+
147
+ # PyCharm
148
+ .idea/
149
+
150
+
151
+ # dask locks
152
+ *.lock
153
+
154
+ # ignore hatch versioning
155
+ gpcam/_version.py
@@ -0,0 +1,34 @@
1
+ # .readthedocs.yaml
2
+ # Read the Docs configuration file
3
+ # See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
4
+
5
+ # Required
6
+ version: 2
7
+
8
+ # Set the version of Python and other tools you might need
9
+ build:
10
+ os: ubuntu-22.04
11
+ tools:
12
+ python: "3.11"
13
+ jobs:
14
+ pre_build:
15
+ # Mirror authoritative notebooks from examples/ into docs/source/examples/
16
+ # so Sphinx finds them. `docs/source/examples/*.ipynb` is gitignored.
17
+ # The same copy also runs from docs/source/conf.py for local builds.
18
+ - mkdir -p docs/source/examples
19
+ - cp -fv examples/*.ipynb docs/source/examples/
20
+ - ls -la docs/source/examples/
21
+
22
+ # Build documentation in the docs/ directory with Sphinx
23
+ sphinx:
24
+ configuration: docs/source/conf.py
25
+
26
+ formats: all
27
+
28
+ # Optionally declare the Python requirements required to build your docs
29
+ python:
30
+ install:
31
+ - method: pip
32
+ path: .
33
+ extra_requirements:
34
+ - docs
gpcam-4.8.3/AUTHORS.md ADDED
@@ -0,0 +1,19 @@
1
+ # Credits
2
+
3
+ ## Development Lead
4
+
5
+ * Marcus Michael Noack <MarcusNoack@lbl.gov>
6
+
7
+ # Contributors
8
+
9
+ * James Sethian, LBNL
10
+ * Ronald Pandolfi, LBNL
11
+ * Ian Humphrey, LBNL
12
+ * Masafumi Fukuto, BNL
13
+ * Kevin Yager, BNL
14
+ * David Perryman, LBNL
15
+ * Thomas Caswell, BNL
16
+ * Pablo Enfedaque, LBNL
17
+ * Harinarayan Krishnan, LBNL
18
+ * Petrus Zwart
19
+ * Suchismita Sarker
@@ -0,0 +1,47 @@
1
+ cff-version: 1.2.0
2
+ message: "If you use this software, please cite it as below."
3
+ authors:
4
+ - family-names: "Noack"
5
+ given-names: "Marcus"
6
+ orcid: "https://orcid.org/0000-0002-7288-4787"
7
+ - family-names: "Sethian"
8
+ given-names: "James"
9
+ - family-names: "Yager"
10
+ given-names: "Kevin"
11
+ - family-names: "Fukuto"
12
+ given-names: "Masafumi"
13
+ - family-names: "Zwart"
14
+ given-names: "Petrus"
15
+ - family-names: "Ushizima"
16
+ given-names: "Daniela"
17
+ - family-names: "Krishnan"
18
+ given-names: "Harinarayan"
19
+ - family-names: "Lee"
20
+ given-names: "Steven"
21
+ - family-names: "Pandolfi"
22
+ given-names: "Ronald"
23
+ - family-names: "Humphrey"
24
+ given-names: "Ian"
25
+ - family-names: "Perryman"
26
+ given-names: "David"
27
+ - family-names: "Enfedaque"
28
+ given-names: "Pablo"
29
+ - family-names: "Hexemer"
30
+ given-names: "Alexander"
31
+ - family-names: "Sarker"
32
+ given-names: "Suchismita"
33
+ - family-names: "Weber"
34
+ given-names: "Tobias"
35
+ - family-names: "Mehta"
36
+ given-names: "Apurva"
37
+ - family-names: "Li"
38
+ given-names: "Ruipeng"
39
+ - family-names: "Doerk"
40
+ given-names: "Gregory"
41
+ - family-names: "Boehm"
42
+ given-names: "Martin"
43
+ title: "gpCAM"
44
+ version: 7.3.4
45
+ doi: 10.5281/zenodo.5975553
46
+ date-released: 2022-2-4
47
+ url: "https://github.com/lbl-camera/gpCAM"
gpcam-4.8.3/CLAUDE.md ADDED
@@ -0,0 +1,113 @@
1
+ # CLAUDE.md
2
+
3
+ This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4
+
5
+ This file serves two audiences:
6
+ 1. **Scientists designing experiments** with gpCAM — routed through the skills below.
7
+ 2. **Developers working on the gpCAM package itself** — see Development & Architecture.
8
+
9
+ ---
10
+
11
+ ## For scientists: designing autonomous experiments
12
+
13
+ You are helping scientists design autonomous experiments using gpCAM, a Gaussian Process-based Bayesian optimization toolkit. Read the appropriate skill file before generating code:
14
+
15
+ - **Designing an experiment**: `skills/experiment-designer/SKILL.md`
16
+ - **Custom kernels**: `skills/kernel-designer/SKILL.md`
17
+ - **Acquisition functions**: `skills/acquisition-functions/SKILL.md`
18
+ - **Prior mean functions**: `skills/prior-mean-functions/SKILL.md`
19
+ - **Noise models**: `skills/noise-functions/SKILL.md`
20
+ - **Cost functions (travel time)**: `skills/cost-functions/SKILL.md`
21
+ - **Large-scale (>10k points)**: `skills/gp2scale-advanced/SKILL.md`
22
+ - **Multi-task/multi-output**: `skills/multi-task-advanced/SKILL.md`
23
+ - **Constrained observations (y>0 or y∈[0,1])**: `skills/transformed-optimizers-advanced/SKILL.md`
24
+
25
+ These skills also ship as a Claude Code plugin marketplace (see README.md), so they are available outside this repo once installed.
26
+
27
+ ### Key principles for generated experiment scripts
28
+
29
+ 1. **Generate complete, runnable scripts** — not fragments
30
+ 2. **Target audience is scientists**, not GP experts — explain choices in plain language
31
+ 3. **Always document the hyperparameter layout** — which index maps to what
32
+ 4. **Hyperparameter bounds must match** the total hyperparameter count across kernel + mean + noise
33
+ 5. **Default kernel is usually fine** — only suggest custom when there's a clear reason
34
+ 6. **Use vectorized numpy** — no Python loops over data points
35
+ 7. **Return dict keys**: `posterior_mean()` returns `"m(x)"`, `posterior_covariance()` returns `"v(x)"` and `"S"`. NOT `"f(x)"`.
36
+ 8. **`get_data()` keys use spaces**: `"x data"`, `"y data"`, `"hyperparameters"`, `"measurement variances"`. NOT underscores.
37
+
38
+ ---
39
+
40
+ ## Development & Architecture
41
+
42
+ ### Commands
43
+
44
+ Running from source requires an install (the package reads a VCS-generated `gpcam/_version.py`):
45
+
46
+ ```bash
47
+ pip install -e .[tests] # editable install with test deps (pytest, torch, imate, ...)
48
+ pytest tests # run the full test suite
49
+ pytest tests --cov=./ --cov-report=xml # exactly what CI runs
50
+ pytest tests/test_gpCAM.py::test_basic_1task # run a single test
51
+ hatch build # build sdist + wheel (version comes from git tags via hatch-vcs)
52
+ ```
53
+
54
+ - **Python >= 3.11**; CI matrix is 3.11 and 3.12 (`.github/workflows/gpCAM-CI.yml`).
55
+ - Tests use `distributed.utils_test` fixtures (`client`, `loop`, `cluster_fixture`) and spin up a **local Dask cluster**, so they are slow and start real worker processes. Multiprocessing entrypoint guards (`if __name__ == "__main__":`) matter — see `docs/source/common-bugs.md`.
56
+ - `tox.ini` and the `[bumpversion]` block in `setup.cfg` are **stale** (reference py35–py38 and a removed `setup.py`). Don't trust them; GitHub Actions + hatch-vcs are authoritative. Do not hand-edit `gpcam/_version.py` (auto-generated).
57
+
58
+ ### The big picture
59
+
60
+ **gpCAM is a thin Bayesian-optimization / autonomous-data-acquisition layer on top of the [`fvgp`](https://github.com/lbl-camera/fvgp) package** (pinned `fvgp==4.7.9` in `pyproject.toml`). The actual GP math — kernels, hyperparameter training, posterior evaluation, MCMC, deep kernels — lives in `fvgp`. gpCAM adds the `ask`/`tell`/`train`/`optimize` loop and acquisition-function optimization on top.
61
+
62
+ This means **the most important architectural fact is what is NOT in this repo**:
63
+
64
+ - `gpcam/kernels.py`, `gpcam/gp_mcmc.py`, and `gpcam/deep_kernel_network.py` are **one-line re-exports** of the corresponding `fvgp` modules.
65
+ - Methods like `train()`, `posterior_mean()`, `posterior_covariance()`, `update_gp_data()`, `gp_relative_information_entropy()`, `gp_total_correlation()`, and the default kernel/mean/noise are all **inherited from `fvgp.GP`** — to understand or change them, read the installed `fvgp` source, not this repo.
66
+
67
+ ### Class hierarchy
68
+
69
+ - `GPOptimizerBase(fvgp.GP)` — `gpcam/gp_optimizer_base.py`. Adds `ask()`, `tell()`, `optimize()`, `evaluate_acquisition_function()`, `get_data()`, and pickling. This is where the optimization-loop logic lives.
70
+ - `GPOptimizer(GPOptimizerBase)` — single-task (scalar) GP. `multi_task=False`.
71
+ - `fvGPOptimizer(GPOptimizerBase, fvGP)` — multi-task (vector-valued) GP. `multi_task=True`. A multi-task GP is modeled as a single-task GP over the Cartesian product of input × output space, so the task index becomes an extra input dimension that kernel/mean/noise functions must handle.
72
+
73
+ So a `GPOptimizer` instance *is* an `fvgp.GP` with the optimization methods mixed in.
74
+
75
+ ### ask / tell / train loop
76
+
77
+ The canonical usage (no `AutonomousExperimenter` — see below):
78
+
79
+ ```python
80
+ gp = GPOptimizer(x_data, y_data)
81
+ gp.train() # inherited from fvgp.GP
82
+ for i in range(N):
83
+ new = gp.ask(bounds, acquisition_function="variance")["x"]
84
+ gp.tell(new, measure(new)) # appends + rank-n updates the GP
85
+ if i in train_at: gp.train()
86
+ ```
87
+
88
+ - **Lazy initialization**: if `x_data`/`y_data` are not passed to the constructor, the underlying `fvgp.GP` is not built until the first `tell()`. The `self.gp` boolean tracks this; many properties (`x_data`, `y_data`, `args`, ...) return `None` and most methods assert before init.
89
+ - `optimize(...)` in `gp_optimizer_base.py` is a convenience wrapper that runs the whole tell/ask/train loop for a known `func`.
90
+
91
+ ### Acquisition functions (`gpcam/surrogate_model.py`)
92
+
93
+ `ask()` delegates to `surrogate_model.find_acquisition_function_maxima()`, which **maximizes** the acquisition function over `input_set` using one of three methods:
94
+
95
+ - `"global"` → scipy `differential_evolution` (default; supports vectorized eval)
96
+ - `"local"` → scipy `minimize` (L-BFGS-B with finite-difference gradient)
97
+ - `"hgdl"` → the in-house `hgdl` hybrid optimizer (needs a Dask client; used automatically when `n>1` with a callable acq func)
98
+
99
+ Sign convention to keep straight: acquisition functions are written to be **maximized**, but internally `evaluate_acquisition_function` returns the **negated** value (so the scipy minimizers maximize), and the result is divided by `cost_function`. `ask()` flips the sign back in its return dict. A user-supplied acquisition function `f(x, gp_obj)` must return a 1d array of length `len(x)` and is maximized.
100
+
101
+ Built-in acquisition strings (`"variance"`, `"ucb"`, `"lcb"`, `"expected improvement"`, `"relative information entropy"`, `"total correlation"`, `"target probability"`, etc.) are dispatched in `evaluate_gp_acquisition_function`, with separate single-task vs multi-task (`x_out is not None`) branches. `"target probability"` requires `args={'a': lower, 'b': upper}`.
102
+
103
+ `ask()` returns `{'x': ..., 'f_a(x)': ..., 'opt_obj': ...}`. Non-Euclidean / mixed spaces are supported by passing `input_set` as a **list of candidates** instead of a bounds array.
104
+
105
+ ### Deprecated code
106
+
107
+ `gpcam/autonomous_experimenter.py` — `AutonomousExperimenterGP` and `AutonomousExperimenterFvGP` both **raise on construction**. They are deprecated in favor of using `GPOptimizer`/`fvGPOptimizer` directly. Don't extend or revive them; point users at the optimizer classes (or the Tsuchinoko package).
108
+
109
+ ## Reference materials
110
+
111
+ - [gpCAM documentation](https://gpcam.readthedocs.io) — full API reference and mathematical background (much of it the inherited `fvgp` API)
112
+ - `docs/source/common-bugs.md` — recurring errors and fixes (singular matrix, Dask freeze_support, pickle/allow_pickle)
113
+ - The installed `fvgp` package source — authoritative for kernels, training, and posterior math
@@ -0,0 +1,25 @@
1
+ .. highlight:: shell
2
+
3
+ ============
4
+ Contributing
5
+ ============
6
+
7
+ Contributions are welcome, and they are greatly appreciated! Every little bit
8
+ helps, and credit will always be given.
9
+
10
+ You can contribute in many ways:
11
+
12
+ Types of Contributions
13
+ ----------------------
14
+
15
+ Report Bugs
16
+ ~~~~~~~~~~~
17
+
18
+ Report bugs though the Slack channel.
19
+ Contacte MarcusNoack@lbl.gov for an invite
20
+
21
+ If you are reporting a bug, please include:
22
+
23
+ * Your operating system name and version.
24
+ * Any details about your local setup that might be helpful in troubleshooting.
25
+ * Detailed steps to reproduce the bug.