You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- Solve any scrambled Rubik's Cube configuration with ease.
11
+
- Find efficient algorithms, optimizing for either solution length or ergonomic move sequences.
12
+
- Incorporate solving capabilities into custom Rubik's Cube applications and tools.
13
+
- Analyze the statistical properties and solution space of the Rubik's Cube.
14
+
- Illustrate AI/ML concepts such as self-supervised learning and heuristic search.
35
15
36
16
## Installation
37
17
@@ -43,15 +23,17 @@ pip install -U alphacube
43
23
44
24
## Usage
45
25
46
-
### Basic
26
+
The first time you run `alphacube.load()`, the required model data will be downloaded and cached on your system for future use.
27
+
28
+
### Basic Usage
47
29
48
30
```python
49
31
import alphacube
50
32
51
-
# Load a trained DNN (default: "small" on cpu, "large" on GPU)
33
+
# Load a pre-trained model (defaults to "small" on CPU, "large" on GPU)
52
34
alphacube.load()
53
35
54
-
# Solve the cube using a given scramble sequence
36
+
# Solve a scramble
55
37
result = alphacube.solve(
56
38
scramble="D U F2 L2 U' B2 F2 D L2 U R' F' D R' F' U L D' F' D R2",
57
39
beam_width=1024, # Number of candidate solutions to consider at each depth of search
@@ -66,14 +48,14 @@ print(result)
66
48
>'solutions': [
67
49
>"D L D2 R' U2 D B' D' U2 B U2 B' U' B2 D B2 D' B2 F2 U2 F2"
68
50
> ],
69
-
>'num_nodes': 19744, # Total search nodes explored
70
-
>'time': 1.4068585219999659#Wall-clock time in seconds
51
+
>'num_nodes': 19744, # Total search nodes explored
52
+
>'time': 1.4068585219999659#Time in seconds
71
53
> }
72
54
>```
73
55
74
56
### Better Solutions
75
57
76
-
Increasing `beam_width`explores more candidate solutions, producing shorter (better) solve sequences at the cost of increased computation:
58
+
Increasing `beam_width`makes the search more exhaustive, yielding shorter solutions at the cost of extra compute:
77
59
78
60
```python
79
61
result = alphacube.solve(
@@ -96,14 +78,42 @@ print(result)
96
78
> }
97
79
>```
98
80
99
-
`beam_width` values between 1024-65536 typically offer a good trade-off between solution quality and speed. Tune according to your needs.
81
+
`beam_width` values between 1024and65536 typically offer a good trade-off between solution quality and speed. Tune according to your needs.
82
+
83
+
### GPU Acceleration
84
+
85
+
For maximal performance, use the `"large"` model on a GPU (orMPSif you have Mac).
86
+
87
+
```python
88
+
alphacube.load("large")
89
+
result = alphacube.solve(
90
+
scramble="D U F2 L2 U' B2 F2 D L2 U R' F' D R' F' U L D' F' D R2",
91
+
beam_width=65536,
92
+
)
93
+
print(result)
94
+
```
95
+
96
+
> **Output**
97
+
>
98
+
> ```python
99
+
> {
100
+
>'solutions': ["D F L' F' U2 B2 U F' L R2 B2 U D' F2 U2 R D'"],
101
+
>'num_nodes': 903448,
102
+
>'time': 20.46845487099995
103
+
> }
104
+
>```
105
+
106
+
> [!IMPORTANT]
107
+
> When running on a CPU, the default `"small"` model is recommended. The `"base"`and`"large"` models are significantly slower without a GPU.
108
+
109
+
Please refer to our [documentation](https://alphacube.dev/docs) for more, especially ["Getting Started"](https://alphacube.dev/docs/getting-started/index.html)
100
110
101
111
### Applying Ergonomic Bias
102
112
103
-
The `ergonomic_bias` parameter lets you specify the desirability of each move type, influencing the solver to favor certain moves over others:
113
+
The `ergonomic_bias` parameter can influence the solver to prefer certain types of moves, generating solutions that might be easier to perform.
104
114
105
115
```python
106
-
#Desirability scale: 0 (lowest) to 1 (highest)
116
+
#Define desirability for each move type (higher is more desirable)
107
117
ergonomic_bias = {
108
118
"U": 0.9, "U'": 0.9, "U2": 0.8,
109
119
"R": 0.8, "R'": 0.8, "R2": 0.75,
@@ -141,48 +151,18 @@ print(result)
141
151
> }
142
152
>```
143
153
144
-
### GPU Acceleration
145
-
146
-
For maximum performance, use the `"large"` model on a CUDA-enabled GPU (requires [PyTorch](https://pytorch.org/get-started/locally/)):
147
-
148
-
```python
149
-
alphacube.load("large")
150
-
result = alphacube.solve(
151
-
scramble="D U F2 L2 U' B2 F2 D L2 U R' F' D R' F' U L D' F' D R2",
152
-
beam_width=65536,
153
-
)
154
-
print(result)
155
-
```
156
-
157
-
> **Output**
158
-
>
159
-
> ```python
160
-
> {
161
-
>'solutions': ["D F L' F' U2 B2 U F' L R2 B2 U D' F2 U2 R D'"],
162
-
>'num_nodes': 903448,
163
-
>'time': 20.46845487099995
164
-
> }
165
-
>```
166
-
167
-
Using a GPU provides an order of magnitude speedup over CPUs, especially for larger models.
168
-
169
-
> [!IMPORTANT]
170
-
> When running AlphaCube _on a CPU_, it's generally recommended to stick with the `"small"` model, as the larger `"base"` and `"large"` models would take considerably more time to find solutions.
171
-
172
-
Please refer to our [documentation](https://alphacube.dev/docs) for more, especially ["Getting Started"](https://alphacube.dev/docs/getting-started/index.html)
173
-
174
154
## How It Works
175
155
176
-
At the heart of AlphaCube lies a deep learning method described in["Self-Supervision is All You Need for Solving Rubik's Cube" (TMLR'23)](https://openreview.net/forum?id=bnBeNFB27b), the official code of which is also available as [EfficientCube](https://github.com/kyo-takano/efficientcube).
156
+
At its core, AlphaCube uses the deep learning method from ["Self-Supervision is All You Need for Solving Rubik's Cube" (TMLR'23)](https://openreview.net/forum?id=bnBeNFB27b), the official code for which is available at [`kyo-takano/efficientcube`](https://github.com/kyo-takano/efficientcube).
177
157
178
-
The 3provided models (`"small"`, `"base"`, and`"large"`) are **_compute-optimally trained_**in the Half-Turn Metric, This means the model sizes are scaled in tandem with the amount of training data to maximize prediction accuracy for a given computational budget. See Section 7 of the above-mentioned paperfor details.
158
+
The provided models (`"small"`, `"base"`, and`"large"`) are **compute-optimally trained**in the Half-Turn Metric. This means model size and training data were scaled together to maximize prediction accuracy for a given computational budget, as detailed inthe paper.
179
159
180
160
> [!NOTE]
181
-
>**📖 Read more: ["How It Works"](https://alphacube.dev/docs/how-it-works/index.html)**
161
+
>**📖 Read more: ["How It Works"](https://alphacube.dev/docs/how-it-works)** on our documentation site.
182
162
183
163
## Contributing
184
164
185
-
You are more than welcome to collaborate on AlphaCube. Please read our [Contributing Guide](https://github.com/kyo-takano/alphacube/blob/main/CONTRIBUTING.md) to get started.
165
+
You are welcome to collaborate on AlphaCube! Please read our [Contributing Guide](https://github.com/kyo-takano/alphacube/blob/main/CONTRIBUTING.md) to get started.
0 commit comments