1"use strict";(self.webpackChunk=self.webpackChunk||[]).push([[2685],{28453(e,i,t){t.d(i,{R:()=>r,x:()=>s});var n=t(96540);const o={},a=n.createContext(o);function r(e){const i=n.useContext(a);return n.useMemo(function(){return"function"==typeof e?e(i):{...i,...e}},[i,e])}function s(e){let i;return i=e.disableParentContext?"function"==typeof e.components?e.components(o):e.components||o:r(e.components),n.createElement(a.Provider,{value:i},e.children)}},89395(e,i,t){t.r(i),t.d(i,{assets:()=>l,contentTitle:()=>s,default:()=>p,frontMatter:()=>r,metadata:()=>n,toc:()=>c});const n=JSON.parse('{"id":"recipes/multi-objective-optimization","title":"Multi-Objective Optimization with Ax","description":"Multi-objective optimization (MOO) allows you to optimize multiple objectives","source":"@site/versioned_docs/version-1.0.0/recipes/multi-objective-optimization.md","sourceDirName":"recipes","slug":"/recipes/multi-objective-optimization","permalink":"/docs/1.0.0/recipes/multi-objective-optimization","draft":false,"unlisted":false,"tags":[],"version":"1.0.0","lastUpdatedBy":"github-actions[bot]","lastUpdatedAt":1746744654000,"frontMatter":{},"sidebar":"tutorials","previous":{"title":"Saving and Loading an Ax Experiment to Your SQL Database","permalink":"/docs/1.0.0/recipes/experiment-to-sqlite"},"next":{"title":"Scalarized Objective Optimizations with Ax","permalink":"/docs/1.0.0/recipes/scalarized-objective"}}');var o=t(74848),a=t(28453);const r={},s="Multi-Objective Optimization with Ax",l={},c=[{value:"Prerequisites",id:"prerequisites",level:2},{value:"Setup",id:"setup",level:2},{value:"Steps",id:"steps",level:2},{value:"1. Configure an optimization with multiple objectives",id:"1-configure-an-optimization-with-multiple-objectives",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. Observe optimal parametrizations",id:"3-observe-optimal-parametrizations",level:3},{value:"Learn more",id:"learn-more",level:2}];function d(e){const i={a:"a",code:"code",h1:"h1",h2:"h2",h3:"h3",header:"header",li:"li",ol:"ol",p:"p",pre:"pre",ul:"ul",...(0,a.R)(),...e.components};return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(i.header,{children:(0,o.jsx)(i.h1,{id:"multi-objective-optimization-with-ax",children:"Multi-Objective Optimization with Ax"})}),"\n",(0,o.jsx)(i.p,{children:"Multi-objective optimization (MOO) allows you to optimize multiple objectives\nsimultaneously, which is particularly useful when you have competing objectives.\nIn this recipe, we will demonstrate how to perform multi-objective optimization\nusing the Ax Client."}),"\n",(0,o.jsx)(i.p,{children:"Note that while MOO can handle multiple objectives, it's generally recommended\nto keep the number of objectives relatively small. Having too many objectives\ncan lead decreased optimization performance and difficulties in interpreting the\nresults."}),"\n",(0,o.jsx)(i.h2,{id:"prerequisites",children:"Prerequisites"}),"\n",(0,o.jsxs)(i.p,{children:["We will assume you are already familiar with\n",(0,o.jsx)(i.a,{href:"/docs/1.0.0/tutorials/getting_started/",children:"basic Ax usage"}),"."]}),"\n",(0,o.jsx)(i.h2,{id:"setup",children:"Setup"}),"\n",(0,o.jsxs)(i.p,{children:["Instantiate the ",(0,o.jsx)(i.code,{children:"Client"})," and configure it with your experiment and metrics."]}),"\n",(0,o.jsx)(i.pre,{children:(0,o.jsx)(i.code,{className:"language-python",children:"client = Client()\n\nclient.configure_experiment(...)\nclient.configure_metrics(...)\n"})}),"\n",(0,o.jsx)(i.h2,{id:"steps",children:"Steps"}),"\n",(0,o.jsxs)(i.ol,{children:["\n",(0,o.jsx)(i.li,{children:"Configure an optimization with multiple objectives"}),"\n",(0,o.jsx)(i.li,{children:"Continue with iterating over trials and evaluating them"}),"\n",(0,o.jsx)(i.li,{children:"Observe optimal parametrizations"}),"\n"]}),"\n",(0,o.jsx)(i.h3,{id:"1-configure-an-optimization-with-multiple-objectives",children:"1. Configure an optimization with multiple objectives"}),"\n",(0,o.jsxs)(i.p,{children:["We can leverage the Client's ",(0,o.jsx)(i.co
1de,{children:"configure_optimization"})," method. This method takes\nin an objective goal as a string, and can be used to specify single-objective,\nscalarized-objective, and multi-objective goals. For this recipe, we will define\na multi-objective goal:"]}),"\n",(0,o.jsx)(i.pre,{children:(0,o.jsx)(i.code,{children:'client.configure_optimization(objectives="-cost, utility")\n'})}),"\n",(0,o.jsxs)(i.p,{children:["By default, objectives are assumed to be maximized. If you want to minimize an\nobjective, you can prepend the objective with a ",(0,o.jsx)(i.code,{children:"-"})," sign."]}),"\n",(0,o.jsx)(i.h3,{id:"2-continue-with-iterating-over-trials-and-evaluating-them",children:"2. Continue with iterating over trials and evaluating them"}),"\n",(0,o.jsx)(i.p,{children:"Now that your experiment has been configured for a multi-objective optimization,\nyou can simply continue with iterating over trials and evaluating them as you\ntypically would."}),"\n",(0,o.jsx)(i.pre,{children:(0,o.jsx)(i.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,o.jsx)(i.h3,{id:"3-observe-optimal-parametrizations",children:"3. Observe optimal parametrizations"}),"\n",(0,o.jsxs)(i.p,{children:["You can now observe the optimal parametrizations by calling\n",(0,o.jsx)(i.code,{children:"get_optimal_pareto_frontier"}),". The function returns a list of tuples containing\nthe best parameters, their corresponding metric values, the most recent trial\nthat ran them, and the name of the best arm."]}),"\n",(0,o.jsx)(i.pre,{children:(0,o.jsx)(i.code,{className:"language-python",children:"frontier = client.get_pareto_frontier()\nfor parameters, metrics, trial_index, arm_name in frontier:\n ...\n"})}),"\n",(0,o.jsx)(i.h2,{id:"learn-more",children:"Learn more"}),"\n",(0,o.jsx)(i.p,{children:"Take a look at these other resources to continue your learning:"}),"\n",(0,o.jsxs)(i.ul,{children:["\n",(0,o.jsx)(i.li,{children:(0,o.jsx)(i.a,{href:"/docs/1.0.0/recipes/scalarized-objective",children:"Set scalarized-objective optimizations"})}),"\n",(0,o.jsx)(i.li,{children:(0,o.jsx)(i.a,{href:"/docs/1.0.0/recipes/outcome-constraints",children:"Set outcome constraints"})}),"\n"]})]})}function p(e={}){const{wrapper:i}={...(0,a.R)(),...e.components};return i?(0,o.jsx)(i,{...e,children:(0,o.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.