Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

running with no results #6

Open
Jiadalee opened this issue Jan 17, 2019 · 49 comments
Open

running with no results #6

Jiadalee opened this issue Jan 17, 2019 · 49 comments

Comments

@Jiadalee
Copy link

Hi :

I can run your codes but I didn't get any results. Have you ever encounter this problem?

@jsadler2
Copy link
Member

Hi Jiadalee,

Thanks for reaching out. The main result that the current version of the code produces is a csv file in the results_dir (an input to the run_swmm_mpc function). The csv file is titled [start datetime]_ctl_results_[run_suffix] where run_suffix is another parameter of the run_swmm_mpc function. After you run your code do you see that file?

@Jiadalee
Copy link
Author

Hi Jeff:

No. Basically, I wrote the 'my_swmm_mpc.py'file and created a 'result' folder. After that, I run my_swmm_mpc.py in Linux system. This shows running is successful but there is nothing in the 'results 'folder. Can you help me check the 'my_swmm_mpc.py' file? I can share it with you.

@Jiadalee
Copy link
Author

Hi Jeff:

What does 'To add to the path, add this line to your .bashrc' mean? Is .bashrc a file?

@jsadler2
Copy link
Member

Hi @Jiadalee , I can definitely look at your my_swmm_mpc.py file. What is output to the shell when you run it? Do you see some information about the the genetic algorithm generations? And yeah. The .bashrc is a file. It's should be in your home directory if you are running Linux.

@Jiadalee
Copy link
Author

Thanks!. I added 'print(MPC is great)'at the end of the my_swmm_mpc.py file. So the output to my shell is only'MPC is great'. I didn't see any info about GA generators. I'm wondering if there are problems in the setting-up before running.

Below is the my_swmm_mpc codes:

from swmm_mpc import run_swmm_mpc

input_file = "/uufs/chpc.utah.edu/common/home/u1147017/RL/flux_version_system_run/swmm_mpc/swmm_mpc/sample.inp"
control_horizon = 1. #hr
control_time_step = 900. #sec
control_str_ids = ["ORFICE R1", "ORIFICE R2"]
results_dir = "/uufs/chpc.utah.edu/common/home/u1147017/RL/flux_version_system_run/swmm_mpc/swmm_mpc/results/"
work_dir = "/uufs/chpc.utah.edu/common/home/u1147017/RL/flux_version_system_run/swmm_mpc/swmm_mpc/"
ngen = 4
nindividuals = 300

target_depth_dict = {'St1':{'target':1, 'weight':0.1}, 'St2':{'target':1.5, 'weight':0.1}}

def main():
run_swmm_mpc(inp_file,
control_horizon,
control_time_step,
work_dir,
target_depth_dict = target_depth_dict,
ngen = ngen,
nindividuals = nindividuals
)
if name == "main":
main()

@Jiadalee
Copy link
Author

mpc problem

@jsadler2
Copy link
Member

How long does it take to run that?

@Jiadalee
Copy link
Author

just two seconds. Very short

@jsadler2
Copy link
Member

Hmm. When I run it, it usually takes at least 10 minutes. Where in the above code do you have your print statement? I don't see it. Also, do you mind using the markdown code block feature so it's easier to read?

@Jiadalee
Copy link
Author

Hi:

No problem!
Sorry, I put the code in the swmm_mpc.py. Did you mean create an MD file?

Jiada

@Jiadalee
Copy link
Author

Can I email this code to you?

@jsadler2
Copy link
Member

Sure. You can email me OR maybe it would be easier to send on Research Gate. I just replied to your thread about sharing the paper. Let me know if that works. If not, I can give you my email address.

@jsadler2
Copy link
Member

Just got your code file. Which version of Python are you running?
Also, I think one of your problems is in the last part of your script. You have

if _name_ == "_main_":

What I think you need to have is

if __name__ == "__main__":

(add another underscore before and after name and main)
Also, although you have the results_dir variable at the top of your script, you do not include that as an input parameter when you are actually calling the run_swmm_mpc method.

@Jiadalee
Copy link
Author

Hi Jeff:

I use Python 3.6.7 to run my codes.

Oh! I see. I have changed the codes and also added the results_dir to the input variable(see the screenshot). Still, same problem....
2

@Jiadalee
Copy link
Author

underscore to 'nam'e was also added ..

@Jiadalee
Copy link
Author

from swmm_mpc import run_swmm_mpc

input_file = "/uufs/chpc.utah.edu/common/home/u1147017/MPC/swmm_mpc/swmm_mpc/sample.inp"
control_horizon = 1. #hr
control_time_step = 900. #sec
control_str_ids = ["ORFICE R1", "ORIFICE R2"]
results_dir = "/uufs/chpc.utah.edu/common/home/u1147017/MPC/swmm_mpc/swmm_mpc/results/"
work_dir = "/uufs/chpc.utah.edu/common/home/u1147017/MPC/swmm_mpc/swmm_mpc/"
ngen = 4
nindividuals = 300

target_depth_dict = {'St1':{'target':1, 'weight':0.1}, 'St2':{'target':1.5, 'weight':0.1}}

def main():
    run_swmm_mpc(input_file,
                 control_horizon,
                 control_time_step,
                 work_dir,
			     results_dir,
                 target_depth_dict = target_depth_dict,
                 ngen = ngen,
                 nindividuals = nindividuals
                 )
    if __name__ == "__main__":
        main()

@jsadler2
Copy link
Member

Okay. I've only been running this on Python 2.7. I haven't tried on Python 3. So I would first suggest to try running on Python 2.7. After that, I'm still a little unsure that it is running at all. Could you put a print statement in your code? like this:

def main():
    run_swmm_mpc(input_file,
    control_horizon,
    control_time_step,
    work_dir,
    results_dir,
    target_depth_dict = target_depth_dict,
    ngen = ngen,
    nindividuals = nindividuals
    )
    print 'yep. my code is running'

if name == "main":
    main()

@Jiadalee
Copy link
Author

Sure! Let me have a try

@Jiadalee
Copy link
Author

Sorry. I got the same error. ...

Actually, I double checked the codes like swmm_mpc.py and run_ea.py file. I found it seems they are written in Python 3 since they use syntax such as print (' xxx ') but not print ' '. If so, I think running them in Python 3 is a correct way.

Can I run these codes in Windows system? If so, how should I do? Thanks

Jiada

@Jiadalee
Copy link
Author

Ah....I think I have compiled it to my Local PC. But I got an ImportWarning.

image

@Jiadalee
Copy link
Author

Ok, I fixed this local PC 'deap' problem of swmm_mpc. So here comes the same question just same as I run it in Linux system: I can run it but no output in 'results' folder.....

@jsadler2
Copy link
Member

Currently, running on Windows is not supported.

@jsadler2
Copy link
Member

I am trying your code on my computer to see if I can reproduce the behavior your seeing

@jsadler2
Copy link
Member

@Jiadalee, I ran your code and found a couple problems.

  1. In line 6 you spell "ORIFICE" wrong
  2. You didn't include control_str_ids in your function call
  3. make sure your if __name__ ... line is outside your main() function
  4. you need to include "Node" in front of St1 and St2 in the target_depth_dict (this was a problem in my example in the readme which has been fixed now.

After changing all those thing, I got it to work.

@Jiadalee
Copy link
Author

Thanks. I will check it out.

@Jiadalee
Copy link
Author

image

@Jiadalee
Copy link
Author

I modified my codes. This time I got a log file in my 'results' folder. I passed this file to you via researchgate

@Jiadalee
Copy link
Author

Oh. I fixed the last question

Here comes another one:

when I include the if_name_...line inside the main() function, then, I run the codes. Finally, there is no error and I also got a newly-produced .inp file which is called 'simple_processed'. However, nothing in the results folder....

@Jiadalee
Copy link
Author

Jiadalee commented Feb 1, 2019

I can get a new .rpt file now after running it in python3

@Jiadalee
Copy link
Author

Jiadalee commented Feb 1, 2019

Hi:

Do you know how to solve the time_step problem?

image

@jsadler2
Copy link
Member

jsadler2 commented Feb 4, 2019

Awesome. So you are getting it to run. That is actually a known bug with a simple fix that I've neglected to push. I will push that today.

@jsadler2
Copy link
Member

jsadler2 commented Feb 4, 2019

I just pushed the commit that should fix that. After you run the code, it should update the control rules of the .inp file that you gave it. 3dd16c6

@jsadler2
Copy link
Member

jsadler2 commented Feb 4, 2019

I'm testing it now.

@Jiadalee
Copy link
Author

Jiadalee commented Feb 4, 2019

Yes. It basically can run in the Linux system now.

@jsadler2
Copy link
Member

jsadler2 commented Feb 4, 2019

I just ran it with the latest commit and there was no error. Pls let me know if you still have an error.

@Jiadalee
Copy link
Author

Jiadalee commented Feb 4, 2019

so you added a line
'''python
sim_start_dt = pd.to_datetime(sim_start_time)
'''
before 'ct1_settings_df.....'

@Jiadalee
Copy link
Author

Hi:

I still got this error. Actually, I have adjusted the code to make it run in Python3. So, could you let me know where you modify the code to fix the last error? so I can also do this in my side. Thanks

image

@jsadler2
Copy link
Member

Hi yes. If you just make the changes from this commit in your code, it should work: 3dd16c6 . Let me know if that makes sense.

@jsadler2
Copy link
Member

And that's cool you got it to run in Python3. What changes did you have to make?

@Jiadalee
Copy link
Author

Hi Jeff:

Sorry for the late reply.

Basically, I modified the tabs and indentations. I will send you the updated scripts for running in Python3 Linux system soon.

@Jiadalee
Copy link
Author

Hi:
I test these modified codes in python 3 again. I used the simple.inp model and only got 15-min simulation results. Can this code only run 15 mins?

image

@DangMH-TLU
Copy link

Dear Authors,
Could you possibly help me to fix the following error?

minhhai@MInhHai:/mnt/c/swmmmpc/models/runs$ python hgv11.py
{'optimization_params': {u'num_cores': 20, u'nindividuals': 20, u'ngen': 5}, 'n_ctl_steps': 2, 'ctl_horizon': 0.5, 'work_dir': u'/mnt/c/swmmmpc/models/runs/work', 'inp_file_dir': u'/mnt/c/swmmmpc/models/runs', 'flood_weight': 1, 'inp_file_path': u'/mnt/c/swmmmpc/models/runs/hague_v11_template.inp', 'results_dir': u'/mnt/c/swmmmpc/models/runs/rtc_output', 'opt_method': u'genetic_algorithm', 'run_suffix': u'hgv11_base_00_2yr12hr_gate_ga', 'ctl_str_ids': [u'PUMP P0', u'WEIR W0', u'ORIFICE R2'], 'target_depth_dict': None, 'ctl_time_step': 900, 'dev_weight': 0, 'log_file': u'/mnt/c/swmmmpc/models/runs/rtc_output/log_hgv11_base_00_2yr12hr_gate_ga', 'inp_process_file_path': u'/mnt/c/swmmmpc/models/runs/work/hague_v11_template_process.inp', 'node_flood_weight_dict': None}
Simulation start: 2021.02.09.16.04
2016-10-08 00:15:01

Traceback (most recent call last):
File "hgv11.py", line 46, in
main()
File "hgv11.py", line 43, in main
run_swmm_mpc(config_file)
File "/home/minhhai/.local/lib/python2.7/site-packages/swmm_mpc/swmm_mpc.py", line 150, in run_swmm_mpc
run.optimization_params)
File "/home/minhhai/.local/lib/python2.7/site-packages/swmm_mpc/run_ea.py", line 54, in run_ea
halloffame=hof, verbose=True)
File "/home/minhhai/.local/lib/python2.7/site-packages/deap/algorithms.py", line 150, in eaSimple
fitnesses = toolbox.map(toolbox.evaluate, invalid_ind)
File "/usr/lib/python2.7/multiprocessing/pool.py", line 253, in map
return self.map_async(func, iterable, chunksize).get()
File "/usr/lib/python2.7/multiprocessing/pool.py", line 572, in get
raise self._value
IOError: [Errno 2] No such file or directory: '/mnt/c/swmmmpc/models/runs/work/hague_v11_template_process_tmp_fpsnd2f8w.rpt'

Thank you very much in advance.
Regards,
Dang Minh Hai

@Jiadalee
Copy link
Author

@DangMH-TLU It seems the working directory is not correct. Can you introduce which programming environment are you using and how did you navigate to your working dir?

@DangMH-TLU
Copy link

Hi Jiadalee,
I run Swmm_mpc on python 2.7 on Ubuntu 18.04.
I navigate to the working directory as follows:cd /mnt/c/swmmmpc/models/runs/
Thank you very much.
Regards,
Dang Minh Hai

@jsadler2
Copy link
Member

jsadler2 commented Mar 1, 2021

Hi @DangMH-TLU - sorry for the slow reply. I think your error means that you haven't installed swmm5 correctly or it's not in your path. Did you follow this step in the readme? https://github.com/UVAdMIST/swmm_mpc#2-install-epaswmm5

@bdb3m - didn't you have a similar problem? Were you able to fix that?

@bdb3m
Copy link

bdb3m commented Mar 1, 2021

@jsadler2 I'm fuzzy on the details since it's been a while but that sounds right. I'll see if I can find anything in my notes.

@DangMH-TLU I hope jsadler2's response can help you get it working!

@DangMH-TLU
Copy link

DangMH-TLU commented Mar 2, 2021

@jsadler2 : Thank you very much. I fixed sucessfully the error which originated from the wrong working directory in the .bashrc file. Again, thank you very much!

@DangMH-TLU
Copy link

@bdb3m Thank you very much!

@jsadler2
Copy link
Member

jsadler2 commented Mar 3, 2021

Glad you got it working!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants