diff --git a/demo/Constrained multi-output min-max.ipynb b/demo/Constrained multi-output min-max.ipynb index 7347362..dade947 100644 --- a/demo/Constrained multi-output min-max.ipynb +++ b/demo/Constrained multi-output min-max.ipynb @@ -143,7 +143,7 @@ "metadata": {}, "outputs": [], "source": [ - "from obsidian.constraints import InConstraint_Generic" + "from obsidian.constraints import Linear_Constraint" ] }, { @@ -163,7 +163,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 +210,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)" 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]]