Closed main loop

A small suggestion on how to close the loop, with some simulation parameters included. This is still a concept phase, working on some ideas.
But as I wanted to test pull-requests, I'm sending the pull request now, even the code is not completely done. 

Note that it runs, so that is not the problem, however, if you depend on the setup_params function of the main.py file, you will have to change how you get the parameters. See in the log explanation about why.