sertalpbilal / FPL-Optimization-Tools

A collection of tutorials and recipes to use optimization for winning Fantasy Premier League :)
Apache License 2.0
122 stars 43 forks source link

File Not Found error on running regular optimization py file mac #4

Closed ab9801 closed 2 years ago

ab9801 commented 2 years ago

Getting below error if I run "python3 solve_regular.py"

Exported problem with name: mp_h5_regular_pS0ST Traceback (most recent call last): File "/Users/abchanda/Documents/fpl-optimization/run/solve_regular.py", line 19, in result = solve_multi_period_fpl(data, options) File "/Users/abchanda/Documents/fpl-optimization/run/../src/multi_period_dev.py", line 349, in solve_multi_period_fpl process = Popen(command, shell=False) File "/usr/local/Cellar/python@3.9/3.9.7_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/subprocess.py", line 951, in init self._execute_child(args, executable, preexec_fn, close_fds, File "/usr/local/Cellar/python@3.9/3.9.7_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/subprocess.py", line 1821, in _execute_child raise child_exception_type(errno_num, err_msg, err_filename) FileNotFoundError: [Errno 2] No such file or directory: 'cbc tmp/mp_h5_regular_pS0ST.mps cost column ratio 1 solve solu tmp/mp_h5_regular_pS0ST_sol_init.txt'

sertalpbilal commented 2 years ago

You should be seeing this error due to first solve step failing. Probably the instance if infeasible. Could you tell me your configuration (regular_settings.json content)?

ab9801 commented 2 years ago

Sure..

{ "horizon": 5, "ft_value": 1.5, "itb_value": 0.08, "no_future_transfer": false, "randomized": false, "banned": [], "locked": [], "delete_tmp": true, "secs": 300, "use_cmd": false }

sertalpbilal commented 2 years ago

Can you open a terminal and try running cbc to see if it is in your path variable? If you don't get an error, navigate to "tmp" directory and try running the same line as above (if you have the .mps file still there):

cbc tmp/mp_h5_regular_pS0ST.mps cost column ratio 1 solve solu tmp/mp_h5_regular_pS0ST_sol_init.txt

If this works fine, then try using "use_cmd": true and let me know if the script works that way.

ab9801 commented 2 years ago

Thanks for the suggestions. Yes, cbc command works for me. I tried entering the line you pasted within the /tmp directory. Below is what I got:

Welcome to the CBC MILP Solver Version: 2.10.5 Build Date: Aug 12 2020

command line - cbc tmp/mp_h5_regular_pS0ST.mps cost column ratio 1 solve solu tmp/mp_h5_regular_pS0ST_sol_init.txt (default strategy 1) Unable to open file ./tmp/mp_h5_regular_pS0ST.mps Option for costStrategy changed from off to column!Order? ratioGap was changed from 0 to 1 Current model not valid Current model not valid No match for tmp/mp_h5_regular_pS0ST_sol_init.txt - ? for list of commands Total time (CPU seconds): 0.00 (Wallclock seconds): 0.00

ab9801 commented 2 years ago

"try using "use_cmd": true and let me know if the script works that way."

Yes, I just tried it and it works now!!! :) thank you so much! got all excited after seeing it work!! Does it mean this is fixed now?

sertalpbilal commented 2 years ago

I see "current model not valid" error. Seems like there is still a problem. When you run the script with use_cmd, did it give you a solution back at the end?

sertalpbilal commented 2 years ago

Oh never mind, it was probably due to file not being there. Do you see the transfer suggestion at the end when you run the script now?

ab9801 commented 2 years ago

Yes, I see it now! The issue is fully resolved! Thanks a lot for your help and expertise!