Skip to content

Commit

Permalink
[FEATURE] Added copyright notice
Browse files Browse the repository at this point in the history
  • Loading branch information
JuliuszZiomek committed May 24, 2023
1 parent 378fa34 commit 5f227d0
Show file tree
Hide file tree
Showing 8 changed files with 189 additions and 43 deletions.
14 changes: 9 additions & 5 deletions RDUCB/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@


This repository accompanies a [ICML 2023 publication](https://arxiv.org/pdf/2301.12844.pdf) by Juliusz Ziomek and Haitham Bou-Ammar.
The repository is largely based on code from [High-Dimensional Bayesian Optimization via Tree-Structured Additive Models ](https://github.com/eric-vader/HD-BO-Additive-Models), as such the code in this repository is released under the original MIT license (in the LICENSE file) giving copyright to Eric Han, except for the parts that have been added or substantially modified, which are released under MIT licence giving copyrights to Huawei Technologies Co., Ltd. Such parts are clearly marked in code by comments.

## Acknowledgements

Expand Down Expand Up @@ -35,9 +36,12 @@ Minimum System requirements:
Prepare your environment:

1. If you don't have it already, [Install Conda](https://docs.conda.io/projects/conda/en/latest/user-guide/install/linux.html)
2. (Optional) Run `bash data/setup.sh` to download data from [NAS Benchmarks](https://github.com/automl/nas_benchmarks) and into your home directory. You may skip this step if you are not running lpsolve and NAS-Bench-101 datasets.
3. [Install MLflow](https://mlflow.org/) either on your system or in the base environment of Conda - `pip install mlflow`
4. Build and test environment by using the command `mlflow run .` (this may take a while).
2. [Install MLflow](https://mlflow.org/) either on your system or in the base environment of Conda - `pip install mlflow`
3. Build and test environment by using the command `mlflow run .` (this may take a while).

Optional steps:
1. (Optional) Run `bash data/setup.sh` to download data from [NAS Benchmarks](https://github.com/automl/nas_benchmarks) and into your home directory. You may skip this step if you are not running lpsolve and NAS-Bench-101 datasets.
2. (Optional) Run `pip install -U pandas matplotlib seaborn` in your base environment for plotting the results. You may skip this step if you do not need the plotting script.

## Running experiments from Paper

Expand All @@ -50,9 +54,9 @@ mlflow run . -P param_file=config/LassoBench/rducb.yml
All the parameters of the run should be specified in the `.yml` file. However, to facilitate running batch jobs, one can include command line arguments to override the seed or subproblem. For example:

```
mlflow run . -P param_file=config/LassoBench/rducb.yml -P seed=1 -P sub_benchmark="pick_data:leukemia"
mlflow run . -P param_file=config/LassoBench/rducb.yml -P seed=1 -P sub_benchmark="pick_data:diabetes"
```
will run the experiment as specified in `config/LassoBench/rducb.yml` but will overwrite the seed to 1 and pick_data to leukemia. See an example of workflow in `example.sh`
will run the experiment as specified in `config/LassoBench/rducb.yml` but will overwrite the seed to 1 and pick_data to diabetes. See an example of workflow in `example.sh`


## Visualising the results
Expand Down
21 changes: 7 additions & 14 deletions RDUCB/config/default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,11 @@ algorithm_type:
noise_var: 0.01
param_n_iter: 16
data_type:
Synthetic:
data_random_seed: 3
dimension: 15
fn_noise_var: 0.0225
graph_type: StarGraph
grid_params:
domain_lower: 0.0
domain_upper: 1.0
grid_size: 150
kernel_params:
lengthscale: 0.2
variance: 1.0

n_iter: 1000
Hpolib:
aug_dimension: 14
data_random_seed: 2
fn_noise_var: 0
grid_size: 150
hpo_fn: Hartmann6Aug
n_iter: 10
n_rand: 10
2 changes: 1 addition & 1 deletion RDUCB/example.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
mlflow run . -P param_file=config/examples/example1_random.yml -P seed=0
mlflow run . -P param_file=config/examples/example1_random.yml -P seed=1

# Run two seeds of RDUCBon example1 problem (Rosenbrock)
# Run two seeds of RDUCB on example1 problem (Rosenbrock)
mlflow run . -P param_file=config/examples/example1_rducb.yml -P seed=0
mlflow run . -P param_file=config/examples/example1_rducb.yml -P seed=1

Expand Down
2 changes: 1 addition & 1 deletion RDUCB/hdbo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ dependencies:
- ConfigSpace==0.4.11 # this works with glibc 2.12 which xgpa is on
- noisyopt
- git+https://github.com/eric-vader/HPOlib2.git#egg=hpolib2
#- git+https://github.com/ksehic/LassoBench.git
- git+https://github.com/ksehic/LassoBench.git
- tensorflow==2.2.0
# - ./tensorflow-2.2.0-cp38-cp38-linux_x86_64.whl
# - cudnn=7.6.5=cuda10.1_0
Expand Down
24 changes: 24 additions & 0 deletions RDUCB/hdbo/algorithms.py
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,30 @@ def FnOptimizer(self):
return function_optimizer.Tree

class RDUCB(BayesianOptimization, metaclass=Algorithm):
"""
MIT License
Copyright (c) 2023 Huawei Technologies Co., Ltd
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
"""
__metaclass__ = Algorithm
def __init__(self, **kwargs):
self.random_graph = True
Expand Down
96 changes: 96 additions & 0 deletions RDUCB/hdbo/datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -709,6 +709,30 @@ def eval(self, x):
return objective
# =======================================================================
class LassoBenchLoader(Loader, metaclass=LassoBenchlib):
"""
MIT License
Copyright (c) 2023 Huawei Technologies Co., Ltd
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
"""
def __init__(self, pick_data, grid_size, fidelity, fixed_dims=0, **kwargs):

self.f = ExecuteLassoBench(pick_data, grid_size, fidelity, fixed_dims)
Expand All @@ -719,6 +743,30 @@ def load(self):

# Function to execute LP Solve
class ExecuteLassoBench(Function):
"""
MIT License
Copyright (c) 2023 Huawei Technologies Co., Ltd
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
"""
def __init__(self, pick_data, grid_size, fidelity=0, fixed_dims=0):
import LassoBench

Expand Down Expand Up @@ -774,6 +822,30 @@ def eval(self, X):
return self.hpo_fn(x)

class Adversarial(Loader, metaclass=Simple):
"""
MIT License
Copyright (c) 2023 Huawei Technologies Co., Ltd
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
"""
def __init__(self, grid_size, **kwargs):
Loader.__init__(self, "Adversarial", **kwargs)
logging.info("Using Adversarial function")
Expand All @@ -783,6 +855,30 @@ def load(self):
return AdversairalFunction(self.domain), self.soln

class AdversairalFunction(Function):
"""
MIT License
Copyright (c) 2023 Huawei Technologies Co., Ltd
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
"""
def __init__(self, domain):
Function.__init__(self, domain)
self.graph = None
Expand Down
46 changes: 25 additions & 21 deletions RDUCB/hdbo/graph_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,30 @@ def debug_graph(G):


def get_random_graph(size, connection_draws=1):
"""
MIT License
Copyright (c) 2023 Huawei Technologies Co., Ltd
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
"""

graph = nx.empty_graph(size)
disjoint_set = DisjointSet()
Expand All @@ -95,24 +119,4 @@ def get_random_graph(size, connection_draws=1):
return graph

def sigmoid(x):
return 1 / (1 + math.exp(-x))


if __name__ == "__main__":
import matplotlib.pyplot as plt
for i in range(100):
test_graph = get_random_graph(20, 5)
nx.draw_networkx(test_graph)
try:
nx.find_cycle(test_graph)
has_cycles = True
except nx.exception.NetworkXNoCycle:
has_cycles = False
print(i, test_graph.edges())
if has_cycles:
pass
else:
print('No cycles')

plt.savefig(f'test_graph{i}')
plt.clf()
return 1 / (1 + math.exp(-x))
27 changes: 26 additions & 1 deletion RDUCB/plot.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,28 @@
"""
MIT License
Copyright (c) 2023 Huawei Technologies Co., Ltd
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
"""

import pandas as pd
import seaborn as sns
import os
Expand Down Expand Up @@ -76,7 +101,7 @@ def get_matching_runs(data_type, data_name, exehashs, ignore_error=False, run_le
if type(data) == type(None):
data = new_data
else:
data = data.append(new_data, ignore_index=True)
data = pd.concat([data, new_data], ignore_index=True)

print(f'Found {run_no} runs for {name}')

Expand Down

0 comments on commit 5f227d0

Please sign in to comment.