Skip to content

Asktell/variables objectives #1448

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

jlnav
Copy link
Member

@jlnav jlnav commented Oct 21, 2024

Introducing specifying variables and objectives to ask/tell generators, This basically supersedes specifying gen_specs.in or gen_specs.out from the user's perspective.

For many of our gens, specify a mapping of variables and objectives to "x" and "f":

variables_mapping = {"x": ["core", "edge"], "f": ["energy"]}

@jlnav jlnav changed the title Asktell/variables objectives [WIP] Asktell/variables objectives Oct 21, 2024
jlnav added 16 commits October 21, 2024 15:41
…ss; setting up unit test to eventually map user-specififed variables into internal xs
… fs need to be figured out reasonably, somehow, still
…on't want to convert. fix key-that-starts-with-variable condition, plus append the distinguishing integer
@jlnav jlnav marked this pull request as ready for review November 4, 2024 15:27
jlnav added 2 commits November 4, 2024 09:42
…, since variables/objectives probably wont be passed in. remove exact H-entry test, since the gen does its own internal persis_info
@jlnav jlnav changed the title [WIP] Asktell/variables objectives Asktell/variables objectives Nov 4, 2024
Copy link

codecov bot commented Nov 4, 2024

Codecov Report

Attention: Patch coverage is 83.72093% with 14 lines in your changes missing coverage. Please review.

Project coverage is 78.60%. Comparing base (ab09b9f) to head (d66dafb).
Report is 173 commits behind head on experimental/jlnav_plus_shuds_asktell.

Files with missing lines Patch % Lines
libensemble/generators.py 76.66% 2 Missing and 5 partials ⚠️
libensemble/utils/misc.py 86.20% 3 Missing and 1 partial ⚠️
libensemble/gen_classes/aposmm.py 66.66% 1 Missing and 1 partial ⚠️
libensemble/utils/runners.py 50.00% 1 Missing ⚠️
Additional details and impacted files
@@                            Coverage Diff                            @@
##           experimental/jlnav_plus_shuds_asktell    #1448      +/-   ##
=========================================================================
- Coverage                                  78.90%   78.60%   -0.30%     
=========================================================================
  Files                                         81       80       -1     
  Lines                                       8077     8054      -23     
  Branches                                    1200     1205       +5     
=========================================================================
- Hits                                        6373     6331      -42     
- Misses                                      1499     1510      +11     
- Partials                                     205      213       +8     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

jlnav added 3 commits November 4, 2024 12:48
…f-concepts from before we became dedicated to ask/tell, plus currently it's gen_out is rather "largely dimensioned" for defining via variables/objectives
@jlnav jlnav requested review from jmlarson1 and shuds13 November 5, 2024 14:21
@jlnav jlnav changed the title Asktell/variables objectives [WIP] Asktell/variables objectives Nov 8, 2024
@jlnav jlnav changed the title [WIP] Asktell/variables objectives Asktell/variables objectives Nov 11, 2024
@jlnav
Copy link
Member Author

jlnav commented Nov 11, 2024

Dramatically simplified by the user providing a mapping:

    variables = {"core": [-3, 3], "edge": [-2, 2]}
    objectives = {"energy": "EXPLORE"}
    mapping = {"x": ["core", "edge"]}

    gen = UniformSample(variables, objectives, mapping)

and:

    variables = {"core": [-3, 3], "edge": [-2, 2]}
    objectives = {"energy": "MINIMIZE"}
    variables_mapping = {"x": ["core", "edge"], "f": ["energy"]}

    my_APOSMM = APOSMM(
        variables=variables, objectives=objectives, gen_specs=gen_specs, variables_mapping=variables_mapping
    )

Output dictionaries contain the variables, the objective value can be the key in objectives, and the generator uses the provided mapping to repack variables/objectives into "x"/"f".

This is much simpler than my previous attempt at figuring this out dynamically!


self.n = len(self.variables)
# build our own lb and ub
if "lb" not in kwargs and "ub" not in kwargs:
Copy link
Member

Choose a reason for hiding this comment

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

Have you tested if these are in kargs?

Copy link
Member

Choose a reason for hiding this comment

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

If I forget to comment out my lb/ub line I get:
...persistent_aposmm.py", line 326, in update_local_H_after_receiving
local_H[name][Work["libE_info"]["H_rows"]] = calc_in[name]
ValueError: shape mismatch: value array of shape (4,6) could not be broadcast to indexing result of shape (4,3)

Copy link
Member

Choose a reason for hiding this comment

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

That was with our branches merged.

@shuds13
Copy link
Member

shuds13 commented Nov 14, 2024

With your branch merged into mine the APOSMM run completes, but I dont have any local optimisation runs happening.

I ran with:

vars_std = {"x0": [mcr, 1.0-mcr], "x1": [-20.0, 20.0], "x2":[1.0, 20.0],
            "x_on_cube0": [0, 1.0], "x_on_cube1": [0, 1.0], "x_on_cube2":[0, 1.0],
            }

aposmm = APOSMM(
    variables=vars_std,
    objectives={"f": "MINIMIZE"},  # SH is "MINIMIZE" being used in APOSMM?
    persis_info=persis_info,
    initial_sample_size=initial_sample,
    #initial_sample_size=100,
    localopt_method="LN_BOBYQA",
    rk_const=0.5 * ((gamma(1 + (n / 2)) * 5) ** (1 / n)) / sqrt(pi),
    run_max_eval= 100 * (n + 1),
    max_active_runs=12,
    dist_to_bound_multiple=0.5,
    #lb=np.array([param.lower_bound for param in varying_params]),
    #ub=np.array([param.upper_bound for param in varying_params]),
    hfun=get_x,
    components=1,
    ftol_rel=1e-1,
)

@shuds13
Copy link
Member

shuds13 commented Nov 14, 2024

Also tried with this, though I think this is the default right.

    mapping = {"x": ["x0", "x1", "x2", "x_on_cube0", "x_on_cube1", "x_on_cube2"]},

@jlnav jlnav requested a review from shuds13 November 22, 2024 17:53
@jlnav jlnav merged commit f4a9691 into experimental/jlnav_plus_shuds_asktell Dec 4, 2024
14 checks passed
@jlnav jlnav deleted the asktell/variables_objectives branch December 4, 2024 15:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants