Skip to content

mlab-upenn/L2O-MIQP

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

L2O-MIQP

This repository contains the code for the project Learning to Optimize (L2O) applied to mixed-integer quadratic programming (MIQP).

Read the paper: arXiv

Overview

We implemented a L2O framework that leverages a quadratic programming (QP) layer to embed the dependence between integer and continuous decision variables, and utilizes a hybrid loss function combining supervised and self-supervised losses to leverage the strengths of both during training.

The experimental results are shown below.

  1. Robot Navigation Metric



  2. Robot Navigation Trajectory Infeasibility
    This plot shows the MPC lookahead trajectory collision rate. Our method shows a significant improvement in solving a "physically" safe solution.

    Robot Navigation Fail Rate

  3. Energy Tank Metric

  4. Energy Tank Trajectory Infeasibility

    Energy Tank Fail Rate

Where

  • SL: Supervised Learning with QP layer
  • SSL: Self-Supervised Learning with QP layer
  • C-SSL: Conventional Self-Supervised Learning applied to predict both discrete and continuous variables end-to-end.
  • H-L2O: Hybrid Learning-to-Optimize (proposed method)

Installation

To install the package dependencies, run:

pip install -r requirements.txt

To install the package, go to the root directory of the repository and execute

pip install -e . 

Examples

We provide two example problems:

  1. Collision avoidance for robot navigation
  2. Simplified thermal energy tank system

Each example includes scripts for training and evaluating different learning models.

Datasets

The datasets for both examples are included in the repository under the data/ directory.

To generate new datasets, run the following scripts:

  • For robot navigation:
    python generate_data.py --num_samples <number_of_simulations>
    
    Additional flags include --autosave, --shuffle, --horizon, and --save_path for configuring the simulation horizon and storage behavior.
  • For energy system:
    python generate_data.py --num_samples <number_of_simulations>
    
    Additional flags include --horizon, --seed, and --save_path for finer control over the generated dataset.

Training the Model

To train a model, navigate to the corresponding example directory and run:

python train.py

You can pass command-line arguments to customize the training. Use python train.py --help to display the available options. An example usage can be found in run.sh. The trained model will be saved in the same directory with the filename model_{your_input_filename}.pth and the validation results are saved in stats_{your_input_filename}.pt.

For example:

# supervised learning (default)
python train.py --save_stats --filename robot_nav_sl
# self-supervised learning
python train.py --w_obj 1e-5 --w_slack 1.0 --w_con 1.0 --w_sup 0.0 --save_stats --filename robot_nav_ssl
# hybrid learning
python train.py --w_obj 0.0 --w_slack 0.0 --w_con 1.0 --w_sup 1e3 --save_stats --filename robot_nav_hl_1

then the saved model is model_{filename}.pth, and the validation results are saved in stats_{filename}.pt.

You can train multiple models (e.g., supervised learning, self-supervised learning, or hybrid L2O with different weight configurations), by modifying the run.sh script as needed, then execute:

bash run.sh

Evaluating the trained model

After training, you can evaluate checkpoints (from inside each example directory) with:

python evaluate.py --model checkpoints/model_$run_name.pth

Replace $run_name with the name you supplied during training. You can also pass just the base name (e.g., --model robot_nav_sl), and the script will look in checkpoints/ automatically while writing stats to checkpoints/stats_<model>.pt. Use --stats_out custom/path.pt if you want to override the output location.

About

This is the repository for our learning-to-optimize for mixed integer quadratic programming (L2O-MIQP)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors