khalil-research / PyEPO

A PyTorch-based End-to-End Predict-then-Optimize Library for Linear and Integer Programming
MIT License
429 stars 56 forks source link

Error occurs for portfolio.py while using multi-processor #33

Closed ShuanyuWu closed 3 months ago

ShuanyuWu commented 3 months ago

Hi there, when I use the portfolio benchmark to train the model with regret, one error occurs as: File "E:\Anaconda\lib\site-packages\torch\nn\modules\module.py", line 1511, in _wrapped_call_impl return self._call_impl(*args, *kwargs) File "E:\Anaconda\lib\site-packages\torch\nn\modules\module.py", line 1520, in _call_impl return forward_call(args, *kwargs) File "E:\Anaconda\lib\site-packages\pyepo\func\rank.py", line 57, in forward sol, _ = _solve_in_pass(cp, self.optmodel, self.processes, self.pool) File "E:\Anaconda\lib\site-packages\pyepo\func\utlis.py", line 56, in _solve_in_pass [model_type] ins_num).get() File "E:\Anaconda\lib\site-packages\multiprocess\pool.py", line 774, in get raise self._value TypeError: portfolioModel.init() missing 1 required positional argument: 'covariance'

The solution is to replace the line 32 in portfoli.py self.cov = covariance => self.covariance= covariance

Hope this will help you update the PyEPO package. By the way, it is indeed helpful for researches on E2E PTO.

LucasBoTang commented 3 months ago

Hi there,

Thank you for reporting this issue. The error you encountered was due to a missing positional argument covariance in the portfolioModel.init() method.

The bug has been fixed in the latest commit b3634104c4d8b2eec9fcfaac9eef678ece2cef58. Please update to the latest version v0.3.8a of the PyEPO package.