-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16 from UBC-CS/bp
objective function with known lipschitz constant
- Loading branch information
Showing
11 changed files
with
128 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,6 @@ numpy == 1.14.2 | |
scipy == 0.19.1 | ||
scikit-learn == 0.19.1 | ||
pandas == 0.23.1 | ||
matplotlib == 2.1.2 | ||
tqdm == 4.23.4 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
## Resources | ||
|
||
[Global optimization of Lipschitz functions](https://arxiv.org/abs/1703.02628). | ||
|
||
* C. Malherbe and N. Vayatis. "Global optimization of Lipschitz functions". ICML. 2314 - 2323. (2017) | ||
|
||
[BayesOpt](https://arxiv.org/abs/1405.7430) | ||
|
||
* R. Martinez-Cantin. BayesOpt: {A} Bayesian Optimization Library for Nonlinear Optimization, Experimental Design and Bandits. CoRR. 1405.7430. (2014) | ||
|
||
[CMA-ES - Covariance Matrix Adaptation Evolution Strategy](https://www.researchgate.net/publication/227050324_The_CMA_Evolution_Strategy_A_Comparing_Review) | ||
|
||
* N. Hansen. The CMA Evolution Strategy: A Comparing Review. In J.A. Lozano, P. Larrañaga, I. Inza and E. Bengoetxea (Eds.). Towards a new evolutionary computation. Advances in estimation of distribution algorithms. Springer, pp. 75-102 (2006). | ||
|
||
**IS ABOVE POINTING AT THE CORRECT PAPER?** | ||
|
||
[CRS - Controlled Random Search with Local Mutation](https://link.springer.com/article/10.1007/s10957-006-9101-0) | ||
|
||
* P. Kaelo and M. M. Ali, "Some variants of the controlled random search algorithm for global optimization," J. Optim. Theory Appl. 130 (2), 253-264 (2006). | ||
|
||
[DIRECT](https://link.springer.com/article/10.1007/BF00941892) | ||
|
||
* D. R. Jones, C. D. Perttunen, and B. E. Stuckmann, "Lipschitzian optimization without the lipschitz constant," J. Optimization Theory and Applications, vol. 79, p. 157 (1993). | ||
|
||
[MLSL - Multi-Level Single-Linkage](https://link.springer.com/article/10.1007/BF02592071) | ||
|
||
* A. H. G. Rinnooy Kan and G. T. Timmer, "Stochastic global optimization methods," Mathematical Programming, vol. 39, p. 27-78 (1987). (Actually 2 papers — part I: clustering methods, p. 27, then part II: multilevel methods, p. 57.) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
#!usr/bin/env python | ||
|
||
# Script to plot the lipschitz estimates | ||
# Usage: | ||
# - python plot_k.py inputfile 1 myplot | ||
|
||
import argparse | ||
import pickle | ||
import numpy as np | ||
import matplotlib | ||
matplotlib.use('Agg') | ||
import matplotlib.pyplot as plt | ||
|
||
def main(results, lipschitz_constant, filename, | ||
optimizer='AdaLIPO', q=(5,95), figsize=(10,5)): | ||
|
||
if len(results.keys()) > 1: | ||
raise RuntimeError('Inputfile must be simulation using single objective function!') | ||
|
||
func_name = list(results.keys())[0] | ||
d = results[func_name][optimizer][0]['x'].shape[1] | ||
num_sim = len(results[func_name][optimizer]) | ||
num_iter = len(results[func_name][optimizer][0]['k']) | ||
|
||
k_results = np.zeros((num_sim, num_iter)) | ||
|
||
for sim in range(num_sim): | ||
k_results[sim,:] = results[func_name][optimizer][sim]['k'] | ||
|
||
median_loss = np.median(a=k_results, axis=0) | ||
upper_loss = np.percentile(a=k_results, q=q[1], axis=0) | ||
lower_loss = np.percentile(a=k_results, q=q[0], axis=0) | ||
yerr = np.abs(np.vstack((lower_loss, upper_loss)) - median_loss) | ||
|
||
fig, ax = plt.subplots() | ||
fig.set_size_inches(figsize[0], figsize[1]) | ||
|
||
ax.plot(range(1,num_iter+1), [lipschitz_constant]*num_iter, color='red') | ||
|
||
ax.plot(range(1,num_iter+1), median_loss) | ||
ax.errorbar( | ||
x=range(1,num_iter+1), | ||
y=median_loss, | ||
yerr=yerr, | ||
linestyle='None', | ||
alpha=0.5, | ||
capsize=200/num_iter | ||
) | ||
ax.set(xlabel='Iteration Number', ylabel='Lipschitz Constant') | ||
|
||
plt.legend(['True', 'Estimated', '90 % Error bars']) | ||
plt.title('Convergence of Lipschitz Constant Estimate of {}-d Paraboloid'.format(d)) | ||
if filename: | ||
fig = ax.get_figure() | ||
fig.savefig(filename) | ||
else: | ||
plt.show() | ||
|
||
if __name__ == '__main__': | ||
|
||
parser = argparse.ArgumentParser() | ||
parser.add_argument('inputfile', type=str) | ||
parser.add_argument('--K', type=float, default=None) | ||
parser.add_argument('--filename', type=str, default=None) | ||
args = parser.parse_args() | ||
|
||
with open(args.inputfile, 'rb') as f: | ||
results = pickle.load(f) | ||
|
||
main(results, args.K, args.filename) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters