MiniZincIDE icon indicating copy to clipboard operation
MiniZincIDE copied to clipboard

Feature request/bug report - Visualisation tool

Open Mommessc opened this issue 1 year ago • 3 comments

Hello, I have a few requests/bugfixes to report about the visualisation tool.

I am launching the IDE in a Docker container with Firefox, but I get an error message Unable to detect a web browser to launch 'http://127.0.0.1:39587/0'. The fact that it does not detect my browser may be a problem on my side, but I also wanted to report that in this error message the URL is detected by the terminal and 'clickable' but the link contains a trailing quote (the one after /0 ). Again I am not sure this is something from my side or from how the error message is generated in the IDE.

Also, I noticed the port number is not fixed, but changes when launching multiple times the IDE, which is not convenient when launching the IDE inside a Docker container. It would be convenient to have an option to fix/select the port number to use for the visualisation tool.

Last question: I am using the draw_gantt function provided and I noticed it seems to be "called/evaluated" multiple times during the solving process, and not only at the end when a solution is found. Is there a way to draw visualisations only once, when all decision variables are fixed, in a same manner as the output works?

I am using the IDE version 2.7.4. Thanks for your work, and sorry if I should have created multiple issues for this.

Mommessc avatar Jul 18 '23 07:07 Mommessc

I think the reason that the IDE is unable to find a default browser would likely be because it's running in Docker (it might be possible to get it to work if you can set the XDG default browser using xdg-settings set default-web-browser from xdg-utils). We're using QDesktopServices::openUrl which is built into Qt, which produces that error message with the single quotes around the URL, so we can't change it. I'll have a look at allowing you to fix the port number in a future version.

I'm not sure what the draw_gantt function is - maybe you're referring to the vis_gantt function. Usually you would call this in a top-level constraint, which will evaluate it once during compilation, before solving. At that point, it just sends the Gantt label information to the webpage and opens the visualisation (but it will be blank because there's no solution yet). It also adds an output statement which will update the visualisation when a new solution arrives. It's not currently possible to only open the visualisation once the first solution has arrived.

cyderize avatar Jul 19 '23 02:07 cyderize

Installing xdg-utils in my docker solved the issue, thanks for that.

For the visualization, yes I was referring to the vis_gantt function, draw_gantt is my own function that calls vis_gantt. I am not sure what you mean by a "top-level" constraint. All constrains are not "loaded" at the same time when compiling the model?

Mommessc avatar Aug 29 '23 07:08 Mommessc

I suppose it doesn't really matter whether the constraint is a top-level item or within a let-expression - they should (hopefully) both work the same. It is just more typical to want to visualise a 'main' top-level variable, and for that it's easiest to use a top-level constraint.

The main point is that evaluating the call to vis_gantt is done once during compilation and then never done again - so I'm not sure what the behaviour you're observing is, with it being called multiple times during solving. An output statement which sends the solution data to the visualisation page does get added, so that gets evaluated every solution, but that definitely is only meant to get evaluated when a solution is found, not while variables are unfixed.

One way that strange things can happen would be if the vis_gantt call was placed inside an output statement, or in the RHS of an ::output_only declaration - then it would get evaluated with each solution, and probably won't work correctly at all.

cyderize avatar Aug 29 '23 07:08 cyderize