0

I am trying to do a similar simulation to this.

Parking randomly in Anylogic

in addition, I would also want to generate graphs for the output i.e total number of cars leaving the car park garage.

I am facing the issue of "Description: Parameter type is not specified" under the "isThereParking" function from the solution above.

Also the error "Description: Void methods cannot return a value.- Function" for the "selectRandomParkinSpace" Function

What should be the return for both these functions?

Thank you for helping!

boolean 
 isThereParking( ~Object~  ) { 

for(ParkingLot p : parkingSpaces){
    if(p.nFree()>0)
        return true;
} 
return false; 
  }

Description: Syntax error, insert "... VariableDeclaratorId" to complete FormalParameterList. - Agent Type

  • where are your functions defined? you can start by removing the ~Object~ so the function will be boolean isThereParking() ... but this may be wrong depending where this is defined – Felipe Jul 13 '19 at 14:17
  • the "object" seems to be the error there are no "~" in the code. With regards to defining the functions in anylogic, isnt it defining it from the function drag and drop under the pallet "agent"? – john zapanta Jul 14 '19 at 05:25
  • you can define it as you say.. but you can place the function in main, in an agent, or maybe you made a class... who knows – Felipe Jul 14 '19 at 14:35
  • I am able to run the simulation now by defining the functions in Main's additional code. However, there is a new problem where taken parking lots is still marked as free. I want to set that state of the ParkingLot to not free after it's selected. However, I cannot find the source code for the ParkingLot model, so I don't know what methods I can call to set the state. Can you help? – john zapanta Jul 15 '19 at 12:15

1 Answers1

0

It seems to me that you are not sure how to properly set up a function with the graphical function symbol. The function name, input and output parameters are defined in the fields of the function's properties section, not in the code itself if you use this module. Have a look at the screenshot:

enter image description here

I marked the name definition, the return parameter definition and then the input parameter definition.

One thing that is unclear to me however is why you want an input parameter of type object, but do not give it a name or use it for anything...not sure what you want to do with this.

Florian
  • 962
  • 1
  • 5
  • 17