{ "cells": [ { "cell_type": "markdown", "id": "6f01675f-cd1a-4712-9ca4-3cc1dbbd9056", "metadata": { "tags": [] }, "source": [ "## Multiple Objective Optimization" ] }, { "cell_type": "markdown", "id": "567ea5b7-f871-4ce3-8970-6f82728de9bf", "metadata": { "collapsed": true, "jupyter": { "outputs_hidden": true }, "tags": [] }, "source": [ "An example that computes a Pareto-optimal point of a benchmark function using Chebyshev weights is given in the\n", "following:" ] }, { "cell_type": "code", "execution_count": null, "id": "cae5fecd-f30c-4a5c-966e-c14008a1af8a", "metadata": {}, "outputs": [], "source": [ "from entmoot import Enting, ProblemConfig, GurobiOptimizer, PyomoOptimizer\n", "from entmoot.benchmarks import (\n", " build_multi_obj_categorical_problem,\n", " eval_multi_obj_cat_testfunc,\n", ")\n", "\n", "# define problem\n", "problem_config = ProblemConfig(rnd_seed=73)\n", "# number of objectives\n", "number_objectives = 2\n", "build_multi_obj_categorical_problem(problem_config, n_obj=number_objectives)\n", "\n", "# sample data\n", "rnd_sample = problem_config.get_rnd_sample_list(num_samples=20)\n", "testfunc_evals = eval_multi_obj_cat_testfunc(rnd_sample, n_obj=number_objectives)" ] }, { "cell_type": "markdown", "id": "180e8e4b", "metadata": {}, "source": [ "Model parameters can be defined in a few ways:" ] }, { "cell_type": "code", "execution_count": null, "id": "63286741", "metadata": {}, "outputs": [], "source": [ "from entmoot import EntingParams, UncParams, TrainParams, TreeTrainParams\n", "\n", "# all three of the below `params` are valid arguments for Enting\n", "params = {\"unc_params\": {\"dist_metric\": \"l1\", \"acq_sense\": \"exploration\"}}\n", "params = EntingParams(**params)\n", "params = EntingParams(unc_params=UncParams(dist_metric=\"l1\", acq_sense=\"exploration\"))\n", "\n", "enting = Enting(problem_config, params=params)\n", "# fit tree ensemble\n", "enting.fit(rnd_sample, testfunc_evals)" ] }, { "cell_type": "markdown", "id": "7b88056d-e265-4097-9711-6bdcec723b44", "metadata": {}, "source": [ "### Gurobi Version" ] }, { "cell_type": "code", "execution_count": null, "id": "311c88fa-f757-44f3-8ae5-555f715fc1b4", "metadata": { "tags": [] }, "outputs": [], "source": [ "# Build GurobiOptimizer object and solve optimization problem\n", "params_gurobi = {\"MIPGap\": 0}\n", "opt_gur = GurobiOptimizer(problem_config, params=params_gurobi)\n", "res_gur = opt_gur.solve(enting)" ] }, { "cell_type": "markdown", "id": "ab64ab28-9578-43ea-8943-821637681acf", "metadata": {}, "source": [ "### Pyomo Version" ] }, { "cell_type": "code", "execution_count": null, "id": "cbf5ea4c-fe6b-4f29-8b35-ae88cfdb2379", "metadata": {}, "outputs": [], "source": [ "# Build PyomoOptimizer object with GLPK as solver and solve optimization problem\n", "params_pyo = {\"solver_name\": \"gurobi\"}\n", "opt_pyo = PyomoOptimizer(problem_config, params=params_pyo)\n", "res_pyo = opt_pyo.solve(enting)" ] }, { "cell_type": "code", "execution_count": null, "id": "772c3b0f-c885-43bf-9962-042a3da71756", "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.10.13" } }, "nbformat": 4, "nbformat_minor": 5 }