This project enhances the learning search mechanism by shifting the optimization goal from merely reaching a specific goal state to optimizing the rank of the solution path. A key feature is the integration of bidirectional search to improve efficiency and exploration.
Traditional search algorithms often optimize for the shortest path to a goal. This project introduces a paradigm where the search is optimized to rank the discovered solution, potentially allowing for the discovery of more relevant or efficient paths beyond just the absolute minimum cost. The inclusion of bidirectional search significantly speeds up the search process by simultaneously searching from the initial state and the goal state, meeting somewhere in the middle.
The project can be run with various configurations controlled by command-line arguments.
This project requires Python 3.x and uses Conda for environment management to ensure all dependencies (including pygame for visualization) are correctly installed and isolated.
Installation Steps:
-
Preferred Method (Using
environment.yaml):If you have the necessary Conda channels configured (like
conda-forge), use the YAML file to create the environment:# Create and activate the environment using the YAML file conda env create -f environment.yaml conda activate optimize-to-rank -
Alternative Method (Using
spec-file.txt):If the YAML method fails due to channel or dependency issues, use the strict specification file to create the environment directly:
# Create the environment using the specification file conda create --name optimize-to-rank --file spec-file.txt conda activate optimize-to-rank
After activating the environment (conda activate optimize-to-rank), run the program with the desired arguments.
The general format for execution is: python main.py [optional arguments]
| Goal | Command | Description |
|---|---|---|
| Default Run | python main.py |
Runs with Visuals (Pygame), in Automatic mode, using Forward Search. |
| Interactive Debugging | python main.py --iteration_type "step" |
Runs with Visuals, pausing at each step, requiring input (e.g., arrow key) to advance. |
| Compare Bidirectional Performance | python main.py --with_or_without_pygame "False" --forward_or_bidirectional "bidirectional" |
Runs the fastest, non-visual search using the Bidirectional method. |
| Visual Bidirectional Search | python main.py --forward_or_bidirectional "bidirectional" |
Runs with Visuals in Automatic mode using the Bidirectional search. |
You can combine any of the following arguments:
--with_or_without_pygame: Set to"False"to disable visualization for faster, headless execution. (Default:"True")--iteration_type: Set to"step"to control the execution step-by-step. (Default:"auto")--forward_or_bidirectional: Set to"bidirectional"to enable the dual-direction search strategy. (Default:"forward")
The environment is loaded from files like states10_3box.txt, which define the grid using integer mappings.
Each cell in the input grid file corresponds to the following elements:
| Value | Element | Description |
|---|---|---|
0 |
Walls | Impassable barriers. |
1 |
Floor | Moveable space where the player can walk. |
2 |
Target Block Locations | Goal spots where the blocks must be pushed. |
3 |
Player Location | The starting position of the agent. |
4 |
Block Locations | Blocks that are to be pushed. |
4: Where the Blocks Currently Are (This value represents a movable block or box).
Note: The primary task when processing the grid is to convert all cells with the value 4 into a dynamic list of (row, column) coordinates to accurately track their positions throughout the search process.
