## Abstract  

Our work builds upon two prior approaches: *"DC3: A Learning Method for Optimization with Hard Constraints"* and *"Homeomorphic Projection to Ensure Neural Network Solution Feasibility for Constrained Optimization"*. We have adapted and extended the official implementations from [DC3](https://github.com/locuslab/DC3) and [Homeomorphic Projection](https://github.com/emliang/Homeomorphic-Projection). In particular, we use their methods to obtain feasible initial solutions, upon which we apply our proposed **Descent-Net** framework.  

Descent-Net updates candidate solutions iteratively by learning the descent direction at each step, leading to solutions with smaller optimality gaps while preserving feasibility adjustments throughout the optimization process. Compared with baseline approaches, our method achieves improved accuracy with lower computational cost.  

---

## Dependencies 

+ Python 3.x + [PyTorch](https://pytorch.org) >= 1.8 
+ numpy/scipy/pandas
+ [osqp](https://osqp.org/): *State-of-the-art QP solver* 
+ [qpth](https://github.com/locuslab/qpth): *Differentiable QP solver for PyTorch* 
+ [ipopt](https://coin-or.github.io/Ipopt/): *Interior point solver* 
+ [pypower](https://pypi.org/project/PYPOWER/): *Power flow and optimal power flow solvers* 
+ [argparse](https://docs.python.org/3/library/argparse.html): *Input argument parsing* 
+ [pickle](https://docs.python.org/3/library/pickle.html): *Object serialization* 
+ [hashlib](https://docs.python.org/3/library/hashlib.html): *Hash functions (used to generate folder names)* 
+ [setproctitle](https://pypi.org/project/setproctitle/): *Set process titles* 
+ [waitGPU](https://github.com/riceric22/waitGPU) (optional): *Intelligently set CUDA_VISIBLE_DEVICES*

---

## Dataset  

- For QP and nonconvex problems, datasets are provided in the `datasets` folder, where each subfolder (named after the problem type) contains the corresponding dataset. Alternatively, the datasets can also be regenerated using the `make_dataset.py` scripts located in each subfolder.   
- For ACOPF experiments, the dataset is too large to include in this repository. It can be downloaded from the [Homeomorphic Projection repository](https://github.com/emliang/Homeomorphic-Projection) with filenames:  
  - `acopf_2023_30_10000_dataset`  
  - `acopf_2023_118_20000_dataset`  

---

## Main Files  

- **`training_descent.py`**: Trains Descent-Net on QP and nonconvex problems.  
- **`training_descent_acopf.py`**: Trains Descent-Net on ACOPF problems.  
- **`opt_eval.py`**: Uses solvers to obtain the optimal solutions of QP, nonconvex, and ACOPF problems.  
- **`subproblem.py`**: Evaluates the performance of the Descent Module on subproblems.  
- **`pgm.py`**: Solves problems using the projected subgradient method instead of Descent-Net, serving as a baseline for comparison.  
