Skip to content
Open
Show file tree
Hide file tree
Changes from 210 commits
Commits
Show all changes
463 commits
Select commit Hold shift + click to select a range
c9c4671
presumably fix surmise asktell test?
jlnav Aug 7, 2024
601af44
actually fix surmise test. make sure that when passing around single …
jlnav Aug 7, 2024
d454b5c
similarly exclude gpcam_class test from tests, for now
jlnav Aug 8, 2024
92e22e4
experimenting with batch_size and initial_batch_size gen_specs options
jlnav Aug 8, 2024
d14f4d2
subsequent batch_sizes are either back_size or len(H_in)
jlnav Aug 9, 2024
e27487d
now test in test_sampling_asktell_gen
jlnav Aug 9, 2024
a6feb77
cover asking aposmm for num points
jlnav Aug 9, 2024
12a133b
various coverage adjustments and fixes
jlnav Aug 12, 2024
de1916a
Merge branch 'develop' into experimental/jlnav_plus_shuds_asktell
jlnav Aug 16, 2024
ee2508e
initial commit, creating ask/tell gen unit test, base LibensembleGene…
jlnav Aug 16, 2024
070fc6f
add test, arrays become flattened dicts in np_to_list_dicts
jlnav Aug 16, 2024
a969f50
remove debug statement
jlnav Aug 16, 2024
6eb5fe8
additional attempts to unflatten the input dict...
jlnav Aug 16, 2024
1261274
fix index ordering, cleanup/complete tentatively unit test
jlnav Aug 19, 2024
d960b96
passthrough kwargs to superclasses, try to handle empty lists for sin…
jlnav Aug 19, 2024
3ce0ca2
better handling of multi-dim and single-dim output-array item assignm…
jlnav Aug 19, 2024
09cb4a6
comments
jlnav Aug 19, 2024
601f02c
adjust persistent_gen_wrapper, fix UniformSampleDicts
jlnav Aug 19, 2024
6733fe5
fix ordering of parameters in implemented ask/tell classes and parent…
jlnav Aug 21, 2024
7466100
better detecting of combinable names, by stripping out the numeric su…
jlnav Aug 21, 2024
751de5e
deal with keys that end with integers, but aren't similar to any othe…
jlnav Aug 21, 2024
18e7079
keyword assignment of gen_specs to Surmise
jlnav Aug 22, 2024
a34d589
forgot another keyword surmise assignment
jlnav Aug 22, 2024
5f33724
add unit test for awkward H and checking routine from shuds, add case…
jlnav Aug 26, 2024
41c16b7
add optional dtype argument for list_dicts_to_np to preempt "dtype di…
jlnav Aug 26, 2024
4860428
replace _to_array with list_dicts_to_np with dtype parameter. list_di…
jlnav Aug 26, 2024
ced8992
fix
jlnav Aug 26, 2024
cbfdf0b
Merge branch 'develop' into feature/flatten_asktell_dict_values
jlnav Aug 29, 2024
4261ca8
LibensembleGenerator can provide matching dtype for list_dicts_to_np,…
jlnav Aug 29, 2024
460bbe3
fix
jlnav Aug 29, 2024
7fdd8a6
ahhhh, just gen_specs['out']'s dtype isn't sufficient. persis_in, des…
jlnav Aug 29, 2024
69b0584
removing hardcoded gen_specs.out, removing hardcoded persis_info.nwor…
jlnav Sep 12, 2024
8c01ca9
clarify a comment
jlnav Sep 12, 2024
4541d8a
as discussed, currently gen_specs['out'] must be provided to a gen in…
jlnav Sep 12, 2024
345aea3
Merge pull request #1409 from Libensemble/feature/flatten_asktell_dic…
jlnav Sep 12, 2024
fe7629e
Merge branch 'develop' into experimental/jlnav_plus_shuds_asktell
jlnav Sep 12, 2024
0d7e1a3
specify gen_specs.out dtype to conversion in independent borehole-call
jlnav Sep 12, 2024
c7d1cb1
dont assert cancelled sims in asktell surmise test (at this time)
jlnav Sep 13, 2024
94de46f
slotting in variables/objectives into Generator abc. changes to subcl…
jlnav Sep 19, 2024
80df25f
try an indexing fix
jlnav Sep 20, 2024
b5d8bcf
dont require an explicit "None" to shut down a threaded generator
jlnav Sep 20, 2024
f52bf92
various internal logics and routines for buffering results passed bac…
jlnav Sep 25, 2024
5434dfa
fixes
jlnav Sep 25, 2024
0ab048d
given that persis_info available to the aposmm thread needs nworkers.…
jlnav Sep 25, 2024
7a9a2d8
fix
jlnav Sep 25, 2024
a68ffb8
tiny fix
jlnav Sep 27, 2024
5228711
tiny fix
jlnav Sep 27, 2024
1ef5898
undo some unneeded changes
jlnav Sep 27, 2024
8371d97
enormously ugly iterating over the buffering, tell_numpy process. got…
jlnav Sep 27, 2024
092be69
Merge branch 'develop' into feature/adjusts_for_optimas
jlnav Oct 4, 2024
3ebc467
making some attributes private
jlnav Oct 4, 2024
1159e74
Merge branch 'develop' into feature/adjusts_for_optimas
jlnav Oct 7, 2024
138c89e
Merge branch 'develop' into experimental/jlnav_plus_shuds_asktell
jlnav Oct 7, 2024
2922259
Merge branch 'experimental/jlnav_plus_shuds_asktell' into feature/adj…
jlnav Oct 7, 2024
c2a2802
comments, reorganizing tell_numpy as usual
jlnav Oct 7, 2024
5a2eb09
using gen_specs.batch_size and gen_specs.initial_batch_size to try co…
jlnav Oct 7, 2024
10accde
Merge branch 'develop' into feature/adjusts_for_optimas
jlnav Oct 8, 2024
aa8ad57
use base MPIRunner if detection fails, so KeyError doesnt occur?
jlnav Oct 8, 2024
6712f1e
Merge branch 'bugfix/detect_mpiexec_mpis' into feature/adjusts_for_op…
jlnav Oct 8, 2024
1eec392
various fixes as usual, plus experimenting with running gen-on-proces…
jlnav Oct 10, 2024
c4418fb
Merge branch 'develop' into experimental/jlnav_plus_shuds_asktell
jlnav Oct 14, 2024
2b8e537
initial commit - adding variables/objectives to initializer signature…
jlnav Oct 14, 2024
70dde7b
recreate the buffer after the results' final opportunity to send onto…
jlnav Oct 14, 2024
484304b
dont need sim_id sorting
jlnav Oct 14, 2024
b0897d0
the initial sample being done is determined by the total number of re…
jlnav Oct 14, 2024
cdcb2d8
Merge branch 'develop' into experimental/jlnav_plus_shuds_asktell
jlnav Oct 15, 2024
57bbfb1
it was long-past time to give up on the super-complicated slot-in-dat…
jlnav Oct 17, 2024
dbd19fd
Merge pull request #1433 from Libensemble/feature/adjusts_for_optimas
jlnav Oct 17, 2024
994b652
enormously critical bugfix; optimas workflow now finds minima
jlnav Oct 17, 2024
64c2cd1
Merge branch 'experimental/jlnav_plus_shuds_asktell' into asktell/var…
jlnav Oct 18, 2024
3104240
experiment with UniformSampleDicts using variables/objectiveso
jlnav Oct 18, 2024
3d262fb
i wonder if we can determine lb, ub, and n based on the contents of s…
jlnav Oct 21, 2024
847a617
APOSMM can now accept variables and objectives instead of needing ub,…
jlnav Oct 22, 2024
f45ddbe
cleanup the removed validator; since gen_specs['out'] can be absent
jlnav Oct 22, 2024
26f1d73
cleanup/fixes
jlnav Oct 22, 2024
10e96d8
stop kwargs from replacing entire gen_specs.user; try out vars/objs w…
jlnav Oct 22, 2024
0290deb
Merge branch 'develop' into experimental/jlnav_plus_shuds_asktell
jlnav Oct 22, 2024
e01e87b
removing ask/tell generator wrapper user function; removing from samp…
jlnav Oct 22, 2024
a1eb450
adjust ask/tell gpcam test
jlnav Oct 23, 2024
23b1549
Merge branch 'experimental/jlnav_plus_shuds_asktell' into asktell/var…
jlnav Oct 23, 2024
1b4c2c6
we dont need to run multiple tests for asktell surmise
jlnav Oct 24, 2024
5f777c2
additional experiments with vars/objs, including seeing if we can app…
jlnav Oct 25, 2024
a165cdd
tiny changes for slotting in data back from the waket/optimas workflow
jlnav Oct 25, 2024
ac5467b
moving logic for determining lb and ub from variables into parent cla…
jlnav Oct 28, 2024
85507a4
init pair of functions for mapping, slot in where they'll be called
jlnav Oct 28, 2024
fc30284
remove a debugging print
jlnav Oct 28, 2024
98267e3
small fixes, including slotting-in x-on-cube, removing hardcoded -10 …
jlnav Oct 30, 2024
74579d5
simplifications from code-review; need to determine reason for hang i…
jlnav Oct 30, 2024
63ef323
i determined that besides having asked for at least as many points as…
jlnav Oct 30, 2024
1b1cd59
better check: all generated sim_ids have returned to the buffer
jlnav Oct 30, 2024
dcb3486
fix LibensembleGenThreadInterfacer._set_sim_ended to use results' dty…
jlnav Oct 30, 2024
6828fe0
whoops, fix dtype definition in set_sim_ended
jlnav Oct 30, 2024
e443af9
cleanup unused attributes
jlnav Oct 30, 2024
a1937a9
better buffer updating suggestion from shuds
jlnav Oct 31, 2024
dedef4c
fix ask-the-genf condition to accomodate after initial sample has com…
jlnav Oct 31, 2024
4b812d6
fix set_sim_ended new array dtype specification
jlnav Oct 31, 2024
f9e3cba
small fixes, and first tentative implementation of converter for xs t…
jlnav Nov 1, 2024
14c36fa
perhaps the input conversion will be easier on a numpy array?
jlnav Nov 1, 2024
25299e7
tentatively complete converter for vars/objs -> x/f. but those xs and…
jlnav Nov 1, 2024
f0736fb
some cleanup
jlnav Nov 1, 2024
7fa4d1e
fix continue-condition to occur earlier if we're looking at keys we d…
jlnav Nov 4, 2024
14daf3c
test fixes, plus if our gen naturally returns the requested variables…
jlnav Nov 4, 2024
114c7a4
fix asktell_gen functionality test - including removing wrapper tests…
jlnav Nov 4, 2024
507bc0a
just use UniformSample class
jlnav Nov 4, 2024
18a52c9
remove ask/tell surmise and ask/tell surmise test - they were proof-o…
jlnav Nov 4, 2024
231e6f0
fix import
jlnav Nov 4, 2024
eaebbff
remove the other ask/tell surmise test
jlnav Nov 4, 2024
043feeb
renable persistent_aposmm unit test
jlnav Nov 5, 2024
c66f10b
gpCAM class uses returned x
shuds13 Nov 5, 2024
3d7981b
Convert numpy scalar types
shuds13 Nov 5, 2024
c380595
preparing to add variables_mapping to LibensembleGenerator parent cla…
jlnav Nov 6, 2024
fdcfd66
Merge pull request #1453 from Libensemble/experimental/optimas_waket_…
jlnav Nov 7, 2024
1e0abd3
Merge branch 'experimental/jlnav_plus_shuds_asktell' into asktell/var…
jlnav Nov 7, 2024
c7ea54b
intermediate work on passing mapping into np_to_list_dicts. need to p…
jlnav Nov 7, 2024
c111afd
Call setup on first ask
shuds13 Nov 8, 2024
0ee448c
use mapping to construct list_dicts_to_np dtype when provided
jlnav Nov 8, 2024
bb37f4b
additional work on replacing dict keys with xs and fs
jlnav Nov 8, 2024
38b3967
some cleanup of generators.py in anticipation of the changes to the d…
jlnav Nov 8, 2024
4b49233
Merge branch 'experimental/jlnav_plus_shuds_asktell' into asktell/var…
jlnav Nov 11, 2024
1d213ef
dont try to determine dtype for fields that aren't actually in the in…
jlnav Nov 11, 2024
f8c5eaf
finalize mapping support within list_dicts_to_np, now need to refacto…
jlnav Nov 11, 2024
dff6bad
refactoring
jlnav Nov 11, 2024
c1ec7f6
tiny fixes; need to figure out why aposmm_nlopt reg test is hanging
jlnav Nov 11, 2024
a5133b9
runners.py no longer calls setup() on gen
jlnav Nov 11, 2024
682daa8
rename a handful of asktell tests to have a test_asktell prefix
jlnav Nov 12, 2024
09ebdbc
remove redundant .setup calls that also cause hangs
jlnav Nov 12, 2024
9f200f0
Merge branch 'experimental/jlnav_plus_shuds_asktell' into asktell/var…
jlnav Nov 12, 2024
cf5ac63
Merge branch 'develop' into experimental/jlnav_plus_shuds_asktell
jlnav Nov 13, 2024
f2ef248
Merge branch 'experimental/jlnav_plus_shuds_asktell' into asktell/var…
jlnav Nov 13, 2024
2c6a9c4
lock nlopt to 2.8.0?
jlnav Nov 13, 2024
7224de3
Merge branch 'develop' into experimental/jlnav_plus_shuds_asktell
jlnav Nov 14, 2024
99a7a2c
Merge branch 'experimental/jlnav_plus_shuds_asktell' into asktell/var…
jlnav Nov 14, 2024
e8b7052
Feature/spawn with interfacer (#1464)
shuds13 Nov 14, 2024
23e5164
use macOS-supported condition to check if gen_f has enqueued any outb…
jlnav Nov 14, 2024
06c14d7
Merge pull request #1467 from Libensemble/asktell/macos_queue_fixes
jlnav Nov 14, 2024
bc1587e
Merge branch 'experimental/jlnav_plus_shuds_asktell' into asktell/var…
jlnav Nov 14, 2024
5c2308d
avoid redundant install of nlopt?
jlnav Nov 14, 2024
0d146fc
Merge branch 'develop' into experimental/jlnav_plus_shuds_asktell
jlnav Nov 20, 2024
ef906d5
Merge branch 'experimental/jlnav_plus_shuds_asktell' into asktell/var…
jlnav Nov 20, 2024
9d07e6c
Merge branch 'develop' into experimental/jlnav_plus_shuds_asktell
jlnav Nov 20, 2024
902b7f0
Merge branch 'experimental/jlnav_plus_shuds_asktell' into asktell/var…
jlnav Nov 20, 2024
64b6401
swap sim_id with _id when data goes out from gen. swap _id with sim_i…
jlnav Dec 3, 2024
ab09b9f
Merge pull request #1480 from Libensemble/asktell/under_id
jlnav Dec 3, 2024
d66dafb
Merge branch 'experimental/jlnav_plus_shuds_asktell' into asktell/var…
jlnav Dec 4, 2024
f4a9691
Merge pull request #1448 from Libensemble/asktell/variables_objectives
jlnav Dec 4, 2024
6fb608e
Merge branch 'experimental/jlnav_plus_shuds_asktell' into asktell/try…
jlnav Dec 4, 2024
f926bfa
Merge pull request #1451 from Libensemble/asktell/try_removing_wrapper
jlnav Dec 4, 2024
25bca85
rename LibensembleGenThreadInterfacer to PersistentGenInterfacer
jlnav Dec 4, 2024
2973b41
remove ask_updates from abc
jlnav Dec 4, 2024
5a7160f
always build "lb" and "ub" from variables
jlnav Dec 4, 2024
b5d66e0
refactoring of list_dicts_to_np, more comments, docstrings, etc.
jlnav Dec 4, 2024
bf4577d
refactor np_to_list_dicts
jlnav Dec 4, 2024
c24730b
only call ask_updates on gen if its implemented
jlnav Dec 4, 2024
8695692
rename self.thread to self.running_gen_f, some TODO and clarification…
jlnav Dec 5, 2024
fcb434e
lets go with the first approach for updating libE_info's comm
jlnav Dec 6, 2024
581c9a5
fix
jlnav Dec 6, 2024
877ecef
Merge pull request #1481 from Libensemble/asktell/various_fixes
jlnav Dec 10, 2024
54d7b3f
Merge branch 'develop' into experimental/jlnav_plus_shuds_asktell
jlnav Dec 17, 2024
1cd8b45
Merge branch 'develop' into experimental/jlnav_plus_shuds_asktell
jlnav Feb 27, 2025
05fca90
Merge branch 'develop' into experimental/jlnav_plus_shuds_asktell
jlnav Mar 13, 2025
7a96995
Merge branch 'develop' into experimental/jlnav_plus_shuds_asktell
jlnav Mar 20, 2025
c86c571
Merge branch 'develop' into experimental/jlnav_plus_shuds_asktell
jlnav Mar 21, 2025
8379e0f
first find-and-replace for ask/tell/final_tell to suggest/ingest/fina…
jlnav Mar 21, 2025
0ad9dcf
missed one
jlnav Mar 21, 2025
e2263a3
oMerge branch 'develop' into experimental/jlnav_plus_shuds_asktell
jlnav Mar 21, 2025
57e8c4b
Merge branch 'develop' into experimental/jlnav_plus_shuds_asktell
jlnav Apr 11, 2025
a952fc1
Merge branch 'develop' into experimental/jlnav_plus_shuds_asktell
jlnav Apr 30, 2025
6ec7528
Merge branch 'develop' into experimental/jlnav_plus_shuds_asktell
jlnav May 28, 2025
3ac630a
initial commit, adding upstream current VOCS implementation as depend…
jlnav May 28, 2025
08ad9df
initial commit for replacing variables/objectives with VOCS
jlnav May 30, 2025
aca1d50
Merge branch 'develop' into experimental/jlnav_plus_shuds_asktell
jlnav Jul 2, 2025
6ac1faa
Merge branch 'asktell/init_vocs' into asktell/VOCS
jlnav Jul 2, 2025
56c644e
make generator_standard a required dependency
jlnav Jul 2, 2025
fec7aa4
cleanup
jlnav Jul 2, 2025
0db9f0b
some more cleanup, carrying on with making UniformSampler VOCS compat…
jlnav Jul 2, 2025
49fda1e
adjust test_asktell to use VOCS for testing UniformSample
jlnav Jul 2, 2025
1d6f83b
cleanup sampling.py
jlnav Jul 2, 2025
81267a5
first attempt to try simply having new Standard_GP_CAM be a thin wrap…
jlnav Jul 2, 2025
b633f94
fix gen standard repo install
jlnav Jul 2, 2025
a3e8346
work to convert previous variables/objectives for LibensembleGenerato…
jlnav Jul 3, 2025
4da4298
further work using vocs for self.n, self.lb, self.ub
jlnav Jul 3, 2025
c0e452c
make GPCAM_Standard test a separate file
jlnav Jul 9, 2025
f9385c2
adjustments for variables_mapping needing to be an attribute of the g…
jlnav Jul 9, 2025
02b349c
trying to figure out why our autogenerated variables_mapping isn't wo…
jlnav Jul 9, 2025
f162e75
chasing down a bug involving a single-dim f-shape being not (1,), lik…
jlnav Jul 9, 2025
c041a6b
update asktell aposmm unit test
jlnav Jul 10, 2025
23ed512
various fixes involving the dict/array converters, when aposmm has be…
jlnav Jul 10, 2025
34f582e
fix ask/tell sampling test, also don't assume a given gen has a mappi…
jlnav Jul 10, 2025
390597f
include standard-finalize-usage in StandardGenRunner. Then for gens l…
jlnav Jul 11, 2025
f80aa9f
Merge branch 'develop' into asktell/VOCS
jlnav Jul 16, 2025
80c09d7
dunno how this validator change made it through
jlnav Jul 16, 2025
7ca34b1
fix isinstance check for gen_f when gen_specs["generator"] is provide…
jlnav Jul 16, 2025
f6341a4
this spec-checker was lost to time somehow
jlnav Jul 17, 2025
fef5833
Merge branch 'develop' into experimental/jlnav_plus_shuds_asktell
jlnav Jul 17, 2025
673c3eb
Merge branch 'experimental/jlnav_plus_shuds_asktell' into asktell/VOCS
jlnav Jul 22, 2025
65ca79b
revert sampling.py and the associated functionality test to their pre…
jlnav Jul 23, 2025
1ed05e5
various experiments with updating samplers and the test to accept onl…
jlnav Jul 24, 2025
9b1195b
add parameter for UniformSample, instructing the generator to squash …
jlnav Jul 25, 2025
24df60f
making variables_mapping an explicit kwarg for a libensemble generator
jlnav Jul 31, 2025
715773b
bump pydantic - this should've been done in a previous PR
jlnav Jul 31, 2025
08ead4a
fix UniformSample LibensembleGenerator to use variables_mapping
jlnav Jul 31, 2025
22b69b4
just commenting out, but maybe we don't need this unit test now that …
jlnav Jul 31, 2025
f664e37
removing unnecessary GPCAM_Standard class; refactoring the other gpca…
jlnav Aug 6, 2025
99bc450
update regression test to (presumably) use classes that now use VOCS
jlnav Aug 6, 2025
423f0d6
... why was this test excluded?
jlnav Aug 6, 2025
56e59aa
lists instead of tuples...
jlnav Aug 6, 2025
145e09d
fix default value of test_points_file kwarg to be None
jlnav Aug 7, 2025
9a6f299
somehow this tell_numpy got missed
jlnav Aug 7, 2025
9c0e258
various fixes to building variables_mapping and extra.ci, still debug…
jlnav Aug 7, 2025
4a52e0b
temporary debugging print?
jlnav Aug 7, 2025
73bbf69
fix objective name
jlnav Aug 8, 2025
bf0d79e
batch_size fix to runners.py, add batch_size to gen_specs so the runn…
jlnav Aug 8, 2025
b3ce513
we still want to map {"f": ["energy"]), obviously
jlnav Aug 8, 2025
2428152
move StandardSample to test_asktell_sampling.py, to test as-though we…
jlnav Aug 8, 2025
0bcd7c9
various fixes from PR suggestions
jlnav Aug 13, 2025
bf9ed05
move gpcam superclass init to top of init, make UniformSample accept …
jlnav Aug 14, 2025
acc4811
gpcam asserts objectives, then a better description of variables_mapping
jlnav Aug 14, 2025
2a67724
move _validate_vocs call to superclass
jlnav Aug 15, 2025
8c9e313
Merge pull request #1572 from Libensemble/asktell/VOCS
jlnav Aug 18, 2025
6b54991
Merge branch 'develop' into experimental/jlnav_plus_shuds_asktell
jlnav Aug 19, 2025
a4ead36
Split finalize and export
shuds13 Aug 21, 2025
3622219
aposmm uses x mapping to set bounds and size
shuds13 Aug 21, 2025
9b3429b
Fix finalize and export functions
shuds13 Aug 22, 2025
a2c58fc
Option to export with user fields
shuds13 Aug 22, 2025
012227a
Add unit tests of unmap_numpy_array
shuds13 Aug 25, 2025
03420b3
Remove unneeded branch
shuds13 Aug 25, 2025
682425a
Add expected variables mapping for APOSMM
shuds13 Aug 25, 2025
b209901
Better example bounds
shuds13 Aug 25, 2025
fd630eb
Allow pass through of unmapped arrays
shuds13 Aug 25, 2025
57a8de9
Allow export as list of dictionaries
shuds13 Aug 25, 2025
050c22d
Add pass-through array to unmap test
shuds13 Aug 25, 2025
5d31b63
Add export unit tests and fix up unmap
shuds13 Aug 25, 2025
d1d4b76
Re-enable APOSMM unit tests
shuds13 Aug 25, 2025
b05762a
Add checks for x and x_on_cube
shuds13 Aug 25, 2025
0b8cdec
Add export tests and fixup
shuds13 Aug 25, 2025
1e52d99
Do not send local_min/pt to ingest
shuds13 Aug 27, 2025
3c21202
Autofill x and f variables_mapping separately
shuds13 Aug 28, 2025
1cb542f
Update asktell APOSMM regression test
shuds13 Aug 29, 2025
9798b3e
Merge branch 'develop' into experimental/jlnav_plus_shuds_asktell
jlnav Sep 5, 2025
585c521
Add fvec when components is present
shuds13 Sep 22, 2025
cf36e85
Send APOSMM errors as a string
shuds13 Sep 22, 2025
77efa2a
Formatting
shuds13 Oct 1, 2025
ed6604d
Blacken
shuds13 Oct 1, 2025
9cbca1e
Clarify comment
shuds13 Oct 1, 2025
ec773d4
Update generator_standard to gest_api
shuds13 Oct 1, 2025
5ea9b2b
Fix gest-api in pyproject
shuds13 Oct 1, 2025
b14b85d
Fix gest project name
shuds13 Oct 1, 2025
f8d1833
Fix _validate_vocs for gpCAM
shuds13 Oct 1, 2025
ad54abd
Remove misleading n
shuds13 Oct 2, 2025
a383dc0
Merge pull request #1582 from Libensemble/feature/update_finalize
shuds13 Oct 2, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions docs/function_guides/ask_tell_generator.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@

Ask/Tell Generators
===================

**BETA - SUBJECT TO CHANGE**

These generators, implementations, methods, and subclasses are in BETA, and
may change in future releases.

The Generator interface is expected to roughly correspond with CAMPA's standard:
https://github.com/campa-consortium/generator_standard

libEnsemble is in the process of supporting generator objects that implement the following interface:

.. automodule:: generators
:members: Generator LibensembleGenerator
:undoc-members:

.. autoclass:: Generator
:member-order: bysource
:members:
1 change: 1 addition & 0 deletions docs/function_guides/function_guide_index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ These guides describe common development patterns and optional components:
:caption: Writing User Functions

generator
ask_tell_generator
simulator
allocator
sim_gen_alloc_api
Expand Down
1 change: 1 addition & 0 deletions libensemble/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@
from libensemble import logger

from .ensemble import Ensemble
from .generators import Generator
2 changes: 1 addition & 1 deletion libensemble/ensemble.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
from libensemble.specs import AllocSpecs, ExitCriteria, GenSpecs, LibeSpecs, SimSpecs
from libensemble.tools import add_unique_random_streams
from libensemble.tools import parse_args as parse_args_f
from libensemble.tools.parse_args import mpi_init
from libensemble.tools import save_libE_output
from libensemble.tools.parse_args import mpi_init
from libensemble.utils.misc import specs_dump

ATTR_ERR_MSG = 'Unable to load "{}". Is the function or submodule correctly named?'
Expand Down
154 changes: 154 additions & 0 deletions libensemble/gen_classes/gpCAM.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
"""Generator class exposing gpCAM functionality"""

import time
from typing import List

import numpy as np
from gpcam import GPOptimizer as GP
from numpy import typing as npt

# While there are class / func duplicates - re-use functions.
from libensemble.gen_funcs.persistent_gpCAM import (
_calculate_grid_distances,
_eval_var,
_find_eligible_points,
_generate_mesh,
_read_testpoints,
)
from libensemble.generators import LibensembleGenerator

__all__ = [
"GP_CAM",
"GP_CAM_Covar",
]


# Note - batch size is set in wrapper currently - and passed to ask as n_trials.
# To support empty ask(), add batch_size back in here.


# Equivalent to function persistent_gpCAM_ask_tell
class GP_CAM(LibensembleGenerator):
"""
This generation function constructs a global surrogate of `f` values.

It is a batched method that produces a first batch uniformly random from
(lb, ub). On subequent iterations, it calls an optimization method to
produce the next batch of points. This optimization might be too slow
(relative to the simulation evaluation time) for some use cases.
"""

def _initialize_gpCAM(self, user_specs):
"""Extract user params"""
# self.b = user_specs["batch_size"]
self.lb = np.array(user_specs["lb"])
self.ub = np.array(user_specs["ub"])
self.n = len(self.lb) # dimension
assert isinstance(self.n, int), "Dimension must be an integer"
assert isinstance(self.lb, np.ndarray), "lb must be a numpy array"
assert isinstance(self.ub, np.ndarray), "ub must be a numpy array"
self.all_x = np.empty((0, self.n))
self.all_y = np.empty((0, 1))
np.random.seed(0)

Copy link
Member

@shuds13 shuds13 Jul 31, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to decide __init__ interface.
We questioned before whether we keep the same interface - which mirrors the current gen_f, or to rearrange, as H is often not given (basically an H0). So it could be gen_specs first. I'm leaning towards keeping the original ordering as it mirrors our user functions, but this should be discussed.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair enough. My opinion/intuition is a user is more likely to prefer either "classical" gens (e.g. Jeff) or ask/tell gens (e.g. other CAMPA folks). With these gens' interfaces and users being so different, I don't think an arguably simpler rearrangement of the input parameters is too confusing.

Similarly to how some people prefer numpy or pandas; they do similar things, but their interfaces being different isn't a point of contention.

I'd also lean towards if someone were to initialize some object, like a gen, themselves, they'd prefer their specifications be provided as early and clearly as possible:

my_gen = Generator(param=1,
     option="two",
)

vs.

my_gen = Generator(None,
     {},
     {"param": 1, "option": "two"},
     {},
)

def __init__(self, H, persis_info, gen_specs, libE_info=None):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will put above _initialize_gpcAM

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and make _initialize_gpcAM _initialize_gpCAM

self.H = H # Currently not used - could be used for an H0
self.persis_info = persis_info
self.gen_specs = gen_specs
self.libE_info = libE_info

self.U = self.gen_specs["user"]
self._initialize_gpCAM(self.U)

self.my_gp = None
self.noise = 1e-8 # 1e-12
self.ask_max_iter = self.gen_specs["user"].get("ask_max_iter") or 10

def ask_numpy(self, n_trials: int) -> npt.NDArray:
if self.all_x.shape[0] == 0:
self.x_new = self.persis_info["rand_stream"].uniform(self.lb, self.ub, (n_trials, self.n))
else:
start = time.time()
self.x_new = self.my_gp.ask(
input_set=np.column_stack((self.lb, self.ub)),
n=n_trials,
pop_size=n_trials,
acquisition_function="total correlation",
max_iter=self.ask_max_iter, # Larger takes longer. gpCAM default is 20.
)["x"]
print(f"Ask time:{time.time() - start}")
H_o = np.zeros(n_trials, dtype=self.gen_specs["out"])
H_o["x"] = self.x_new
return H_o

def tell_numpy(self, calc_in: npt.NDArray) -> None:
if calc_in is not None:
self.y_new = np.atleast_2d(calc_in["f"]).T
nan_indices = [i for i, fval in enumerate(self.y_new) if np.isnan(fval)]
self.x_new = np.delete(self.x_new, nan_indices, axis=0)
self.y_new = np.delete(self.y_new, nan_indices, axis=0)

self.all_x = np.vstack((self.all_x, self.x_new))
self.all_y = np.vstack((self.all_y, self.y_new))

noise_var = self.noise * np.ones(len(self.all_y))
if self.my_gp is None:
self.my_gp = GP(self.all_x, self.all_y.flatten(), noise_variances=noise_var)
else:
self.my_gp.tell(self.all_x, self.all_y.flatten(), noise_variances=noise_var)
self.my_gp.train()


class GP_CAM_Covar(GP_CAM):
"""
This generation function constructs a global surrogate of `f` values.

It is a batched method that produces a first batch uniformly random from
(lb, ub) and on following iterations samples the GP posterior covariance
function to find sample points.
"""

def __init__(self, H, persis_info, gen_specs, libE_info=None):
super().__init__(H, persis_info, gen_specs, libE_info)
self.test_points = _read_testpoints(self.U)
self.x_for_var = None
self.var_vals = None
if self.U.get("use_grid"):
self.num_points = 10
self.x_for_var = _generate_mesh(self.lb, self.ub, self.num_points)
self.r_low_init, self.r_high_init = _calculate_grid_distances(self.lb, self.ub, self.num_points)

def ask_numpy(self, n_trials: int) -> List[dict]:
if self.all_x.shape[0] == 0:
x_new = self.persis_info["rand_stream"].uniform(self.lb, self.ub, (n_trials, self.n))
else:
if not self.U.get("use_grid"):
x_new = self.x_for_var[np.argsort(self.var_vals)[-n_trials:]]
else:
r_high = self.r_high_init
r_low = self.r_low_init
x_new = []
r_cand = r_high # Let's start with a large radius and stop when we have batchsize points

sorted_indices = np.argsort(-self.var_vals)
while len(x_new) < n_trials:
x_new = _find_eligible_points(self.x_for_var, sorted_indices, r_cand, n_trials)
if len(x_new) < n_trials:
r_high = r_cand
r_cand = (r_high + r_low) / 2.0

self.x_new = x_new
H_o = np.zeros(n_trials, dtype=self.gen_specs["out"])
H_o["x"] = self.x_new
return H_o

def tell_numpy(self, calc_in: npt.NDArray):
if calc_in is not None:
super().tell_numpy(calc_in)
if not self.U.get("use_grid"):
n_trials = len(self.y_new)
self.x_for_var = self.persis_info["rand_stream"].uniform(self.lb, self.ub, (10 * n_trials, self.n))

self.var_vals = _eval_var(
self.my_gp, self.all_x, self.all_y, self.x_for_var, self.test_points, self.persis_info
)
47 changes: 47 additions & 0 deletions libensemble/gen_classes/sampling.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
"""Generator classes providing points using sampling"""

import numpy as np

from libensemble.generators import LibensembleGenerator

__all__ = [
"UniformSample",
]


class UniformSample(LibensembleGenerator):
"""
This generator returns ``gen_specs["initial_batch_size"]`` uniformly
sampled points the first time it is called. Afterwards, it returns the
number of points given. This can be used in either a batch or asynchronous
mode by adjusting the allocation function.
"""

def __init__(self, _, persis_info, gen_specs, libE_info=None) -> list:
self.persis_info = persis_info
self.gen_specs = gen_specs
self.libE_info = libE_info
self._get_user_params(self.gen_specs["user"])

def ask_numpy(self, n_trials):
H_o = np.zeros(n_trials, dtype=self.gen_specs["out"])
H_o["x"] = self.persis_info["rand_stream"].uniform(self.lb, self.ub, (n_trials, self.n))

if "obj_component" in H_o.dtype.fields: # needs H_o - needs to be created in here.
H_o["obj_component"] = self.persis_info["rand_stream"].integers(
low=0, high=self.gen_specs["user"]["num_components"], size=n_trials
)
return H_o

def tell_numpy(self, calc_in):
pass # random sample so nothing to tell

def _get_user_params(self, user_specs):
"""Extract user params"""
# b = user_specs["initial_batch_size"]
self.ub = user_specs["ub"]
self.lb = user_specs["lb"]
self.n = len(self.lb) # dimension
assert isinstance(self.n, int), "Dimension must be an integer"
assert isinstance(self.lb, np.ndarray), "lb must be a numpy array"
assert isinstance(self.ub, np.ndarray), "ub must be a numpy array"
4 changes: 2 additions & 2 deletions libensemble/gen_funcs/persistent_aposmm.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
import numpy as np
from mpmath import gamma

# from scipy.spatial.distance import cdist

from libensemble.gen_funcs.aposmm_localopt_support import ConvergedMsg, LocalOptInterfacer, simulate_recv_from_manager
from libensemble.message_numbers import EVAL_GEN_TAG, FINISHED_PERSISTENT_GEN_TAG, PERSIS_STOP, STOP_TAG
from libensemble.tools.persistent_support import PersistentSupport

# from scipy.spatial.distance import cdist


# Due to recursion error in scipy cdist function
def cdist(XA, XB, metric="euclidean"):
Expand Down
38 changes: 38 additions & 0 deletions libensemble/gen_funcs/persistent_gen_wrapper.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import inspect

import numpy as np

from libensemble.message_numbers import EVAL_GEN_TAG, FINISHED_PERSISTENT_GEN_TAG, PERSIS_STOP, STOP_TAG
from libensemble.tools.persistent_support import PersistentSupport
from libensemble.utils.misc import np_to_list_dicts


def persistent_gen_f(H, persis_info, gen_specs, libE_info):

ps = PersistentSupport(libE_info, EVAL_GEN_TAG)
U = gen_specs["user"]
b = U.get("initial_batch_size") or U.get("batch_size")

generator = U["generator"]
if inspect.isclass(generator):
gen = generator(H, persis_info, gen_specs, libE_info)
else:
gen = generator

tag = None
calc_in = None
while tag not in [STOP_TAG, PERSIS_STOP]:
H_o = gen.ask(b)
if isinstance(H_o, list):
H_o_arr = np.zeros(len(H_o), dtype=gen_specs["out"])
for i in range(len(H_o)):
for key in H_o[0].keys():
H_o_arr[i][key] = H_o[i][key]
H_o = H_o_arr
tag, Work, calc_in = ps.send_recv(H_o)
gen.tell(np_to_list_dicts(calc_in))

if hasattr(calc_in, "__len__"):
b = len(calc_in)

return H_o, persis_info, FINISHED_PERSISTENT_GEN_TAG
Loading