I believe the best way to enable this would be an API that would allow a user to control JaamSim directly through Java. Perhaps it is currently possible to include JaamSim as a Java library in your own Java code, but (if it is possible at all) you would need to have knowledge of the source code to control JaamSim.
I imagine that with an API (or JaamSim library) I would be able to set a model by feeding a function setModel() a .cfg file. This could be your single server model. Then I would be able to call runSimulation(), but I would also be able to adjust the arrival rate.
For instance, something like this:
model.setModel(myCfgFile); // suppose the arrival process is controlled by ExponentialDistribution1 with mean interarrival time equal to 1
simulationOutput1 = model.runSimulation();
model.ExponentialDistribution1.Mean = 2; // change the interarrival mean from 1 to 2
simulationOutput2 = model.runSimulation();
One question is how SimulationOutput objects should look. I am not sure how this is currently done internally, but through it I'd like to be able to get access to the output of ExpressionLoggers and EntityLoggers.
You're probably not able to implement a call such as model.ExponentialDistribution1 since the variable names are not known at compile time. Perhaps you need Maps, I'm not proficient enough with Java to tell.
Anyhow, once this is possible, I can build my own search algorithm to identify the arrival rate with the required properties. (The example you gave doesn't require optimization but it does require a root finding algorithm. In your example I could use Newton-Raphson or bisection.)
model.put("ExponentialDistribution1 Mean { 2 h }") // change the interarrival mean from 1 to 2
SimulationOutput simulationOutput2 = new SimulationOutput(model);
1) Environment of the parent optimizer.
2) Static Experiment vs. Guided Experiment.
3) Proficiency of the user with tools / Time Investment of Learning.
4) Level of automation of optimization applications.
5) Black-box vs White-box optimization.
In the first case, let's consider that users might not want to be limited to Java for their optimization.
One can obtain optimization algorithms in most languages, and some black box optimizers can interact through plug-ins or via the command line.
So a question is to what degree do we want to facilitate users of different systems?
Shelling out to the command line is probably the easiest way to accomodate the use of calling Jaamsim from different systems.
The pros and cons of this are probably worth discussing here.
It goes without saying that the maximum amount of flexibility would come from working with Java Source code directly, or an exposed API.
There are options that fall in the middle, such as Protocol Buffers, allowing communication between different languages. I'd be open to hearing
about other options for inter-process communication, it's not my strong suit.
The second case is whether or not the user knows all of the treatments (scenarios) they want to test in advance.
Full-factorial experiments can be handled by the existing UI, more complicated experimental designs like latin hypercubes may be a little
more challenging to implement. Most optimization, however, requires feedback in the form of results from each treatment to progress efficiently
making it a guided experiment where the treatments can't be specified in advance. Therefore, there needs to be a friendly way to pass inputs and
outputs back and forth between the optimizer and the simulation at regular intervals.
We should also consider that many users who come to Jaamsim are here because it's free and has a friendly GUI and thus doesn't require coding in Java.
Allowing these users to optimize simulations will require some sort of GUI or external pre-packaged scripts with easy input files. This is a good
reason to consider making a Java API that facilitates optimization. It will make optimization easier for those who do code, and possible for those
who don't (provided the API is then consumed by a optimization GUI).
I would speculate that the majority of simulation optimization projects have a person-in-the-loop at least for the early stages,
and so the command line seems sufficient for the situation of a single person tweaking some hyper-parameters and launching the optimizer.
As the project lifecycle continues, some may wish to use Jaamsim as part of a production system where it is run exclusively in batch mode and
acts as a function evaluator. Now we're getting into the realm of data pipelines and servers, and so shelling out to the command line may not be
a good option. Also, I'm not a security specialist but I can guess that if security is a concern that there may be issues there as well at any
point in the project lifecycle.
A final dimension I can think of revolves around how much interaction needs to occur between the optimizer and the simulation.
Most simulation optimization is black-box meaning your optimizer has a set of inputs to vary, receives some output and then has to figure out
how to alter the inputs so as to improve the output. This is just fine for search algorithms. As long as your optimization algorithm is
offline (meaning it only makes decisions when the simulation isn't running) this works. There are however some optimization algorithms that
are online, and these would need a way to be baked right into the simulation. The best way to do this is probably to create a new Jaamsim
object that learns over the course of the simulation.
There are probably other dimensions I haven't thought of. The main question in my mind is which direction should be focused upon first?
I'd encourage anyone who is interested in simulation optimization to weigh-in on where they fit on the spectrum of use cases.
Could anyone tell how to access the API?
Good day, Harry!
I'd appreciate very much if I could receive any feedback from you.
I'm really interested in combining JaamSim with, say, MILP, and would like to learn more about this API.
Thank you for your attention.
Regards,
Clever.