Skip to content

Commit

Permalink
Merge pull request #9 from asanolab/add_ml_interfaces
Browse files Browse the repository at this point in the history
add ml_interfaces
  • Loading branch information
yuki-asano authored Feb 6, 2025
2 parents 9ba1a54 + d68b922 commit 86a4e73
Show file tree
Hide file tree
Showing 46 changed files with 182 additions and 283 deletions.
13 changes: 0 additions & 13 deletions bayesopt_ros_bridge/README.md

This file was deleted.

11 changes: 0 additions & 11 deletions bayesopt_ros_bridge/bayesopt_ros_bridge/CMakeLists.txt

This file was deleted.

3 changes: 0 additions & 3 deletions bayesopt_ros_bridge/combo_ros_bridge/.gitignore

This file was deleted.

28 changes: 0 additions & 28 deletions bayesopt_ros_bridge/combo_ros_bridge/CMakeLists.txt

This file was deleted.

26 changes: 0 additions & 26 deletions bayesopt_ros_bridge/combo_ros_bridge/data/test_candidates.csv

This file was deleted.

17 changes: 0 additions & 17 deletions bayesopt_ros_bridge/combo_ros_bridge/package.xml

This file was deleted.

13 changes: 0 additions & 13 deletions bayesopt_ros_bridge/combo_ros_bridge/setup.py

This file was deleted.

4 changes: 0 additions & 4 deletions bayesopt_ros_bridge/physbo_ros_bridge/.gitignore

This file was deleted.

28 changes: 0 additions & 28 deletions bayesopt_ros_bridge/physbo_ros_bridge/LICENSE

This file was deleted.

59 changes: 0 additions & 59 deletions bayesopt_ros_bridge/physbo_ros_bridge/README.md

This file was deleted.

This file was deleted.

18 changes: 0 additions & 18 deletions bayesopt_ros_bridge/physbo_ros_bridge/package.xml

This file was deleted.

13 changes: 0 additions & 13 deletions bayesopt_ros_bridge/physbo_ros_bridge/setup.py

This file was deleted.

Empty file.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,39 @@
# combo_ros_bridge
# bayesopt_interfaces

combo_ros_bridge is a package that includes a bridge software to commanding COMBO through ROS msgs.
## PHYSBO
PHYSBO is an optimization tools for PHYsics based on Bayesian Optimization

### doc
https://www.pasums.issp.u-tokyo.ac.jp/physbo/en

### source code
https://github.com/issp-center-dev/PHYSBO


## Install
- PHYSBO requires python3
```
sudo apt install python3-pip
sudo pip3 install rospkg
sudo pip3 install numpy
sudo pip3 install pandas
sudo pip3 install Cython
sudo pip3 install matplotlib
```

- install physbo
- https://github.com/issp-center-dev/PHYSBO#install


## Usage
### physbo_interface
- test program node for only PHYSBO
- load test candidates (examples/data/candidates.csv)
- visualize mean, std and scores(acquisition functions)
```
cd examples
./test_physbo_interface.py
```


## COMBO
Expand Down Expand Up @@ -44,19 +77,3 @@ see above link for latest information
cd scripts
./test_combo_interface.py
```

### combo_ros_bridge
- bridge node for communication between COMBO and ROS system
- publish COMBO data to ROS system (e.g. next_param)
- subscribe evaluation value or flags to write the value to COMBO
```
roslaunch combo_ros_bridge combo_ros_bridge.launch
```

### memo
- Result and history data are saved in the dir specified by `policy_save_dir` (`data` dir as defalult).
- if you want to continue an experiment with the previous/existing data, `use_saved_policy=True` should be used.
- The arg with `False` does not consider the existing data and learning history.
- However, COMBO is not recommended when you want to continue experiments from existing data due to the following issue which was fixed in PHYSBO.
- https://github.com/issp-center-dev/PHYSBO/issues/44
- PHYSBO is a candidate for this purpose.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import pandas as pd
import physbo
import matplotlib.pyplot as plt
from combo_ros_bridge.combo_interface import ComboInterface
from .combo_interface import ComboInterface


class PhysboInterface(ComboInterface):
Expand Down
10 changes: 10 additions & 0 deletions ml_interfaces/bayesopt_interfaces/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from setuptools import setup, find_packages

setup(
name='bayesopt_interfaces',
version='0.1.0',
author='Yuki Asano',
author_email='[email protected]',
description='',
packages=find_packages()
)
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,17 @@

import os
import random
import sys

import combo
from combo_ros_bridge.combo_interface import ComboInterface
from bayesopt_if.combo_interface import ComboInterface


def main():
# dir setting
candidates_path = '../data/test_candidates.csv'
policy_load_dir = '../data/test_result'
policy_save_dir = '../data/test_result'
candidates_path = './data/candidates.csv'
policy_load_dir = './data/load'
policy_save_dir = './data/result'

# Generate combo
ci = ComboInterface(combo, candidates_path, policy_load_dir, policy_save_dir, use_saved_policy=False)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@

import csv
import os
from physbo_ros_bridge.physbo_interface import PhysboInterface
import sys

from bayesopt_if.physbo_interface import PhysboInterface


def get_data_from_result_list(index):
Expand All @@ -21,7 +23,7 @@ def main():
policy_save_dir = './data/result'

# Generate physbo
pi = PhysboInterface(candidates_path, policy_load_dir, policy_save_dir, use_saved_policy=False, search_score='PI')
pi = PhysboInterface(candidates_path, policy_load_dir, policy_save_dir, use_saved_policy=False, search_score='EI')
pi.start_bayesopt()

# Procedure of search and register data to PHYSBO
Expand All @@ -34,7 +36,7 @@ def main():
result = get_data_from_result_list(pi.get_next_index()) # get result/evaluation data from experiment. (Result list is used for this test program).
pi.write_result(result) # write result to PHYSBO
# Search with Bayesian optimization
for i in range(17):
for i in range(3):
pi.search_next_param_bayes()
result = get_data_from_result_list(pi.get_next_index())
pi.write_result(result)
Expand Down
5 changes: 5 additions & 0 deletions ml_interfaces/bayesopt_ros_bridge/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
*.~
*.pyc
examples/data/chosen_actions.csv
examples/data/chosed_actions.csv
examples/data/result
Loading

0 comments on commit 86a4e73

Please sign in to comment.