user7973134
user7973134

Reputation:

Netlogo procedure - return function

The error is

There is already a procedure called FORAGING_EFFORT

Is there another return function in Netlogo or any other solution?

 to-report fp [foraging_effort]
      report (5 / (1 + exp (2 - foraging_effort * 2)))
    end

to-report foraging_effort [forage_min forage_rate energy_level]
  ifelse energy_level <= forage_min
    [ report 0 ]
    [ report (forage_rate * (energy_level - forage_min)) ]
end

Thanks in advance.

Upvotes: 1

Views: 2055

Answers (1)

Nicolas Payette
Nicolas Payette

Reputation: 14972

Everything in NetLogo shares a single namespace. It means that a variable cannot have the same name as a procedure, and vice versa.

In your case, the fp reporter has an argument named foraging_effort, but you also have a reporter called foraging_effort. This is what NetLogo is complaining about.

Normally, I would say: "Simply rename one of the two, and you should be good to go," but the way you phrased your question makes me suspect there might be something else going on. Is it possible that you wanted to call the foraging_effort reporter from within your fp reporter? In that case, you probably don't need the argument to the reporter, and you should remove the [foraging_effort] part after to-report fp.

Upvotes: 1

Related Questions