AnyLogic executeExpression exception - anylogic

I am using AnyLogic 8 Professional 8.8.1. In my model I sample a repair time for a component that failed from a distribution that is configurable through an input file. To achieve this I specify the distribution in the input file as a String and then in the model, call the executeExpression after each failure to get the downtime for the component.
I have done this for various classes (agent types) in my model and have combined all the logic in a superclass, which the various components merely extend this class.
So far it worked perfectly (except for the annoying 1.6 JVM message see this question) until I tried to add the functionality to another agent. I simply made this agent also extend the superclass, so it is the exact same code executing.
Executing Expression triangular(82.0,287.0,123.0)
Expression returned: 150.21341253179259
Tue Apr 01 21:23:10 CAT 2025: stockyardFeed1 has broken down
Updating status
Executing Expression triangular(82.0,287.0,123.0)
Annotation processing got disabled, since it requires a 1.6 compliant JVM
----------
1. ERROR in \nmet_terminal_model\Expression_9_xjal.java (at line 75)
public class Expression_9_xjal extends nmet_terminal_model.Schematic$17{
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The nested type nmet_terminal_model.Schematic$17 cannot be referenced using its binary name
----------
2. ERROR in \nmet_terminal_model\Expression_9_xjal.java (at line 78)
return triangular(82.0,287.0,123.0);
^^^^^^^^^^
The method triangular(double, double, double) is undefined for the type Expression_9_xjal.Performer
----------
2 problems (2 errors)
Exception during discrete event execution:
Truncated class file
To make it even more confusing is that I added a traceln writing the distribution to execute and its answer in the specific function and when making the distribution the same as another type of component in the input file you will notice that the first two lines in the console output works fine, but then when trying to run the exact same - it throws the error.

Related

Optimization Experiment internal error (no model BUILD problems) - anylogic

I built my model and got Zero problems.
The Simulation Experiment is running without any errors (I'm using test/random values for the parameters)
However, when I run the Optimization Experiment, I'm getting the following 500 errors:
I have 246 int parameters in the optimization experiments ( I know too much but did not return any problem while building the model, I used the same number before in a different problem, and it worked totally fine)
I have defined 1756 constraints ( I know too much, but still under the limit of 65535 bytes and did not return any problem while building the model )
I have used root to define my constraints as below (maybe this is causing errors? but did not return any problem while building the model):
The reason behind this 500 Error (internal error) is the type of the parameter and the step size defined in the optimization experiment panel (Parameters).
What I have found is as follows:
if you use the int type for a parameter, its step size must be 1
if you use the discrete type for a parameter, its step size can be any integer (for example 4)
Even one parameter is not allowed to break this role, otherwise AnyLogic will return the same error message : 500 Error

Is there a way to show the faulty code line instead of the memory address when a runtime error occurs in VSCode?

See the Question in the title:
Runtime error 201 at $0000000100001D42 $0000000100001D42
Is there a way to show the faulty code line instead of the memory address?
Thanks for the Help
Normally, when a run-time error occurs, you are presented with a list of addresses that represent the call stack backtrace, i.e. the addresses of all procedures that were invoked when the run-time error occurred.
This list is not very informative, so there exists a unit that generates the file names and line numbers of the called procedures using the addresses of the stack backtrace. This unit is called lineinfo.
You can use this unit by giving the -gl option to the compiler. The unit will be automatically included. It is also possible to use the unit explicitly in your uses clause, but you must make sure that you compile your program with debug info.
When compiled with -gl, the following output is generated:
Runtime error 255 at 0x0040BDE5
0x0040BDE5 GENERATEERROR255, line 6 of testline.pp
0x0040BDF0 GENERATEANERROR, line 13 of testline.pp
0x0040BE0C main, line 17 of testline.pp
0x0040B7B1
This is more understandable than the normal message. Make sure that all units you use are compiled with debug info, because if they are not, no line number and filename can be found.

Invoke a C# method while paused in WinDbg debugger?

When debugging a C# application using WinDbg, I know how to list the objects of a certain type with !dumpheap. For example:
!dumpheap -stat -type CefSharp.Wpf.ChromiumWebBrowser
Statistics:
MT Count TotalSize Class Name
00007ffa08364978 1 32 CefSharp.Wpf.ChromiumWebBrowser+<>c__DisplayClass1f
00007ffa08336f48 1 32 CefSharp.Wpf.ChromiumWebBrowser+<>c__DisplayClass22
00007ffa0833fa18 2 64 CefSharp.Wpf.ChromiumWebBrowser+<>c__DisplayClass25
00007ffa08364748 4 128 CefSharp.Wpf.ChromiumWebBrowser+<>c__DisplayClass28
00007ffa083123c0 1 824 CefSharp.Wpf.ChromiumWebBrowser
00007ffa08361fe0 115 3680 CefSharp.Wpf.ChromiumWebBrowser+<>c__DisplayClass10
Now, I am wondering if I can execute a method of one of these objects using WinDbg. For example, I know this object has a ShowDevTools() method, how can I execute it?
TLDR: I've never seen it working until now. A related question is unanswered since 2011. If it would be easily possible, some smart people like Steve Johnson (author of SOSEX) would probably have implemented this in an extension. There's also no such command in netext. The closest there is !weval but it works on members only.
While you have a list of objects now, you'll first need to find the methods that are available at those objects:
!dumpmt -md <MT column from !dumpheap>
To call a method, there's the .call command, but it explicitly states that .NET is not supported:
Managed code cannot be called by this command.
However, .NET is not only managed. After the JIT compiler has processed the IL code, you have native code like in C++.
The !dumpmt -md command already told you whether or not the managed method has already been JITted. There are 3 possibilities:
None: the method has not been jitted
PreJIT: the method has been jitted by NGen
JIT: the method has been jitted
From !dumpmt -md you have a method descriptor, you can use
!dumpmd <method descriptor>
From there, you get a native code address, which could possibly be used for a .call. Unfortunately, the next problem occurs:
0:006> .call 011f0500
^ Couldn't resolve '.call 011f0500'
This error message means that WinDbg was unable to resolve the symbols for that method. While you have PDBs for your DLL, the JIT compiler does not produce a PDB for the JITted code.
Therefore you need to specify a prototype as defined in the documentation:
.call /s Prototype Function( Arguments )
Allows you to call the function that is specified by Function even though you do not have the correct symbols. In this case, you must have symbols for another function that has the same calling prototype as the function you are trying to call.
At this point, we have the following open questions:
where do I get a good prototype from?
what do I do if the method was not JITted?
I'm sorry that this "answer" does not resolve your issue. It may only give some insight on how difficult the situation is.

Why does MATLAB give a "class has no property" error when running but not debugging?

I have a script that performs a bunch of experiments on different datasets, below is part of the logic to determine whether a dataset needs to be loaded. Basically we load the dataset if there is none already loaded, or if the currently loaded one doesn't match the one we need by name.
This example crashes with the error The class dataset has no property or method named 'name' at the if statement (the class does in fact have this property):
if(~exist('dataset','var')||~strcmp(dataset.name,datasets{datai}.id))
loaded=load(datasets{datai}.filename);
dataset=loaded.dataset;
end
If I debug and stop at the line, I can access dataset.name in the debugger without performing any further actions. I don't think the reason is the dataset object not existing. In the loop I ran, the first dataset was correctly loaded, but the second one (where the name check comes into play) wasn't.
This rewriting works:
if(~exist('dataset','var')||~strcmp(nom,datasets{datai}.id))
loaded=load(datasets{datai}.filename);
dataset=loaded.dataset;
nom=dataset.name;
end
Why was I able to access dataset.name in the debugger, and why does the rewriting fix the issue?

Cannot change the dimensions of run-time parameter in Model block

I have a Simulink model with a Model block I am using to avoid duplication of some functionality.
When I try and run the parent model, I get the following errors:
Cannot change the dimensions of run-time parameter 'Gain' in
'TranslationChannel/First-Order Filter1/Model/Continuous/A' from
[1x1] to [0x0] while model is executing
Invalid setting in
'TranslationChannel/Second-Order Filter/Model/Continuous/A*x/A11' for
parameter 'Gain'
Error evaluating parameter 'Gain' in
'TranslationChannel/Second-Order Filter/Model/Continuous/A*x/A11'
Reference to non-existent field 'A11'.
Invalid setting in
'TranslationChannel/Tilt/Model/Continuous/A*x/A11' for parameter
'Gain'
Error evaluating parameter 'Gain' in
'TranslationChannel/Tilt/Model/Continuous/A*x/A11'
Reference to
non-existent field 'A11'.
The sub-model is below:
The block the error refers to is First Order Fliter 1, the parameters are which are:
How do I resolve this error, or, is there a better way of calling the same series of blocks multiple times in a model?
The parent model is below:
EDIT:
After my discussion with Ander, I tried connecting a step source directly to the model block to eliminated any possibility of a null signal and got the same error, suggesting the problem is due to calling the second model. If anyone can assist further, that would be great.
EDIT 2: I have confirmed that data is being passed into the model. Removing the filters from the sub-model makes it work fine. The error occurs in the masked portion of the filters.
I have resolved this my using a library instead of a model, and putting the filter blocks into a subsystem inside the library that I then drag to my main model.
This allows me to tune the parameters once and have it change all the blocks at once.