How to know time remaining until Anylogic Model is executed - anylogic

Is there any way one can know the time remaining until Anylogic model completes it's execution in real time using traceln.
I am trying to trigger an anylogic model jar file using vba & want to show a progress bar displaying the Progress of experiment & time remaining until model execution is completed.

I think you want to know the real time that the model execution will take and us that to show a progress bar.
Felipe showed how to calculate the simulation time based on starttime and endtime set in the sim experiment and the current simulation time.
I don't think there is an easy way to do what you want. based on trial and error you could insert some traceln inside your model and use that to time the progress bar. Though it would change based on your inputs. Even the progress bars you see on microsoft apps / installations are not too accurate so thats never easy.

double remaingTimeSeconds=getEngine().getStopTime(SECOND)-time(SECOND);
traceln(remaingTimeSeconds);
in a more general way, if your model doesnt start at t=0, then you can do the following to get the remaing progress:
double totalSimTimeSeconds=getEngine().getStopTime(SECOND)-getEngine().getStartTime(SECOND);
double timeSinceStartSeconds=time(SECOND)-getEngine().getStartTime(SECOND);
double remaingingTimeSeconds=totalSimTimeSeconds-timeSinceStartSeconds;
double fractionRemaining=remaingingTimeSeconds/totalSimTimeSeconds;
traceln(fractionRemaining*100+"%");

Related

The simulation model time slows down in virtual mode

I am currently building a model on a manufacture process line and the simulation was running fine without errors. Suddenly when I entered in virtual mode to run quickly the simulation, the model started to slow down although the step is high. I am trying to identify where the issue is but nothing is working. At a certain time , the simulation just stops while the step is still running.
This is a picture of the pallete, maybe the experiment is causing this.
You created an infinite loop, this can be triggered by various things in your model.
Likely, you have a ' while' loop not finishing, could also be a condition-based transition.
You need to find this yourself, though. 3 options:
(easy): Check the model logic yourself and find the problem
(easy): nudge yourself to where it stops with traceln commands (see where they stop showing, getting you closer to the culprit)
(harder): Use a profiler (google "AnyLogic profiling" or similar if you are not familiar)
Benjamin is correct, you have created an infinite loop. Click on the "Events" tab in the developer panel and see which events are scheduled to occur at about the time that your model slows down to 0 days/sec. You can also pay attention to the "Step: " counter at the bottom of the developer panel and see where the step count spikes - e.g., if your model has roughly 10k steps per day, and suddenly starts climbing to 400k steps around 25.99 days, you can pay attention to which things are happening in your logic at that time and narrow down where the infinite loop is created. traceln will also help immensely

Open date strategy variable

sorry my english. Im not native speaker.
Hi all, i have a dude about stops in Pine-script.
I'm tring to make a specific trail stop in my strategy script.
I want to make a for loop to evaluate all candless from open strategy date until today.
Has pine-script any variable which contains open position date or number of days or similar thing ?
thank you very much.
There is no variable that I know of that records the date of entries, but since it's your strategy, you should know when it's entering/exiting trades, so you should be able to save the time when those events occur.
Also, rather than waiting for a number of bars to elapse and go back over them with a for loop, it will be much more efficient for you to start tracking whatever info you need from the moment your condition triggers. For most needs, this should allow you to forego using a for loop.
I was just reading this thread: Strategy with sample code
And noticed that it has some work with trailing stop in it. Basically, you should be able to find some pine scripts that work with trailing stops and tailor it to your needs.

Show internal progress of Get-WMIObject

I'm using Get-WMIObject, which can take quite a long time, depending on what exactly I want to get.
Sadly this doesn't show its progress by default.
Is there a way to get the actual internal progress of Get-WMIObject? (e.g. the percentage so one can calculate the expected time it will take)
Or is it just impossible to predict the duration of the execution?
Have not found anything in the web about it.

Google Sheet IMPORTHTML VERY Slow?

I have a spreadsheet that acquires some table data using the IMPORTHTML function, and for the first two days I was using it (refreshing twice daily) things were going fine. As of this morning, it is absolutely crawling. Went from taking ~15 seconds to load 30 rows to taking ~10 minutes. Can somebody lend aid on this?
Example formula:
=IMPORTHTML(
"http://www.muthead.com/16/players/prices/1508-markus-wheaton/playstation-4","table",2
)
As mentioned, the first couple of days it was able to refresh and process a list of 30 without any pauses. Now I get the 'Executing script' message for about ten minutes before it begins to do anything, and I haven't touched the source code since origin. I'm not sure what contributes to the performance of the IMPORTHTML statement...
I've run into similar loading issues when using IMPORTHTML, IMPORTDATA, etc. The best solution I've found is to write a trigger that will edit your formula so it is forced to refresh every hour or so.
Open up the script editor and put this in. Change 'A1' with the cell your IMPORTHTML function is in, and change foo to the URL you're trying to import.
function refreshData() {
var range = SpreadsheetApp.getActiveSpreadsheet().getRange('A1');
range.clear();
range.setFormula('=IMPORTHTML(foo)');
}
Then go to Edit > Current Project Trigger > Add Trigger, and set a refresh interval.
Hope this helps.

How to refresh field calculation in live time

I've created a function to calculate time difference between current time and time recorded as StartTime. All calculations are perfect but my "StopWatch" won't update every second. Is there a way of updating it, so it can display every second elapsed since start point?
Window refreshing script isn't an option really.
Short answer: no.
There is nothing in Filemaker that will happen as a result of merely time passing - except for a script paused for a duration or installed on a timer.
To show a live, ticking clock, your best option would be to use a web viewer - see an example file here: http://fmforums.com/forums/topic/71934-calculating-elapsed-time-realtime/?do=findComment&comment=340205