DeepCubeA is a powerful framework designed for solving various combinatorial puzzles like the Rubik’s Cube, 15-puzzle, Lights Out, and more using Deep Reinforcement Learning and A* search algorithms. In this guide, we’ll walk you through the setup process, training, and enhancing the performance of DeepCubeA to effectively tackle these puzzles.
Setup Instructions
- Ensure you have Python 3.7.2 installed on your machine.
- Check the requirements.txt for the necessary Python packages.
- Install these packages using pip or conda.
- Navigate to the DeepCubeA directory and execute the following command to set up the environment:
source setup.sh
Training and A* Search
To train DeepCubeA and implement A* search, follow these steps:
Training Commands
Use the following command format to train your model for the 15-puzzle:
python ctg_approxavi.py --env puzzle15 --states_per_update 50000000 --batch_size 10000 --nnet_name puzzle15 --max_itrs 1000000 --loss_thresh 0.1 --back_max 500 --num_update_procs 30
Solving with A* Search
After the training process, utilize A* search to solve the puzzle:
python search_methodsastar.py --states datapuzzle15testdata_0.pkl --model saved_modelspuzzle15current --env puzzle15 --weight 0.8 --batch_size 20000 --results_dir resultspuzzle15 --language cpp --nnet_batch_size 10000
Comparing Solutions
If you want to evaluate the effectiveness of your solution, compare it to the shortest path:
python scriptscompare_solutions.py --soln1 datapuzzle15testdata_0.pkl --soln2 resultspuzzle15results.pkl
Improving Results
To enhance your model’s performance during training and search, consider the following adjustments:
- Increase
--batch_size
and--states_per_update
for better results during approximate value iteration (AVI). - Lower the
--loss_thresh
to trigger updates more frequently. - Add states encountered through greedy best-first search (GBFS) to the training set.
- Adjust the weight on path cost during A* search to improve outcomes.
Creating New Problem Solvers
DeepCubeA can be adapted to solve new puzzles by implementing your own environment. Follow these steps:
- Implement the abstract methods found in
environments/environment_abstract.py
. - Edit
utils/env_utils.py
to register your environment. - Test the implementation using
tests/timing_test.py
to ensure everything functions properly.
Parallelism in Training
To speed up the training and solving processes, leverage multi-CPU and multi-GPU setups:
- Set the number of workers for approximate value iteration using
--num_update_procs
. - Control the number of GPUs by setting the
CUDA_VISIBLE_DEVICES
environment variable, for example:export CUDA_VISIBLE_DEVICES=0,1,2,3
Memory Management
While acquiring training data and solving with A* search, you may need to reduce the batch size if memory issues arise. Adjust the following settings:
--update_nnet_batch_size
foravi.py
--nnet_batch_size
forastar.py
Compiling C++ for A* Search
If you’re interested in utilizing C++ for A* search, compile the necessary files by navigating to the cpp
directory and running:
cd cpp
make
If you face challenges with the C++ version, you can switch to the Python implementation by modifying the --language
parameter in search_methods/astar.py
from --language cpp
to --language python
.
Troubleshooting
Should you encounter issues while using DeepCubeA, consider these troubleshooting steps:
- Verify your Python environment and installed package versions match the requirements.
- Ensure all necessary files are in the correct directories, especially when executing commands.
- Reduce batch sizes or update steps if you experience memory-related errors.
- If you have further questions or need assistance, reach out to Forest Agostinelli at foresta@cse.sc.edu.
For more insights, updates, or to collaborate on AI development projects, stay connected with fxis.ai.
Conclusion
At fxis.ai, we believe that such advancements are crucial for the future of AI, as they enable more comprehensive and effective solutions. Our team is continually exploring new methodologies to push the envelope in artificial intelligence, ensuring that our clients benefit from the latest technological innovations.