我在NetLogo中运行我的模型,它工作正常。当我尝试运行一些在 xml 文件中定义并使用此脚本启动的实验时,会发生一件奇怪的事情:
java -Xmx4096m -Dfile.encoding=UTF-8 -cp /Applications/NetLogo 5.3/Java/netlogo-mac-app.jar org.nlogo.headless.Main --model mymodel.nlogo --setup-file experiments-.25-times-per-day.xml
Exception in thread "main" Expected a constant. at position 0 in
at org.nlogo.compiler.CompilerExceptionThrowers$.exception(CompilerExceptionThrowers.scala:26)
at org.nlogo.compiler.ConstantParser.readConstantPrefix(ConstantParser.scala:115)
at org.nlogo.compiler.ConstantParser.getConstantValue(ConstantParser.scala:66)
at org.nlogo.compiler.Compiler$$anonfun$readFromString$1.apply(Compiler.scala:92)
at scala.Either$RightProjection.getOrElse(Either.scala:479)
at org.nlogo.compiler.Compiler$.readFromString(Compiler.scala:91)
at org.nlogo.nvm.DefaultCompilerServices.readFromString(DefaultCompilerServices.scala:25)
at org.nlogo.lab.ProtocolLoader$Loader$$anonfun$readEnumeratedValueSetElement$1$1.apply(ProtocolLoader.scala:84)
at org.nlogo.lab.ProtocolLoader$Loader$$anonfun$readEnumeratedValueSetElement$1$1.apply(ProtocolLoader.scala:83)
at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:233)
at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:233)
at scala.collection.LinearSeqOptimized$class.foreach(LinearSeqOptimized.scala:59)
at scala.collection.immutable.List.foreach(List.scala:76)
at scala.collection.TraversableLike$class.map(TraversableLike.scala:233)
at scala.collection.immutable.List.map(List.scala:76)
at org.nlogo.lab.ProtocolLoader$Loader.readEnumeratedValueSetElement$1(ProtocolLoader.scala:83)
at org.nlogo.lab.ProtocolLoader$Loader$$anonfun$valueSets$1$1.apply(ProtocolLoader.scala:88)
at org.nlogo.lab.ProtocolLoader$Loader$$anonfun$valueSets$1$1.apply(ProtocolLoader.scala:85)
at scala.collection.TraversableLike$$anonfun$flatMap$1.apply(TraversableLike.scala:239)
at scala.collection.TraversableLike$$anonfun$flatMap$1.apply(TraversableLike.scala:239)
at scala.collection.LinearSeqOptimized$class.foreach(LinearSeqOptimized.scala:59)
at scala.collection.immutable.List.foreach(List.scala:76)
at scala.collection.TraversableLike$class.flatMap(TraversableLike.scala:239)
at scala.collection.immutable.List.flatMap(List.scala:76)
at org.nlogo.lab.ProtocolLoader$Loader.valueSets$1(ProtocolLoader.scala:85)
at org.nlogo.lab.ProtocolLoader$Loader.readProtocolElement(ProtocolLoader.scala:102)
at org.nlogo.lab.ProtocolLoader$Loader$$anonfun$load$1.apply(ProtocolLoader.scala:63)
at org.nlogo.lab.ProtocolLoader$Loader$$anonfun$load$1.apply(ProtocolLoader.scala:63)
at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:233)
at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:233)
at scala.collection.LinearSeqOptimized$class.foreach(LinearSeqOptimized.scala:59)
at scala.collection.immutable.List.foreach(List.scala:76)
at scala.collection.TraversableLike$class.map(TraversableLike.scala:233)
at scala.collection.immutable.List.map(List.scala:76)
at org.nlogo.lab.ProtocolLoader$Loader.load(ProtocolLoader.scala:63)
at org.nlogo.lab.ProtocolLoader.loadOne(ProtocolLoader.scala:17)
at org.nlogo.lab.Lab.newWorker(Lab.scala:27)
at org.nlogo.lab.Lab.run(Lab.scala:42)
at org.nlogo.headless.Main$.runExperiment(Main.scala:24)
at org.nlogo.headless.Main$$anonfun$main$1.apply(Main.scala:14)
at org.nlogo.headless.Main$$anonfun$main$1.apply(Main.scala:14)
at scala.Option.foreach(Option.scala:197)
at org.nlogo.headless.Main$.main(Main.scala:14)
at org.nlogo.headless.Main.main(Main.scala)
我不明白从错误消息中查看哪里,因为它没有指向模型的任何特定部分 - 据我所知......
这是我的安装文件的摘录:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE experiments SYSTEM "behaviorspace.dtd">
<experiments>
<experiment name="india-hagerstrand-one-at-random" repetitions="100" runMetricsEveryStep="false">
<setup>setup</setup>
<go>go</go>
<enumeratedValueSet variable="dataset">
<value value=""india""/>
</enumeratedValueSet>
<enumeratedValueSet variable="schedule">
<value value=""one at random""/>
</enumeratedValueSet>
<enumeratedValueSet variable="logic">
<value value=""hagerstrand""/>
</enumeratedValueSet>
<enumeratedValueSet variable="debug?">
<value value="false"/>
</enumeratedValueSet>
<enumeratedValueSet variable="ticks-in-semester">
<value value="45"/>
</enumeratedValueSet>
<enumeratedValueSet variable="experiment">
<value value="experiment-.25"/>
</enumeratedValueSet>
</experiment>
</experiments>
仅当我从 xml 文件加载实验时才会发生错误,否则它会起作用。我已经根据行为空间验证了我的 xml.dtd它似乎是正确的。
错误是由 XML 代码引起的,特别是在封装字符串时有一行错误:
<enumeratedValueSet variable="experiment">
<value value=""experiments-4""/>
</enumeratedValueSet>