Counting agents in discrete system during Parameter Variation Experiment - java

I am working on a project for personnel allocation during a Navy maintenance availability using AnyLogic. I have the simulation running and have set the parameters (the personnel) variable up and running. However, I am trying to pull the numbers of checks entering the system and those leaving the system for each simulation run to assess the efficiency of the manpower allocation. I'm not able to do that because I cannot convert "agent" to "double". How can I fix this?
I tried creating new agents, trying to make the count into a variable to gather it on the ParametersVariation page and that did not work either.

Related

Uncommon question with "Ethical hacking" challenge

I have a rather unusual question, but I still don't understand much in programming to understand if it is possible to do what I want. So I feel like I need a little story. My name is Nick, I live in Ukraine and am currently studying as a student in one of the IT firms. Now is the middle of my studies and, if everything goes good, they will give me a chance to get a job in 2 months. But not only me, but 300 more students from all over the country, since the training is online, and the company in which we will get one of the largest in the CIS.
This is where I come closer to the task. To complete the course, we have to complete 8 practical sessions with 5-6 tasks in each. Upon their implementation, we upload the code to the git lab. For this, the company has opened an account for each of us. Then the electronic program for checking assignments - E-Mentor compiles our code, provides input data to fill each class and checks the task. In case of an error, it creates log, which often does not provide complete information. Since some of the test data is always hidden. At the end, the program sets progress points for us. And we all want to get 100%)
**Task: Get input data from the E-Mentor server in the form of a file and automatically push it from the server side to my Git Lab account.**
I am not asking for the complete code, but I am asking you to help me write pseudo code so that I can implement it in full.
I represent it like this:
The server clones my code
Compiles it
Runs tests
At this time, a file is created that copies all incoming information from tests
Somehow the created file is being pushed to my gitlab
For example:
GitBash is started on the server and logs into the gitlab under my login. In this case, it is restricted to rewrite the password and login used by the server itself, as it will be immediately noticed.
This is the coolest challenge that I want to try to do and share it with all students)

Is there a way to run a program in Eclipse without it creating certain variables again every time I run the program?

Basically, I would like to create a "library" of sorts in another class that is created when I run the program's main class the first time. But instead of repeating the action when I click run for a second time, I want the manipulated library in the first run to be initialized. For example if I have a static array with capacity 5 and put the int 1 in index 0, the next time I run the entire thing, I want to start with a static array with 1 in index 0. Is this even possible (in Eclipse) and if so, how can I do this?
All of your program's variables and other state are discarded when it is terminated and reinitialized when it is launched again. (This is a common cause of bugs in Android apps, which are frequently discarded and then re-opened.) To save state between program runs, you need to store it in some place that's intended for this. Common choices include files, databases (H2 with a file-backed database might be a good option), Android SharedPreferences, servers, and more exotic tools such as prevalent systems.

Resize internal table and entrySet fields of many HashMaps. In java 8 after creation to take less space in heap

We have some legacy code that was written in the early 2000s that was running fine till now, except when we added more users to the system it had daily OutOfMemory exceptions
We are going to redo the project from ground up, but we want to best use the existing code base.
The code has thousands (yes not the best design) of HashMaps that are only modified in a loop on creation and after that remain readonly.
When i run Memory analyser it says that there is 15% of the heap consists of unused space in HahsMaps.
For these instances if we use reflection to make the entry set accessible and resize it so the size is equal to the actual needed, will iterators fail?
After initial construction these maps are read only caches. We are running the code on Java 6 and few instances on Java 8. wont be upgrading the JVM version, in another 10-12 months the new code will be in production and replace the current.
I know we can give a better initial size when creating the hash map but that is a lot of work compared to one function that resizes a map based on current size. ALso most of the maps are part of libraries (that i do not have access to source code) and these do nt expose the the constructor that accepts size. they call default constructor of their internal HashMap only.

ScreenDevice.getIDstring() strange value

I am creating a Java application that will run on both Linux and Windows. The application will execute native code for multiple-monitor configurations. Because of this, I want to pass the monitor's ID from Java to the native code. This has lead me to Java's ScreenDevice.getIDstring().
Javadocs claim that this method is useful for debugging, but that it also uniquely identifies a monitor. For Linux devices, it returns a usable ID string that allows the native code to quickly retrieve the desired monitor object.
On Windows, however, the method simply returns /display0 for the first display, and then counts upwards for every following display (regardless if a graphics card contains both monitors, or if the monitors are on separate graphics cards).
When it comes to Windows C++ code, I have tried using EnumDisplayDevices and looking at the respective DeviceIDs and DeviceStrings. These do not match the values of Java:
First Monitor - Java = /display0, Windows = \\.\DISPLAY1
Second Monitor - Java = /display1, Windows = \\.\DISPLAY7
I am really confused as to where this /display# ID value is coming from... Where can I acquire the same /display# value when running native Windows C++ code?
Note: It would technically be possible to cycle through all existing displays to try and match the X/Y/width/height between the OS native code and Java, but this would be a lot of work and not very efficient. I would see this as a possible solution, but it is not very ideal.

How to get an elapsed time for this?

I am creating a Spigot (Performance savvy fork of Bukkit (Minecraft server software)) plugin that communicates with a Bungee (Proxy server for managing multiple spigot instances) server.
I have a functionality, that when you type a command "/setbar (time-in-seconds) (message)", it will use an API (BarAPI if you are familiar) to create a bar on every server connected to the Bungee instance.
The fault with this is that when a player joins one of the Spigot servers after the command was issued, the Bar is not there. I solve this by storing the bar's information on the Proxy level and sending these values to the specific Spigot instance the player attempts to join.
Okay, so enough background information. The problem I'm having is that I'm storing the time the admin (or whoever issued the command) requested in a variable. When the user joins, obviously the time will have decremented slightly (or a lot.) The way I've thought of making sure the user who is joining receives the proper elapsed time, (so the BarAPI knows how large the timer graphic needs to be), was by storing the time the command was executed in a variable (currentTimeMillis / currentTimeNano) and converting that to seconds then subtracting that from the time specified in the command.
I know there is a flaw with my logic here, and I can't seem to work out the math. I know this is rather simple, but any help you can provide would be extremely beneficial.
Thanks in advance.
Postscript: Any information I have failed to provide, please let me know and I will add it to this post.
I realize this is a bit of a "no-end" question as there isn't an exact answer provided I didn't actually give any code.
Here is how I solved it in plain English, though:
Store the time the command was executed the first in milliseconds.
When the command is executed next, remove the first value from the new value and divide it by 1000 to receive a seconds-value.
The seconds-value is the elapsed time. Once can find how much time is remaining by then subtracting the seconds-value from the initially provided seconds-value for the bar.
Erase the bar for the user in question; recreate same values but substitute seconds for the newly calculated seconds-value.

Categories