Community

Hi everybody, Is there any way I can split an AnyLogic model into several files on the disk? (ideally each active object or Java class to be stored in an externl file) Rgds, Lau
Hi Lau, No, for the time being, it is not possible. AnyLogic model it is a holistic file. But could you tell me, why do you need such feature?
Hi, Lau. I think that the item http://www.xjtek.com/support/forum/anylogic6/685/? at this forum may help you. I'm using several "alp" files agregated in a project. Regards, Almir.
Hi Almir, Yes, we thought about that. The only problem is when i need to deliver the project to the customer. It's very unfriendly for him to need to import a lot of libraries. Rgds, Lau
Hi, Lau. How do you send the simulator to your client? .alp + files, etc? Jar? Do you export your application to an Applet? If you open all the "alp" in the same project it's not necessary to import them, isn't? I think that another way is creating some "big" packages (with a lot of classes) and sent them to you cliente. Then the client do not need to import lots of libs, but these few packages. It is possible in your case? Regards, Almir.
Hi all Could someone explain me how to use libraries ? I know that it might be a noob question but lets say i have created a model using pedestrian library that orders pedestrian to walk lets say from line called "Entry" to line "Exit1" or "Exit2" , passengers are choosing exit following calling in pedGoTo object a function called "Function". This was of course example. Now i would like to create libraries of function (functions) and another of flowchart. Now i would like to open new empty project draw lines "Entry", "Exit1" and "Exit2" , drag libraries and see pedestrians walking as in main example. Is This possible ? how can i do that'? I know that to exporting library i can only use Active object class, its mean that every part that i want to export should be in different class? (flowchart , functions) . How then can i refer to objects inside the library ? Of course my project is much more complicated but i would like to learn on this simple example how to use libraries. My main goal is to hide created java code and flowchart but still allow to open project for editing in AnyLogic application. I do have AnyLogic Professional. Best Regards Tomas
HI Tomas, Yes, you're right. The custom library it is a set of active objects. One object can contain any kind of elements inside: flowcharts, functions, parameters, etc. To be able to use the functionality of some library block, you should drop it in your model. All internals (blocks and functions) will be accessible by "libBlockName.internalsName" method. If, while designing a library, you will need to use functionality of already existing library block, you should drop it inside the block that you're developing. I hope it will help you.
Hi Pavel, Can you explain to me how to realize the problem that I have described before? When i am trying to acces any internall objects following your method i can only acces them _name representations which are of the "int" type. Best regards Tomas
I mean that I can but it gaves me error that I "Cannot make a static refference to the non-static field Graphics.line1" . I am using the full template of pedestrian library (that you can choose creating new model) and then i am creating another Active object called Graphics Then i am moving all graphics (walls, line, line1 etc...) to Graphics OC ant trying to use it in Main Object class using for example in pedGoto block "Graphics.line1" as a target. Any Ideas ?? Regards, Tomas
Hi again, Is there any way to make graphical objects (line , point etc) static ? Because when i am referring to them from another Active object class i get the error "cannot make static reference to the non -static field line" (line is ShapeLine type) I Also get an warning that static function shouldn't be accessed in a static way is that a bug?? Regards Tomas
HI Tomas, There are no way to make them static. You should drop the instance of "Graphics" active object to the "Main" and then use the following reference: graphics.line1. BTW, please note, that when you're creating pedestrian models it is highly recommended to place all blocks and graphical objects in the same active object, e.g. in Main.
Hi Pavel, " it is highly recommended to place all blocks and graphical objects in the same active object, e.g. in Main.". Well i am trying to make simplest example but still doesn't work. Now the thing i want to do is to refer to the main object class components from different class. In order to hide all the functions, lists and variables into library and then easy reuse it. OK i did that so now i have flowchart and graphical objects in main (simply project from pedestrian library template (full) only difference is that i have to exit lines "line1" and "line2"), then i have another class called Graphics, in this class i have a simple function which says, if(randomTrue(0.5)==false) return Main.line1 ; else return Main.line2 ; What i get is Cannot make a static reference to a non-static field Main.line1 Cannot make a static reference to a non-static field Main.line2 Cannot make a static reference to a non-static method randomTrue(double) from the type Utilities. Anyway is there a way to copy errors ? OK so I have tried many things and solutions , and references but i cannot get rid of those errors. Any clue ? Best Regards, Tomas
Hi Tomas, Pleas drop "Graphics" object to the "Main". Then you will be able to refer to all elements placed in the "Main" using "get_Main().nameOfElement" notation. I hope it helps.
Hi Pavel Thanks. That way I can get rid of errors, however to use those commands I shall make this function non static (otherwise i still get error) in this situation when i am calling this function from the main class i get the error. (I am just using Graphics.myFunction()) Cannot make a static reference to a non-static method myFunction() from the type Graphics. I am getting crazy with this static, non static issue. Any hand ? Best Regards Tomas.
Hi all , how can i call something (e.g. method) in a non static way ? i mean to make non -static reference. I need to solve the problem described above. Regards, Tomas
Hi again, ok i have finally done that it works between classes. Now I have added the class that contains this Function into Library. I've created a new model exact to the previous one, I dropped the new library AOC and while compiling i got an error : the method myFunction() from the type Functions is not visible. Should I export this class to the library in spacial way ? what can be a problem here? Any ideas, Thanks in advance Tomas
Tomas, if the support services of your AnyLogic license is active, I recommend you to contact XJ Technical Support Team. Use "Get Support" button to ask your questions and attach the model with errors.
Thanks for advice Greg, I believed that this is common problem using libraries, when two classes aren't part of one package, but as I can see is a really big problem. Have anyone used the custom library features? Regards, Tomas
Yes, I'm using custom library feature and I don't have any problems. What problems do you have? Can you share your model that demonstrates the issue?
-------------------------------------------------- Tomas — 11.02.10 Hi again, ok i have finally done that it works between classes. Now I have added the class that contains this Function into Library. I've created a new model exact to the previous one, I dropped the new library AOC and while compiling i got an error : the method myFunction() from the type Functions is not visible. Should I export this class to the library in spacial way ? what can be a problem here? Any ideas, Thanks in advance Tomas -------------------------------- Hi, Tomas. I think you must to change the "Access:" to "public", into "Properties" tab of your method ( myFunction() ). Regards, Almir Campos Sao Paulo, Brazil. http://tech.zona8.com.br
Hi Greg, Almir Almirs' solution works well to get rid of this "not visible" problem, however it still doesn't work. The file is here http://www.speedyshare.com/files/20981140/Model5.zip its obviously just a simple example, my final project is way more complicated. So, when you run this model it works fine, pedGoto object calls function from different object class and get back either line1 or line2 as result with 50% or probability. Now I would like to export this "Funkcje" class to a library, then i am creating a complete new model and copy the content of main class to a new model (flowchart) i am draggin the library icon, and changing the reference according to the Library name. Before i got "not visible" error, now it compiles well, but while starting it gives me: java.lang.NullPointerException Exception during discrete event execution: java.lang.NullPointerException at model3.Functions.myFunction(Functions.java:64) at model5.Main._pedGoTo_target_xjal(Main.java:368) at model5.Main$2.target(Main.java:160) at com.xj.anylogic.libraries.pedestrian.PedGoTo._hold_onEnter_xjal(Unknown Source) at com.xj.anylogic.libraries.pedestrian.PedGoTo$e.onEnter(Unknown Source) at com.xj.anylogic.libraries.enterprise.Hold$2.getEntity(Hold.java:496) at com.xj.anylogic.libraries.enterprise.InPort.getEntity(InPort.java:104) at com.xj.anylogic.libraries.pedestrian.PedCmdGoTo.executeActionOf(Unknown Source) at com.xj.anylogic.engine.EventCondition.execute(Unknown Source) at com.xj.anylogic.engine.Engine.k(Unknown Source) at com.xj.anylogic.engine.Engine.a(Unknown Source) at com.xj.anylogic.engine.Engine$a.run(Unknown Source) So it clearly says that you can't use the same reference way while moving active object class to another package. I am pretty sure that solution is very simple, but I could not find it. Thank you very much in advance, Best regards, Tomas.
Hi all I have checked that the problem is that method get_Main() works when the function is n the same package if not it doesn't , can anyone tell me how to replace this mathod with another that will work while exported into library ?? Thanks in advance, Tomas
Hi Tomas, If you create objects that then will be exported as library, you should not use the reference to another active objects. Each object should be independent from others.