Skip to content

Commit

Permalink
Merge pull request #64 from MSDLLCpapers/bugfix
Browse files Browse the repository at this point in the history
Bugfix
  • Loading branch information
xuyuting authored Sep 17, 2024
2 parents 1a44adf + 3095d6b commit 805c9ab
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
6 changes: 3 additions & 3 deletions demo/Constrained multi-output min-max.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@
"metadata": {},
"outputs": [],
"source": [
"from obsidian.constraints import InConstraint_Generic"
"from obsidian.constraints import Linear_Constraint"
]
},
{
Expand All @@ -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)])"
]
},
{
Expand Down Expand Up @@ -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)"
Expand Down
12 changes: 5 additions & 7 deletions obsidian/plotting/plotly.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,13 +285,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]
Expand Down Expand Up @@ -321,7 +320,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,
Expand Down Expand Up @@ -387,8 +386,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]]
Expand Down

0 comments on commit 805c9ab

Please sign in to comment.