swmm_mpc icon indicating copy to clipboard operation
swmm_mpc copied to clipboard

running with no results

Open Jiadalee opened this issue 6 years ago • 49 comments

Hi :

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

Jiadalee avatar Jan 17 '19 22:01 Jiadalee

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?

jsadler2 avatar Jan 18 '19 20:01 jsadler2

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 avatar Jan 18 '19 23:01 Jiadalee

Hi Jeff:

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

Jiadalee avatar Jan 20 '19 05:01 Jiadalee

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.

jsadler2 avatar Jan 21 '19 17:01 jsadler2

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 avatar Jan 21 '19 18:01 Jiadalee

mpc problem

Jiadalee avatar Jan 22 '19 18:01 Jiadalee

How long does it take to run that?

jsadler2 avatar Jan 22 '19 18:01 jsadler2

just two seconds. Very short

Jiadalee avatar Jan 22 '19 18:01 Jiadalee

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?

jsadler2 avatar Jan 22 '19 21:01 jsadler2

Hi:

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

Jiada

Jiadalee avatar Jan 22 '19 21:01 Jiadalee

Can I email this code to you?

Jiadalee avatar Jan 22 '19 22:01 Jiadalee

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 avatar Jan 23 '19 21:01 jsadler2

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.

jsadler2 avatar Jan 24 '19 18:01 jsadler2

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 avatar Jan 24 '19 18:01 Jiadalee

underscore to 'nam'e was also added ..

Jiadalee avatar Jan 24 '19 18:01 Jiadalee

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()

Jiadalee avatar Jan 24 '19 22:01 Jiadalee

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()

jsadler2 avatar Jan 25 '19 18:01 jsadler2

Sure! Let me have a try

Jiadalee avatar Jan 25 '19 18:01 Jiadalee

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 avatar Jan 26 '19 06:01 Jiadalee

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

image

Jiadalee avatar Jan 28 '19 17:01 Jiadalee

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.....

Jiadalee avatar Jan 28 '19 17:01 Jiadalee

Currently, running on Windows is not supported.

jsadler2 avatar Jan 29 '19 20:01 jsadler2

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

jsadler2 avatar Jan 29 '19 20:01 jsadler2

@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.

jsadler2 avatar Jan 29 '19 21:01 jsadler2

Thanks. I will check it out.

Jiadalee avatar Jan 30 '19 02:01 Jiadalee

image

Jiadalee avatar Jan 30 '19 06:01 Jiadalee

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

Jiadalee avatar Jan 30 '19 16:01 Jiadalee

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 avatar Jan 30 '19 17:01 Jiadalee

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

Jiadalee avatar Feb 01 '19 01:02 Jiadalee

Hi:

Do you know how to solve the time_step problem?

image

Jiadalee avatar Feb 01 '19 03:02 Jiadalee