|
From: Jonathan O. <jo...@an...> - 2009-07-07 18:17:01
|
Hi Zhanna,
The last line needs to be:
Network net=builder.buildNetwork()
Otherwise, you're trying to access the property buildNetwork in the
build object (which explains the error below). This way you're calling
the buildNetwork method.
Hope that helps,
Jonathan
On Jul 7, 2009, at 12:51 PM, Zhanna * wrote:
> Hi Jonathan,
>
> I tried this piece of code in ModelInitializer (after I added all
> the agents to the context "zhanna"):
>
> // This is a task.
> NetworkGenerator gen=new
> WattsBetaSmallWorldGenerator(0.5,4,false)
> Context context = FindContext("zhanna")
> NetworkBuilder builder= new
> NetworkBuilder("SmallNetwork",context,false)
> builder.setGenerator(gen)
> Network net=builder.buildNetwork
> // End the method.
>
> And I get only nodes on the display without edges and the errror log
> says:
>
> 2009/07/07 19:40:13,795: Tried to call: public static void
> zhanna.ModelInitializer.initializeModel()
> java.lang.reflect.InvocationTargetException
> at zhanna.ModelInitializer$$FastClassByCGLIB$
> $b7b8c339.invoke(<generated>)
> at net.sf.cglib.reflect.FastMethod.invoke(FastMethod.java:53)
> at
> repast
> .simphony
> .engine
> .schedule.DynamicTargetAction.execute(DynamicTargetAction.java:69)
> at
> repast.simphony.engine.controller.ScheduledMethodControllerAction
> $StaticMethodAction.execute(ScheduledMethodControllerAction.java:181)
> at
> repast
> .simphony.engine.schedule.DefaultAction.execute(DefaultAction.java:38)
> at
> repast
> .simphony
> .engine.schedule.ScheduleGroup.executeList(ScheduleGroup.java:184)
> at
> repast
> .simphony.engine.schedule.ScheduleGroup.execute(ScheduleGroup.java:
> 201)
> at
> repast.simphony.engine.schedule.Schedule.execute(Schedule.java:352)
> at repast.simphony.ui.GUIScheduleRunner
> $ScheduleLoopRunnable.run(GUIScheduleRunner.java:53)
> at java.lang.Thread.run(Unknown Source)
> Caused by: groovy.lang.MissingPropertyException: No such property:
> buildNetwork for class:
> repast.simphony.context.space.graph.NetworkBuilder
> at
> org
> .codehaus
> .groovy
> .runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:50)
> at
> org
> .codehaus
> .groovy
> .runtime
> .ScriptBytecodeAdapter.getProperty(ScriptBytecodeAdapter.java:479)
> at
> zhanna.ModelInitializer.initializeModel(ModelInitializer.groovy:137)
> ... 10 more
>
>
>
> 2009/7/7 Jonathan Ozik <jo...@an...>
> Hi Zhanna,
>
> I'm not sure I understand.
> What error is generated when you try to include the line:
> NetworkBuilder builder= new
> NetworkBuilder("SmallNetwork",zhanna,false) ?
>
> Jonathan
>
> On Jul 3, 2009, at 8:24 AM, Zhanna * wrote:
>
>> I tried to put the name of the context as a second argument but
>> then it gave an error in groovy.
>>
>> But is it possible to build a network with a networkBuilder in
>> ModelInitializer.agent ? In ModelInitializer.agent I add all my
>> agents to the context and then try to create the network. But in
>> this line NetworkBuilder builder= new NetworkBuilder("SmallNetwork",
>> zhanna,false) I get an error, because groovy doesn't recognize
>> context name here.
>>
>> Should I create separate context file to be able to build a network?
>>
>> Thanks in advance
>>
>>
>> 2009/7/2 Jonathan Ozik <jo...@an...>
>>
>> Hi,
>>
>> The error:
>>
>> Caused by: groovy.lang.GroovyRuntimeException: Could not find
>> matching constructor for:
>> repast
>> .simphony.context.space.graph.NetworkBuilder(java.lang.String,
>> java.lang.Class, java.lang.Boolean)
>>
>> indicates that the arguments you're providing to the NetworkBuilder
>> constructor are not of the correct type. In fact, the second
>> argument should be a Context object, not a Node class.
>>
>> Hope that helps,
>>
>> Jonathan
>>
>>
>> On Jul 2, 2009, at 7:59 AM, Zhanna * wrote:
>>
>> Hi,
>>
>> I'm trying to build a small world network, but strangely i see only
>> nodes without any edges on the display. The network is not created.
>> What could be the reason and how to fix it?
>> Here is the piece of code :
>>
>> public static void initializeModel() {
>>
>> // Note the simulation time.
>> def time = GetTickCountInTimeUnits()
>>
>>
>> // This is a loop.
>> for (i in 1..GetParameter("initialNumNode")) {
>>
>> // This is a task.
>> Node node = new Node()
>> node.initialize()
>> AddAgentToContext("zhanna", node)
>>
>> }
>>
>> // This is a task.
>> NetworkGenerator gen=new
>> WattsBetaSmallWorldGenerator(0.5,4,false)
>> NetworkBuilder builder= new
>> NetworkBuilder("SmallNetwork",Node,false)
>> builder.setGenerator(gen)
>> Network net=builder.buildNetwork
>> // End the method.
>> return
>>
>> }
>>
>> and i get this errors in error log:
>>
>>
>> java.lang.reflect.InvocationTargetException
>> at zhanna.ModelInitializer$$FastClassByCGLIB$
>> $b7b8c339.invoke(<generated>)
>> at net.sf.cglib.reflect.FastMethod.invoke(FastMethod.java:53)
>> at
>> repast
>> .simphony
>> .engine
>> .schedule.DynamicTargetAction.execute(DynamicTargetAction.java:69)
>> at
>> repast.simphony.engine.controller.ScheduledMethodControllerAction
>> $StaticMethodAction.execute(ScheduledMethodControllerAction.java:181)
>> at
>> repast
>> .simphony.engine.schedule.DefaultAction.execute(DefaultAction.java:
>> 38)
>> at
>> repast
>> .simphony
>> .engine.schedule.ScheduleGroup.executeList(ScheduleGroup.java:184)
>> at
>> repast
>> .simphony.engine.schedule.ScheduleGroup.execute(ScheduleGroup.java:
>> 201)
>> at
>> repast.simphony.engine.schedule.Schedule.execute(Schedule.java:352)
>> at repast.simphony.ui.GUIScheduleRunner
>> $ScheduleLoopRunnable.run(GUIScheduleRunner.java:53)
>> at java.lang.Thread.run(Unknown Source)
>> Caused by: groovy.lang.GroovyRuntimeException: Could not find
>> matching constructor for:
>> repast
>> .simphony.context.space.graph.NetworkBuilder(java.lang.String,
>> java.lang.Class, java.lang.Boolean)
>> at
>> groovy.lang.MetaClassImpl.invokeConstructor(MetaClassImpl.java:1273)
>> at
>> groovy.lang.MetaClassImpl.invokeConstructor(MetaClassImpl.java:1185)
>> at
>> org
>> .codehaus
>> .groovy
>> .runtime.InvokerHelper.invokeConstructorOf(InvokerHelper.java:809)
>> at
>> org
>> .codehaus
>> .groovy
>> .runtime
>> .ScriptBytecodeAdapter.invokeNewN(ScriptBytecodeAdapter.java:230)
>> at
>> zhanna.ModelInitializer.initializeModel(ModelInitializer.groovy:134)
>> ... 10 more
>>
>>
>> Zhanna
>>
>> ------------------------------------------------------------------------------
>> _______________________________________________
>> Repast-interest mailing list
>> Rep...@li...
>> https://lists.sourceforge.net/lists/listinfo/repast-interest
>>
>>
>>
>> ------------------------------------------------------------------------------
>> _______________________________________________
>> Repast-interest mailing list
>> Rep...@li...
>> https://lists.sourceforge.net/lists/listinfo/repast-interest
>
>
|