Resetting simulation for multiple runs with the scenario manager

#1

Hi all,

I’m in the process of converting a simulation to Epicenter from Simulate. We need to have the users complete four runs of the sim (with some intermediary information screens) and then display their results. I’m using the scenario manager for this, and have defined it as per the example in the docs:

var sm = new F.manager.ScenarioManager({
    run: {
        model: 'model.vmf'
    }
});

Once the sim has gone through enough time steps I’m using this code to save a clone of the current state, before resetting the sim and moving to the next screen:

sm.current.saveAndAdvance().then(function() {
    sm.current.reset().then(function() {
        window.location.href = "start-round.html";
    });
});

The sim appears to be saving correctly, but when I return to this page later I’m still at the final time step. I’m using the default run strategy, so it sounds like reset should be creating a new run, which is what I want to happen. Is this the correct way to do this?

Thanks!

0 Likes

#2

Hi Alison,

Your understanding sounds correct, and the code samples look right. Your issue probably means you’re somehow accessing the wrong run when you’re reading the time-step/ variables; you can verify this by looking at ( in the Chrome devtools console)

console.log(sm.current.run.getCurrentConfig()) // will log an object, with an ‘id’ field

Then look at the outgoing network request on ‘start-round.html’ which gets variables (it’ll be something like /run/:runid?include=Time) – the “:runid” should match the id logged in the previous step.

You mentioned the ‘default-run’ strategy - are you using the Run Manager in addition to the scenario manager?

I’ll be happy to debug if you let us know your account and project (email us at support@forio.com if you prefer).

-Naren

0 Likes

#3

Hi Naren,

Thank you for the help. I’ve checked the ids and they don’t match so that appears to be the issue. I believe the cause is that I’ve been using the Flow.js data-bindings to display the variables & create the graphs, and thus the run was not updating when required by the scenario manager. I’ve sent an email to support with the project details.

Thanks,
Alison.

0 Likes