# HW simulator of SA
**HW (hardware)** simulator of SA (Simulated Annealing)
## What's this?
* **SA-based annealer**; Ising processor (or QUBO solver) that can address a "fully-connected" model
* **HW simulator** which imitates the behavior of HW annealer (*now under development*)
* Including **HW-specific (or HW-friendly) operations** (fixed-point operations, approximated sigmoid operation, and pseudo random number generator)
## Requirements
* python3 (numpy, argparse, tqdm)
## Simulator types
|No.|Name|Input|Algorithm|
|:----|:---------|:-----|:-----|
|(1)|`SA_simulator_Ising.py`|Ising model|Typical SA|
|(2)|`SA_simulator_QUBO.py`|QUBO|Typical SA|
|(3)|`ConstrainedSA_simulator_QUBO.py`|QUBO|Transition-constrained SA|
* The simulator (3), transion-constrained SA, works in such a way as to always satisfy 1-dimensional one-hot constraints.
* When switching to check mode by an option `-c`, it works in the same manner as the simulator (2) but also counts the number of one-hot constraint violations.
## How to use
#### (a) Read in a pre-defined model from a file
```
python3 SA_simulator_Ising.py -i FILE(.dat) [-O 600] [-I 4000] [-S 20.0] [-E 0.5] [-s 12345] [-d] [-v]
python3 SA_simulator_QUBO.py -i FILE(.dat) [-O 100] [-I 1000] [-S 100.0] [-E 0.1] [-s 12345] [-d] [-v]
python3 ConstrainedSA_simulator_QUBO.py -i FILE(.dat) -C FILE(.con) [-O 100] [-I 1000] [-S 100.0] [-E 0.1] [-s 12345] [-d] [-v]
```
#### (b) Generate a random model
```
python3 SA_simulator_Ising.py [-n 256] [-O 600] [-I 4000] [-S 20.0] [-E 0.5] [-s 12345] [-d] [-v]
python3 SA_simulator_QUBO.py [-n 256] [-O 100] [-I 1000] [-S 100.0] [-E 0.1] [-s 12345] [-d] [-v]
```
## Input argument
#### Model information
|Option|Description|Default|Support|
|:----:|:---------|:-----:|:-----:|
|`-i`|Model file (Only for (a))|None|ALL|
|`-C`|One-hot constraint file|None|(3)|
|`-n`|#. of spins (Only for (b))|256|(1), (2)|
* The simulator (3) always require a pair of model file (.dat) and one-hot constraint file (.con).
#### Annealing parameters
|Option|Description|Default (Ising model)|Default (QUBO)|
|:----:|:---------|:-----:|:-----:|
|`-O`|#. of outer loops|600|100|
|`-I`|#. of inner loops|4000|1000|
|`-S`|Initial temperature|20.0|100.0|
|`-E`|Final temperature|0.5|0.1|
|`-s`|Seed value|12345|12345|
#### Other options
|Option|Description|Support|
|:----:|:---------|:-----:|
|`-d`|Output a log file (`./energy.log`) recording energy transition|ALL|
|`-v`|Output a log file (`./var.log`) recording final state|ALL|
|`-c`|Switch to check mode which works as typical SA but counts the number of one-hot constraint violations|(3)|
## Input file format
### Model file
* The 1st line shows #. of spins.
* Couplings and biases are specified from the 2nd line (32bit integer).
* Constant value is specified in the last line.
#### Example
```
4
0 0 -1
0 1 2
0 2 1
1 1 -1
1 3 1
2 2 -1
2 3 2
3 3 -1
2
```
<img width="600" alt="sample_model_01" src="https://user-images.githubusercontent.com/71317410/99347463-8c7e4880-28da-11eb-82b2-75db0496599a.png">
### One-hot constraint file
* The 1st line shows #. of one-hot constraint sets.
* Pairs of start and end indices are specified from the 2nd line.
#### Example
```
2
0 1
2 3
```
<img width="300" alt="sample_model_02" src="https://user-images.githubusercontent.com/71317410/99346351-c3069400-28d7-11eb-8ecb-fc81756d0696.png">
## Output examples
#### Simulator (1)
```
Model file: Ising_model/G1_Ising.dat
----------------------------------------
-- Model & Parameters ------------------
----------------------------------------
N = 800
#Loops = 600 x 4000
T(set) = 20.0 --> 0.5
T(real) = 20.0 --> 0.500003628459082
seed = 12345
----------------------------------------
100%|████████████████████████████████| 600/600 [00:30<00:00, 19.58it/s]
----------------------------------------
-- Result ------------------------------
----------------------------------------
H(init) = 118
H(fin) = -4072
----------------------------------------
```
#### Simulator (2)
```
Model file: QUBO_problem/2-FullIns_3_QUBO_5.dat
----------------------------------------
-- Model & Parameters ------------------
----------------------------------------
N = 260
#Loops = 100 x 1000
T(set) = 100.0 --> 0.1
T(real) = 100.0 --> 0.10000066578831485
seed = 12345
----------------------------------------
100%|████████████████████████████████| 100/100 [00:01<00:00, 80.17it/s]
----------------------------------------
-- Result ------------------------------
----------------------------------------
H(init) = 662
H(fin) = 6
----------------------------------------
```
#### Simulator (3)
```
Model file: QUBO_problem/2-FullIns_3_QUBO_5.dat
One-hot table (size: 52)
[(0, 4), (5, 9), ... , (250, 254), (255, 259)]
----------------------------------------
-- Model & Parameters ------------------
----------------------------------------
N = 260
#Loops = 100 x 1000
T(set) = 100.0 --> 0.1
T(real) = 100.0 --> 0.10000066578831485
seed = 12345
----------------------------------------
100%|████████████████████████████████| 100/100 [00:02<00:00, 39.72it/s]
----------------------------------------
-- Result ------------------------------
----------------------------------------
H(init) = 201
H(fin) = 0
#. One-hot constraint violations = 0
----------------------------------------
```
#### Simulator (3): check mode
```
Model file: QUBO_problem/2-FullIns_3_QUBO_5.dat
One-hot table (size: 52)
[(0, 4), (5, 9), ... , (250, 254), (255, 259)]
----------------------------------------
-- Model & Parameters ------------------
----------------------------------------
N = 260
#Loops = 100 x 1000
T(set) = 100.0 --> 0.1
T(real) = 100.0 --> 0.10000066578831485
seed = 12345
----------------------------------------
100%|████████████████████████████████| 100/100 [00:01<00:00, 79.07it/s]
----------------------------------------
-- Result ------------------------------
----------------------------------------
H(init) = 662
H(fin) = 6
#. One-hot constraint violations = 0
----------------------------------------
```
## Acknowledgement
This work is supported by the MITOU Target program from Information-technology Promotion Agency, Japan (IPA).
没有合适的资源?快使用搜索试试~ 我知道了~
SA(模拟 退火)HW(硬件)模拟器_python_代码_下载
共12个文件
dat:4个
md:3个
py:3个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 86 浏览量
2022-06-21
19:05:11
上传
评论 1
收藏 119KB ZIP 举报
温馨提示
基于 SA 的退火炉;可以解决“全连接”模型的 Ising 处理器(或 QUBO 求解器) 模仿硬件退火器行为的硬件模拟器(正在开发中) 包括硬件特定(或硬件友好)操作(定点操作、近似 sigmoid 操作和伪随机数生成器) 基于 SA 的退火炉;可以解决“全连接”模型的 Ising 处理器(或 QUBO 求解器) 模仿硬件退火器行为的硬件模拟器(正在开发中) 包括硬件特定(或硬件友好)操作(定点操作、近似 sigmoid 操作和伪随机数生成器)
资源推荐
资源详情
资源评论
收起资源包目录
SA-HW-simulator-master.zip (12个子文件)
SA-HW-simulator-master
README.md 6KB
SA_simulator_Ising.py 11KB
SA_simulator_QUBO.py 11KB
ConstrainedSA_simulator_QUBO.py 13KB
Ising_model
README.md 378B
G3_Ising.dat 201KB
G1_Ising.dat 201KB
QUBO_problem
README.md 462B
myciel3_QUBO_4.con 64B
2-FullIns_3_QUBO_5.con 375B
2-FullIns_3_QUBO_5.dat 16KB
myciel3_QUBO_4.dat 1KB
共 12 条
- 1
资源评论
快撑死的鱼
- 粉丝: 1w+
- 资源: 9154
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功