Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix #64

Merged
merged 3 commits into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -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]
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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]]
Expand Down
Loading