From 30dc2ec78fe19bba84bffd5393ade70f02d5784a Mon Sep 17 00:00:00 2001 From: Yuting Xu <12775874+xuyuting@users.noreply.github.com> Date: Tue, 17 Sep 2024 10:12:09 -0400 Subject: [PATCH 1/3] when X_ref input is None, use X_best_f. whether plot X_ref only depends on plotRef indicator --- obsidian/plotting/plotly.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/obsidian/plotting/plotly.py b/obsidian/plotting/plotly.py index d7fc8cf..e753252 100644 --- a/obsidian/plotting/plotly.py +++ b/obsidian/plotting/plotly.py @@ -280,13 +280,12 @@ def factor_plot(optimizer: Optimizer, # Create a dataframe of test samples for plotting n_samples = 100 if X_ref is None: - df_mean = optimizer.X_best_f - X_test = pd.concat([df_mean]*n_samples, axis=0).reset_index(drop=True) + X_ref = optimizer.X_best_f else: if not isinstance(X_ref, pd.DataFrame): raise TypeError('X_ref must be a DataFrame') - X_test = pd.concat([X_ref]*n_samples, axis=0).reset_index(drop=True) - + X_test = pd.concat([X_ref]*n_samples, axis=0).reset_index(drop=True) + # Vary the indicated column X_name = X_test.columns[feature_id] param_i = optimizer.X_space.params[feature_id] @@ -316,7 +315,7 @@ def factor_plot(optimizer: Optimizer, line={'color': obsidian_colors.teal}, name='Mean'), ) - if (X_ref is not None) and plotRef: + if plotRef: Y_pred_ref = optimizer.predict(X_ref, return_f_inv=not f_transform) Y_mu_ref = Y_pred_ref[y_name+('_t (pred)' if f_transform else ' (pred)')].values fig.add_trace(go.Scatter(x=X_ref.iloc[:, feature_id].values, y=Y_mu_ref, @@ -382,8 +381,7 @@ def surface_plot(optimizer: Optimizer, # Create a dataframe of test samples for plotting n_grid = 100 - df_mean = optimizer.X_best_f - X_test = pd.concat([df_mean]*(n_grid**2), axis=0).reset_index(drop=True) + X_test = pd.concat([optimizer.X_best_f]*(n_grid**2), axis=0).reset_index(drop=True) # Create a mesh grid which is necessary for the 3D plot X0_name = X_test.columns[feature_ids[0]] From c53198e9b943a779fbcf50a83bfc51ebe5f064c3 Mon Sep 17 00:00:00 2001 From: Yuting Xu <12775874+xuyuting@users.noreply.github.com> Date: Tue, 17 Sep 2024 10:16:01 -0400 Subject: [PATCH 2/3] revise the ineq_constraints arg according to the revised Linear_Constraint class --- demo/Constrained multi-output min-max.ipynb | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/demo/Constrained multi-output min-max.ipynb b/demo/Constrained multi-output min-max.ipynb index 7347362..c7a6a1d 100644 --- a/demo/Constrained multi-output min-max.ipynb +++ b/demo/Constrained multi-output min-max.ipynb @@ -1,5 +1,16 @@ { "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "import sys\n", + "sys.path.insert(0,'../')\n", + "sys.path" + ] + }, { "cell_type": "code", "execution_count": null, @@ -143,7 +154,7 @@ "metadata": {}, "outputs": [], "source": [ - "from obsidian.constraints import InConstraint_Generic" + "from obsidian.constraints import Linear_Constraint" ] }, { @@ -163,7 +174,7 @@ "source": [ "X_suggest, eval_suggest = campaign.optimizer.suggest(acquisition = [{'NEHVI':{'ref_point':[-350, -20]}}, 'SF'],\n", " # X1 + X2 <= 6, written as -X1 - X2 >= -6\n", - " ineq_constraints = [InConstraint_Generic(X_space, indices=[0,1], coeff=[-1,-1], rhs=-6)])" + " ineq_constraints = [Linear_Constraint(X_space, ind=[0,1], weights=[-1,-1], rhs=-6, equality=True)])" ] }, { @@ -210,7 +221,7 @@ "for iter in range(5):\n", " campaign.fit()\n", " X_suggest, eval_suggest = campaign.optimizer.suggest(acquisition = [{'NEHVI':{'ref_point':[-350, -20]}}, 'SF'],\n", - " ineq_constraints = [InConstraint_Generic(X_space, indices=[0,1], coeff=[-1,-1], rhs=-6)])\n", + " ineq_constraints = [Linear_Constraint(X_space, ind=[0,1], weights=[-1,-1], rhs=-6, equality=True)])\n", " y_iter = pd.DataFrame(simulator.simulate(X_suggest))\n", " Z_iter = pd.concat([X_suggest, y_iter, eval_suggest], axis=1)\n", " campaign.add_data(Z_iter)" From 3095d6b89b21ed5eabca4a7a26bf99b400eed555 Mon Sep 17 00:00:00 2001 From: Yuting Xu <12775874+xuyuting@users.noreply.github.com> Date: Tue, 17 Sep 2024 10:29:09 -0400 Subject: [PATCH 3/3] remove first cell --- demo/Constrained multi-output min-max.ipynb | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/demo/Constrained multi-output min-max.ipynb b/demo/Constrained multi-output min-max.ipynb index c7a6a1d..dade947 100644 --- a/demo/Constrained multi-output min-max.ipynb +++ b/demo/Constrained multi-output min-max.ipynb @@ -1,16 +1,5 @@ { "cells": [ - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "import sys\n", - "sys.path.insert(0,'../')\n", - "sys.path" - ] - }, { "cell_type": "code", "execution_count": null,