PageSourceSearch

https://ax.dev/assets/js/a8064e24.90169144.js

js ax.dev collected 2026-09-24 10:34:03 UTC 7,822 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunk=self.webpackChunk||[]).push([[3517],{28453(e,t,i){i.d(t,{R:()=>o,x:()=>s});var n=i(96540);const a={},r=n.createContext(a);function o(e){const t=n.useContext(r);return n.useMemo(function(){return"function"==typeof e?e(t):{...t,...e}},[t,e])}function s(e){let t;return t=e.disableParentContext?"function"==typeof e.components?e.components(a):e.components||a:o(e.components),n.createElement(r.Provider,{value:t},e.children)}},84664(e,t,i){i.r(t),i.d(t,{assets:()=>c,contentTitle:()=>s,default:()=>h,frontMatter:()=>o,metadata:()=>n,toc:()=>l});const n=JSON.parse('{"id":"recipes/influence-gs-choice","title":"Influencing The Choice of a Generation Strategy","description":"Introduction","source":"@site/versioned_docs/version-1.0.0/recipes/influence-gs-choice.md","sourceDirName":"recipes","slug":"/recipes/influence-gs-choice","permalink":"/docs/1.0.0/recipes/influence-gs-choice","draft":false,"unlisted":false,"tags":[],"version":"1.0.0","lastUpdatedBy":"github-actions[bot]","lastUpdatedAt":1746744654000,"frontMatter":{},"sidebar":"tutorials","previous":{"title":"Specifying Outcome Constraints","permalink":"/docs/1.0.0/recipes/outcome-constraints"}}');var a=i(74848),r=i(28453);const o={},s="Influencing The Choice of a Generation Strategy",c={},l=[{value:"Introduction",id:"introduction",level:2},{value:"Prerequisites",id:"prerequisites",level:2},{value:"Steps",id:"steps",level:2},{value:"1. Configure a generation strategy via <code>configure_generation_strategy</code>",id:"1-configure-a-generation-strategy-via-configure_generation_strategy",level:3},{value:"2. Continue with iterating over trials and evaluating them",id:"2-continue-with-iterating-over-trials-and-evaluating-them",level:3},{value:"3. View the state of the experiment via <code>summarize()</code>",id:"3-view-the-state-of-the-experiment-via-summarize",level:3},{value:"Learn more",id:"learn-more",level:2}];function d(e){const t={a:"a",code:"code",h1:"h1",h2:"h2",h3:"h3",header:"header",li:"li",ol:"ol",p:"p",pre:"pre",ul:"ul",...(0,r.R)(),...e.components};return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(t.header,{children:(0,a.jsx)(t.h1,{id:"influencing-the-choice-of-a-generation-strategy",children:"Influencing The Choice of a Generation Strategy"})}),"\n",(0,a.jsx)(t.h2,{id:"introduction",children:"Introduction"}),"\n",(0,a.jsx)(t.p,{children:"The GenerationStrategy used by Ax to generate candidate configurations / trials is determined by various factors, such as experiment characteristics and configuration settings. In this tutorial, we'll explore how to influence the selection of a GenerationStrategy via the Client's customizable configurations."}),"\n",(0,a.jsx)(t.h2,{id:"prerequisites",children:"Prerequisites"}),"\n",(0,a.jsxs)(t.p,{children:["Instantiate the ",(0,a.jsx)(t.code,{children:"Client"})," and configure your experiment and metrics."]}),"\n",(0,a.jsxs)(t.p,{children:["We will also assume you are already familiar with\n",(0,a.jsx)(t.a,{href:"../tutorials/getting_started",children:"basic Ax usage"}),"."]}),"\n",(0,a.jsx)(t.pre,{children:(0,a.jsx)(t.code,{className:"language-python",children:"client = Client()\n\nclient.configure_experiment(...)\nclient.configure_metrics(...)\n"})}),"\n",(0,a.jsx)(t.h2,{id:"steps",children:"Steps"}),"\n",(0,a.jsxs)(t.ol,{children:["\n",(0,a.jsxs)(t.li,{children:["Configure a generation strategy via ",(0,a.jsx)(t.code,{children:"configure_generation_strategy"})]}),"\n",(0,a.jsx)(t.li,{children:"Continue with iterating over trials and evaluating them"}),"\n",(0,a.jsxs)(t.li,{children:["View the state of the experiment via ",(0,a.jsx)(t.code,{children:"summarize()"})]}),"\n"]}),"\n",(0,a.jsxs)(t.h3,{id:"1-configure-a-generation-strategy-via-configure_generation_strategy",children:["1. Configure a generation strategy via ",(0,a.jsx)(t.code,{children:"configure_generation_strategy"})]}),"\n",(0,a.jsxs)(t.p,{children:["We can leverage the Client's ",(0,a.jsx)(t.code,{children:"configure_generation_strategy"})," method to configure a generation strategy. This is an optional method used to configure the way candidate parameterizations are generated during the optimization. If not called, a default ",(0,a.jsx)(t.code,{children:"GenerationStrategy"})," will be used."]}
1),"\n",(0,a.jsxs)(t.p,{children:["In this example, we will configure a GenerationStrategy that reduces or skips the initialization step, does not use the center of the search space as the first point, and allows for exceeding the provided initialization budget. To learn more about what other configurations you can leverage, ",(0,a.jsx)(t.a,{href:"https://ax.readthedocs.io/en/latest/api.html#ax.api.client.Client.configure_generation_strategy",children:"check out the API docs for configure_generation_strategy"})]}),"\n",(0,a.jsx)(t.pre,{children:(0,a.jsx)(t.code,{className:"language-python",children:"client.configure_generation_strategy(\n    # Reduce or skip the initialization step\n    # NOTE: Don't set this to 0 (which would skip initialization) unless you\n    # attached manual trials. It's not possible to fully skip the initialization\n    # step and start Bayesian optimization without any completed trials with data!\n    initialization_budget=1,\n    # Do not use center of searchspace as the first point\n    initialize_with_center=False,\n    # Allow for exceeding the provided initialization budget\n    allow_exceeding_initialization_budget=True,\n    # Don't count manually added trials against the initialization\n    # budget (i.e. ensure that the 3 quasi-random Sobol trials will\n    # be run, e.g. to sample the search space more evenly).\n    use_existing_trials_for_initialization=False,\n)\n"})}),"\n",(0,a.jsxs)(t.p,{children:["It\u2019s possible to specify a fully custom ",(0,a.jsx)(t.code,{children:"GenerationStrategy"})," via ",(0,a.jsx)(t.code,{children:"Client.set_generation_strategy"}),", but this usage is not part of the Ax backward-compatible API and backward compatibility is not guaranteed: the method or its input could thus change between minor versions in the future."]}),"\n",(0,a.jsx)(t.h3,{id:"2-continue-with-iterating-over-trials-and-evaluating-them",children:"2. Continue with iterating over trials and evaluating them"}),"\n",(0,a.jsx)(t.p,{children:"Now that your experiment has been configured with a desired GenerationStrategy,\nyou can simply continue with iterating over trials and evaluating them as you\ntypically would."}),"\n",(0,a.jsx)(t.pre,{children:(0,a.jsx)(t.code,{className:"language-python",children:"# Getting just one trial in this example\ntrial_idx, parameters = client.get_next_trials(max_trials=1)().popitem()\nclient.complete_trial(...)\n"})}),"\n",(0,a.jsxs)(t.h3,{id:"3-view-the-state-of-the-experiment-via-summarize",children:["3. View the state of the experiment via ",(0,a.jsx)(t.code,{children:"summarize()"})]}),"\n",(0,a.jsxs)(t.p,{children:["We can now view the state of the experiment by calling ",(0,a.jsx)(t.code,{children:"summarize()"}),", and\nvalidate that our Generation Strategy configurations were used when generating candidates:"]}),"\n",(0,a.jsx)(t.pre,{children:(0,a.jsx)(t.code,{className:"language-python",children:"client.summarize()\n"})}),"\n",(0,a.jsx)(t.h2,{id:"learn-more",children:"Learn more"}),"\n",(0,a.jsx)(t.p,{children:"Take a look at these other recipes to continue your learning:"}),"\n",(0,a.jsxs)(t.ul,{children:["\n",(0,a.jsx)(t.li,{children:(0,a.jsx)(t.a,{href:"../recipes/multi-objective-optimization",children:"Multi-objective Optimizations in Ax"})}),"\n",(0,a.jsx)(t.li,{children:(0,a.jsx)(t.a,{href:"../recipes/scalarized-objective",children:"Scalarized Objective Optimizations with Ax"})}),"\n"]})]})}function h(e={}){const{wrapper:t}={...(0,r.R)(),...e.components};return t?(0,a.jsx)(t,{...e,children:(0,a.jsx)(d,{...e})}):d(e)}}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.