Error while trying to run codes from behaviour space interface

45 views
Skip to first unread message

Biancap0pp Ogbo

unread,
Sep 24, 2021, 10:48:56 AM9/24/21
to netlogo-users
Please I need help, I keep getting this error while trying to run codes from behaviour space interface.


NetLogo is unable to supply you with more details about this error.  Please report the problem 
contents of this window into your report. 


This isn't something you can use "set" on. at position 155 in 
 at org.nlogo.core.Fail$.exception(Fail.scala:27)
 at org.nlogo.core.Fail$.exception(Fail.scala:25)
 at org.nlogo.core.Fail$.exception(Fail.scala:23)
 at org.nlogo.compile.middle.SetVisitor.$anonfun$visitStatement$1(SetVisitor.scala:28)
 at scala.Option.getOrElse(Option.scala:189)
 at org.nlogo.compile.middle.SetVisitor.visitStatement(SetVisitor.scala:28)
 at org.nlogo.compile.api.Statement.accept(AstNode.scala:94)
 at org.nlogo.compile.api.DefaultAstVisitor.$anonfun$visitStatements$1(AstVisitor.scala:32)
 at org.nlogo.compile.api.DefaultAstVisitor.$anonfun$visitStatements$1$adapted(AstVisitor.scala:32)
 at scala.collection.mutable.ResizableArray.foreach(ResizableArray.scala:62)
 at scala.collection.mutable.ResizableArray.foreach$(ResizableArray.scala:55)
 at scala.collection.mutable.ArrayBuffer.foreach(ArrayBuffer.scala:49)
 at org.nlogo.compile.api.DefaultAstVisitor.visitStatements(AstVisitor.scala:32)
 at org.nlogo.compile.api.Statements.accept(AstNode.scala:70)
 at org.nlogo.compile.api.DefaultAstVisitor.visitProcedureDefinition(AstVisitor.scala:27)
 at org.nlogo.compile.api.ProcedureDefinition.accept(AstNode.scala:50)
 at org.nlogo.compile.middle.MiddleEnd$.$anonfun$middleEnd$3(MiddleEnd.scala:47)
 at org.nlogo.compile.middle.MiddleEnd$.$anonfun$middleEnd$3$adapted(MiddleEnd.scala:40)
 at scala.collection.immutable.List.foreach(List.scala:431)
 at org.nlogo.compile.middle.MiddleEnd$.middleEnd(MiddleEnd.scala:40)
 at org.nlogo.compile.CompilerMain$.compile(CompilerMain.scala:61)
 at org.nlogo.compile.Compiler.compileMoreCode(Compiler.scala:85)
 at org.nlogo.compile.Compiler.compileMoreCode(Compiler.scala:100)
 at org.nlogo.workspace.Evaluator.invokeCompiler(Evaluator.scala:159)
 at org.nlogo.workspace.Evaluator.evaluateCommands(Evaluator.scala:20)
 at org.nlogo.workspace.Evaluating.command(Evaluating.scala:80)
 at org.nlogo.workspace.Evaluating.command$(Evaluating.scala:79)
 at org.nlogo.workspace.AbstractWorkspaceScala.command(AbstractWorkspaceScala.scala:26)
 at org.nlogo.headless.HeadlessModelOpener.finish(HeadlessModelOpener.scala:112)
 at org.nlogo.headless.HeadlessModelOpener.openFromModel(HeadlessModelOpener.scala:74)
 at org.nlogo.headless.HeadlessWorkspace.openModel(HeadlessWorkspace.scala:539)
 at org.nlogo.app.App$$anon$1.openCurrentModelIn(App.scala:134)
 at org.nlogo.lab.gui.Supervisor.$anonfun$start$1(Supervisor.scala:98)
 at scala.collection.immutable.Range.foreach$mVc$sp(Range.scala:158)
 at org.nlogo.lab.gui.Supervisor.start(Supervisor.scala:96)
 at org.nlogo.lab.gui.ManagerDialog.run(ManagerDialog.scala:103)
 at org.nlogo.lab.gui.ManagerDialog.$anonfun$runAction$1(ManagerDialog.scala:30)
 at org.nlogo.lab.gui.ManagerDialog$$anon$1.actionPerformed(ManagerDialog.scala:24)
 at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2022)
 at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2348)
 at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
 at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
 at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:252)
 at java.awt.Component.processMouseEvent(Component.java:6539)
 at javax.swing.JComponent.processMouseEvent(JComponent.java:3324)
 at java.awt.Component.processEvent(Component.java:6304)
 at java.awt.Container.processEvent(Container.java:2239)
 at java.awt.Component.dispatchEventImpl(Component.java:4889)
 at java.awt.Container.dispatchEventImpl(Container.java:2297)
 at java.awt.Component.dispatchEvent(Component.java:4711)
 at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4904)
 at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4535)
 at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4476)
 at java.awt.Container.dispatchEventImpl(Container.java:2283)
 at java.awt.Window.dispatchEventImpl(Window.java:2746)
 at java.awt.Component.dispatchEvent(Component.java:4711)
 at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:760)
 at java.awt.EventQueue.access$500(EventQueue.java:97)
 at java.awt.EventQueue$3.run(EventQueue.java:709)
 at java.awt.EventQueue$3.run(EventQueue.java:703)
 at java.security.AccessController.doPrivileged(Native Method)
 at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:74)
 at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:84)
 at java.awt.EventQueue$4.run(EventQueue.java:733)
 at java.awt.EventQueue$4.run(EventQueue.java:731)
 at java.security.AccessController.doPrivileged(Native Method)
 at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:74)
 at java.awt.EventQueue.dispatchEvent(EventQueue.java:730)
 at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:205)
 at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
 at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
 at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
 at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
 at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)

NetLogo 6.2.0
main: org.nlogo.app.AppFrame
thread: AWT-EventQueue-0
OpenJDK Client VM 1.8.0_275 (BellSoft; 1.8.0_275-b01)
operating system: Windows 10 10.0 (x86 processor)
Scala version 2.12.12
JOGL: (3D View not initialized)
OpenGL Graphics: (3D View not initialized)
model: alpha 8 strategies TRYING UPDATED

03:44:18.864 AddInputBoxConstraintEvent (org.nlogo.window.InputBoxWidget) AWT-EventQueue-0
03:44:18.863 AddInputBoxConstraintEvent (org.nlogo.window.InputBoxWidget) AWT-EventQueue-0
03:44:18.863 AddInputBoxConstraintEvent (org.nlogo.window.InputBoxWidget) AWT-EventQueue-0
03:44:18.863 AddInputBoxConstraintEvent (org.nlogo.window.InputBoxWidget) AWT-EventQueue-0
03:44:18.862 AddInputBoxConstraintEvent (org.nlogo.window.InputBoxWidget) AWT-EventQueue-0
03:44:18.862 AddInputBoxConstraintEvent (org.nlogo.window.InputBoxWidget) AWT-EventQueue-0
03:44:18.861 AddInputBoxConstraintEvent (org.nlogo.window.InputBoxWidget) AWT-EventQueue-0
03:44:18.861 AddSliderConstraintEvent (org.nlogo.app.interfacetab.InterfacePanel$$anon$1 (org.nlogo.window.SliderWidget)) AWT-EventQueue-0
03:44:18.860 AddInputBoxConstraintEvent (org.nlogo.window.InputBoxWidget) AWT-EventQueue-0
03:44:18.860 AddInputBoxConstraintEvent (org.nlogo.window.InputBoxWidget) AWT-EventQueue-0

Pradeesh Kumar K V

unread,
Sep 25, 2021, 12:14:01 AM9/25/21
to Biancap0pp Ogbo, netlogo-users
Do you get the error during normal run too? 

--
You received this message because you are subscribed to the Google Groups "netlogo-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to netlogo-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/netlogo-users/208ab9b3-2a28-4aad-b59b-68d4aa7230f7n%40googlegroups.com.

Bianca Ogbo

unread,
Sep 25, 2021, 7:38:13 AM9/25/21
to Pradeesh Kumar K V, netlogo-users
Hello Pradeesh,

Thanks for responding. There is no error during manual run

Pradeesh Kumar K V

unread,
Sep 25, 2021, 9:26:26 AM9/25/21
to Bianca Ogbo, netlogo-users
Ok. I don't know what is causing the issue.

So this is just a guess. The error message posted by you has the following first line "This isn't something you can use "set" on. at position 155 in".

Perhaps the error is getting triggered by one of those lines where you have used 'set' command. Certain input combination maybe somehow affecting this line (i.e. taking it out of its permitted syntax)

My suggestions are:

Print the inputs (in the command center) as the behavior space is running so that you know which was the last set of inputs used before execution stopped.

Use this set of inputs in manual mode to see at what point the error occurs.

Bianca Ogbo

unread,
Sep 25, 2021, 11:06:48 AM9/25/21
to Pradeesh Kumar K V, netlogo-users
This is my entire code, trying to model 2 player game with 8 strategies.

patches-own [strategy]
extensions[matrix table]
globals [m strategies
  h-freq l-freq hp-freq lp-freq hc-freq lc-freq hfake-freq lfake-freq
  average-h average-l average-hp average-lp average-hc average-lc average-hfake average-lfake]

to setup
  clear-all
  set strategies ["HP" "LP" "H" "L" "HC" "LC" "HFAKE" "LFAKE"]
  set m matrix:from-row-list (list
    (list ((b + c - e) / 2)  ((b + c - e) / 2) (a) (b) (b - e - f) (b - e - f) (a - e + h) (a - e + h))
    (list  ((c + b - e) / 2)  ((c + b - e) / 2)  (a)  (b) (c - e + g) (c - e + g) (d + h - e) (d + h - e))
    (list  (a) (a) (a) (b) (a) (b) (a) (b))
    (list  (c) (c) (c) (d) (c) (d) (c) (d))
    (list  (c + f) (b - g) (a) (b) (a) (b) (a) (b))
    (list  (c + f) (b - g) (c) (d) (c) (d) (c) (d))
    (list  (a - h) (d - h) (a) (b) (a) (b) (a) (b))
    (list  (a - h) (d - h) (c) (d) (c) (d) (c) (d))
  )

  setup-patches
  set average-h []
  set average-l []
  set average-hp []
  set average-lp []
  set average-hc []
  set average-lc []
  set average-hfake []
  set average-lfake []
  reset-ticks
end

;; init patches
to setup-patches
  resize-world 0 (L - 1) 0 (L - 1)
  ask patches [
    set strategy one-of strategies
    if strategy = "HP" [
      set pcolor blue
    ]
    if strategy = "LP" [
      set pcolor Orange
    ]
    if strategy = "H" [
      set pcolor green
    ]
    if strategy = "L" [
      set pcolor red
    ]
    if strategy = "HC" [
      set pcolor brown
    ]
    if strategy = "LC" [
      set pcolor cyan
    ]
    if strategy = "HFAKE" [
      set pcolor gray
    ]
    if strategy = "LFAKE" [
      set pcolor yellow
  ]]
end



to go
  play
  if ticks = max-runs [
    stop
  ]

  ;and ticks mod 100 = 0
  if ticks > max-runs - 1000 [
    set average-h lput get-freq "H" average-h
    set average-l lput get-freq "L" average-l
    set average-hp lput get-freq "HP" average-hp
    set average-lp lput get-freq "LP" average-lp
    set average-hc lput get-freq "HC" average-hc
    set average-lc lput get-freq "LC" average-lc
    set average-lfake lput get-freq "LFAKE" average-lfake
    set average-hfake lput get-freq "HFAKE" average-hfake
  ]
  tick
end

to play

  ask one-of patches [

    let myindex position strategy strategies

    let neighbor one-of neighbors4
    let nindex position [strategy] of neighbor strategies

    let random1 random-float 1

    ifelse random1 < mutation-rate [
      set strategy one-of strategies
      update-colour
      stop
    ] [
      if strategy = [strategy] of neighbor [stop]
    ]

    let fitness1 0
    let fitness2 0

    foreach sort neighbors4 [x -> set fitness1 fitness1 + matrix:get m myindex position [strategy] of x strategies]

    ask neighbor [
      foreach sort neighbors4 [x -> set fitness2 fitness2 + matrix:get m nindex position [strategy] of x strategies]
    ]

    let probability 0
    carefully [
      set probability (1 + e ^ ((- beta) * (fitness2 - fitness1))) ^ -1
    ] [
      ifelse (fitness2 - fitness1) > 0 [ set probability 1 ] [ set probability 0 ]
    ]
    if random1 < probability [
      set strategy [strategy] of neighbor
      update-colour
    ]
  ]
end

to update-colour
  if strategy = "H" [ set pcolor green]
  if strategy = "L" [ set pcolor red ]
  if strategy = "HP" [set pcolor blue]
  if strategy = "LP" [set pcolor orange]
  if strategy = "HC" [ set pcolor brown]
  if strategy = "LC" [ set pcolor cyan ]
  if strategy = "HFAKE" [set pcolor gray]
  if strategy = "LFAKE" [set pcolor yellow]
end

to-report get-freq [target]
  report count patches with [strategy = target] / (L ^ 2)
end

to update-plot
  set-current-plot "Strategies"
  clear-plot
  let counts table:counts [ strategy ] of patches
  let sub_strategies sort table:keys counts
  let n length sub_strategies
  set-plot-x-range 0 n
  let step 0.05 ; tweak this to leave no gaps
  (foreach sub_strategies range n [ [s i] ->
    let y table:get counts s
    let xc black
    if s = "H" [ set xc green]
    if s = "L" [ set xc red ]
    if s = "HP" [set xc blue]
    if s = "LP" [set xc orange]
    if s = "HC" [ set xc brown]
    if s = "LC" [ set xc cyan ]
    if s = "HFAKE" [set xc gray]
    if s = "LFAKE" [set xc yellow]
    create-temporary-plot-pen s
    set-plot-pen-mode 1 ; bar mode
    set-plot-pen-color xc
    foreach (range 0 y step) [ _y -> plotxy i _y ]
    set-plot-pen-color black
    plotxy i y
    set-plot-pen-color xc ; to get the right color in the legend
  ])
end

Pradeesh Kumar K V

unread,
Sep 25, 2021, 11:57:37 AM9/25/21
to Bianca Ogbo, netlogo-users
Can you please share the file? Some of the variables are inputs and hence not defined within the code.

Thanks.
Reply all
Reply to author
Forward
0 new messages