This repository contains the code for the (pCQO-MIS) method. The goal is to provide tools and implementations for the experiments conducted in the submission.
- Install LibTorch.
- Clone the repository and navigate to the
./cpp_impl
directory. - Run the following CMake command:
cmake -DCMAKE_PREFIX_PATH={path to libtorch} ..
- Build the program using:
The executable
cmake --build . --config Release
pcqo_mis
will be available in the./external
directory.
To run the pcqo_mis
application, follow these steps:
-
Build the Application
Ensure the application is built as described in the Application Setup section. The executablepcqo_mis
should be available in the./external
directory. -
Prepare Input Data
The application requires a graph file in DIMACS format as input. Ensure the graph file is accessible and correctly formatted. -
Run the Application
Use the following command to execute the application:./external/pcqo_mis <file_path> [<learning_rate> <momentum> <num_iterations> <num_iterations_per_batch> <gamma> <gamma_prime> <batch_size> <std> <output_interval>] [initialization_vector]
<file_path>
: Path to the DIMACS graph file (required).- All other parameters are optional. If not provided, a grid search will be performed to attempt to find suitable values. Note: This grid search may result in suboptimal parameters that do not yield ideal results. It is strongly recommended to provide these parameters for better performance.
-
Example Command
For example, to run the application with a graph filegraph.dimacs
and specific parameters:./external/pcqo_mis graph.dimacs 0.0003 0.875 7500 30 900 1 256 2.25 10
For more information about the DIMACS format, see utils/NetworkX_to_DIMACS.ipynb
-
Output
- The application prints intermediate results at intervals specified by
<output_interval>
. - At the end of execution, the maximum independent set found is printed as a binary vector.
- The application prints intermediate results at intervals specified by
-
Notes
- Ensure the graph file is correctly formatted and accessible.
- Adjust parameters as needed for different graph sizes or optimization requirements.
- Python 3.10
- pCQO-MIS Setup
- Required libraries:
pandas
,torch
,gurobipy
,ortools
- Clone the repository and navigate to the repository's root directory.
- Create a virtual environment using
venv
:python3 -m venv .venv
- Activate the virtual environment:
source .venv/bin/activate
- Install the required Python libraries:
pip install -r requirements.txt
- (Optional) If using Gurobi, obtain a license and install it on the machine.
- (Optional) If using ReduMIS, clone the KaMIS project, build the ReduMIS program, and place it in the
external
folder. - Retrieve datasets from the
/graphs
folder used in the original experiments. - Run the benchmarking suite:
python benchmark.py
Specify the directories containing the graph data by editing the graph_directories
list in benchmark.py
. For example:
graph_directories = [
"./graphs/satlib/m403",
"./graphs/satlib/m411",
"./graphs/satlib/m418",
]
Define the solvers to use in the solvers
list. Uncomment the solvers and specify their parameters. For example:
solvers = [
{
"name": "Gurobi",
"class": GurobiMIS,
"params": {"time_limit": 100},
},
{
"name": "CPSAT",
"class": CPSATMIS,
"params": {"time_limit": 30},
},
]
When running the pcqo_mis
application, ensure that all arguments are provided. If any optional arguments are omitted, the application will default to a slower grid search to determine suitable values. This grid search may result in suboptimal parameters and significantly increase runtime. Providing all arguments is strongly recommended for optimal performance.
Run the script to start the benchmarking process:
python benchmark.py
Intermediate results are saved at intervals defined by SOLUTION_SAVE_INTERVAL
. Final results are saved as CSV files named zero_to_stage_{current_stage}_of_{total_stages}_total_stages.csv
.
The script generates a CSV file containing results for each graph and solver, including solution sizes and time taken.
For new graphs, a basic hyper-parameter search procedure is provided to assist in setting up pcqo_mis
without all optional parameters. Note: This grid search may result in suboptimal parameters that do not yield ideal results. It is strongly recommended to determine these parameters yourself for better performance.
- Ensure graph data and solver implementations are correctly set up and accessible.
- Adjust
SOLUTION_SAVE_INTERVAL
to control the frequency of checkpoint saves. - The benchmarking process may take significant time depending on the number and size of graphs and solvers used.
- For large datasets exceeding local RAM, use the
benchmark_large_graphs.py
script.