How to define programmatically an extended parameter?

View: New views
7 Messages — Rating Filter:   Alert me  

How to define programmatically an extended parameter?

by John Tranier :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi all,

Does somebody know how to add values in the combo-box of an extended  
parameter with Java? Or to build in Java an extended parameter that  
can be seen in the parameters GUI?

My simulation model takes a script file as parameter (for  
initialization).
Right now I'm using an extended parameter, so I can set all the  
possible script files and select the one to use at runtime with the  
combo-box.
This works, but requires to update the parameter file each time I add  
a new script file.
Ideally I would like the combo-box to be automatically filled with all  
the script files that are in a specific directory.

I looked into the Repast sources but I couldn't find myself a solution.

Thanks in advance,
John

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Repast-interest mailing list
Repast-interest@...
https://lists.sourceforge.net/lists/listinfo/repast-interest

Re: How to define programmatically an extended parameter?

by Nick Collier-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

There are some docs on that here:

http://repast.sourceforge.net/docs/reference/SIM/GUI%20Parameters%20and%20Probes.html

in particular if you have a value list attribute the values in that  
list should appear in a combobox.

Nick

On Sep 3, 2009, at 7:41 AM, John Tranier wrote:

> Hi all,
>
> Does somebody know how to add values in the combo-box of an extended
> parameter with Java? Or to build in Java an extended parameter that
> can be seen in the parameters GUI?
>
> My simulation model takes a script file as parameter (for
> initialization).
> Right now I'm using an extended parameter, so I can set all the
> possible script files and select the one to use at runtime with the
> combo-box.
> This works, but requires to update the parameter file each time I add
> a new script file.
> Ideally I would like the combo-box to be automatically filled with all
> the script files that are in a specific directory.
>
> I looked into the Repast sources but I couldn't find myself a  
> solution.
>
> Thanks in advance,
> John
>
> ------------------------------------------------------------------------------
> Let Crystal Reports handle the reporting - Free Crystal Reports 2008  
> 30-Day
> trial. Simplify your report design, integration and deployment - and  
> focus on
> what you do best, core application coding. Discover what's new with
> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
> _______________________________________________
> Repast-interest mailing list
> Repast-interest@...
> https://lists.sourceforge.net/lists/listinfo/repast-interest


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Repast-interest mailing list
Repast-interest@...
https://lists.sourceforge.net/lists/listinfo/repast-interest

Re: How to define programmatically an extended parameter?

by John Tranier :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Thanks for you answer Nick.
Actually, I've already been through that doc, and I'm currently using a value list attribute.
My point is that I've to fill the values manually in the parameter xml file while I would like that values to be automatically loaded (basically I want the list to contain all the files existing in a specific directory).

So my question was: how to add values in the list using java programming?

John


Le 4 sept. 09 à 15:26, Nick Collier a écrit :

There are some docs on that here:

http://repast.sourceforge.net/docs/reference/SIM/GUI%20Parameters%20and%20Probes.html

in particular if you have a value list attribute the values in that list should appear in a combobox.

Nick

On Sep 3, 2009, at 7:41 AM, John Tranier wrote:

Hi all,

Does somebody know how to add values in the combo-box of an extended
parameter with Java? Or to build in Java an extended parameter that
can be seen in the parameters GUI?

My simulation model takes a script file as parameter (for
initialization).
Right now I'm using an extended parameter, so I can set all the
possible script files and select the one to use at runtime with the
combo-box.
This works, but requires to update the parameter file each time I add
a new script file.
Ideally I would like the combo-box to be automatically filled with all
the script files that are in a specific directory.

I looked into the Repast sources but I couldn't find myself a solution.

Thanks in advance,
John

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Repast-interest mailing list
Repast-interest@...
https://lists.sourceforge.net/lists/listinfo/repast-interest



--
Dr. John Tranier
Institute for Computing and Information Sciences
Utrecht University 
tel: +31 (30) 253 6761 
email: tranier@... 


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Repast-interest mailing list
Repast-interest@...
https://lists.sourceforge.net/lists/listinfo/repast-interest

Re: How to define programmatically an extended parameter?

by Nick Collier-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Ah, I see. I should have read the question more closely. Unfortunately, there's no straight-forward way to do this at the moment.

Two workarounds that come to mind are:

1. Running some code before the scenario loads to re-write the extended parameters file appropriately. We often use velocity for things like this -- the idea is that the static parts of the file form a template and then you can fill in the rest programmatically. See, http://velocity.apache.org/ for more. The standard way to run code before a scenario loads is to use a ModelInitializer (see the javadocs). You specify the model initalizer with a line in your scenario file like:

<model.initializer class="repast.simphony.demo.mousetrap.TrapInitializer" />

The initializer should be run before the parameters file is parsed so any changes should show up.

2. The list of items that get put into the combobox comes from the list returned by ParameterSchema.getConstrainingList() method. If you really want to poke around in the code, you could hijack this list and add what you need.

Obviously, neither of these is ideal but some changes to parameters are in the works so hopefully this will be easier in the future.

Nick

On Sep 4, 2009, at 9:36 AM, John Tranier wrote:

Thanks for you answer Nick.
Actually, I've already been through that doc, and I'm currently using a value list attribute.
My point is that I've to fill the values manually in the parameter xml file while I would like that values to be automatically loaded (basically I want the list to contain all the files existing in a specific directory).

So my question was: how to add values in the list using java programming?

John


Le 4 sept. 09 à 15:26, Nick Collier a écrit :

There are some docs on that here:

http://repast.sourceforge.net/docs/reference/SIM/GUI%20Parameters%20and%20Probes.html

in particular if you have a value list attribute the values in that list should appear in a combobox.

Nick

On Sep 3, 2009, at 7:41 AM, John Tranier wrote:

Hi all,

Does somebody know how to add values in the combo-box of an extended
parameter with Java? Or to build in Java an extended parameter that
can be seen in the parameters GUI?

My simulation model takes a script file as parameter (for
initialization).
Right now I'm using an extended parameter, so I can set all the
possible script files and select the one to use at runtime with the
combo-box.
This works, but requires to update the parameter file each time I add
a new script file.
Ideally I would like the combo-box to be automatically filled with all
the script files that are in a specific directory.

I looked into the Repast sources but I couldn't find myself a solution.

Thanks in advance,
John

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Repast-interest mailing list
Repast-interest@...
https://lists.sourceforge.net/lists/listinfo/repast-interest



--
Dr. John Tranier
Institute for Computing and Information Sciences
Utrecht University 
tel: +31 (30) 253 6761 
email: tranier@... 



------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Repast-interest mailing list
Repast-interest@...
https://lists.sourceforge.net/lists/listinfo/repast-interest

Re: How to define programmatically an extended parameter?

by John Tranier :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Following your answer, Nick, I've implemented your solution 1. using velocity.
It works, but... the parameters file is parsed before the model initializer is executed. So the changes do not appear for the current run but the next one.

Until now I've used this solution, just running two times repast when I wanted to add a new scenario.
But now I would like to find a more elegant solution in order to distribute the model.

I've tried your 2nd solution, but the problem is that the RunEnvironment is not already initialized when the Model Initializer is executed. So I don't know how to access to the ParameterSchema in order to update it ...

Is there another trick you can think about to solve this problem?

Thanks in advance,
John


Le 4 sept. 09 à 17:14, Nick Collier a écrit :

Ah, I see. I should have read the question more closely. Unfortunately, there's no straight-forward way to do this at the moment.

Two workarounds that come to mind are:

1. Running some code before the scenario loads to re-write the extended parameters file appropriately. We often use velocity for things like this -- the idea is that the static parts of the file form a template and then you can fill in the rest programmatically. See, http://velocity.apache.org/ for more. The standard way to run code before a scenario loads is to use a ModelInitializer (see the javadocs). You specify the model initalizer with a line in your scenario file like:

<model.initializer class="repast.simphony.demo.mousetrap.TrapInitializer" />

The initializer should be run before the parameters file is parsed so any changes should show up.

2. The list of items that get put into the combobox comes from the list returned by ParameterSchema.getConstrainingList() method. If you really want to poke around in the code, you could hijack this list and add what you need.

Obviously, neither of these is ideal but some changes to parameters are in the works so hopefully this will be easier in the future.

Nick

On Sep 4, 2009, at 9:36 AM, John Tranier wrote:

Thanks for you answer Nick.
Actually, I've already been through that doc, and I'm currently using a value list attribute.
My point is that I've to fill the values manually in the parameter xml file while I would like that values to be automatically loaded (basically I want the list to contain all the files existing in a specific directory).

So my question was: how to add values in the list using java programming?

John


Le 4 sept. 09 à 15:26, Nick Collier a écrit :

There are some docs on that here:

http://repast.sourceforge.net/docs/reference/SIM/GUI%20Parameters%20and%20Probes.html

in particular if you have a value list attribute the values in that list should appear in a combobox.

Nick

On Sep 3, 2009, at 7:41 AM, John Tranier wrote:

Hi all,

Does somebody know how to add values in the combo-box of an extended
parameter with Java? Or to build in Java an extended parameter that
can be seen in the parameters GUI?

My simulation model takes a script file as parameter (for
initialization).
Right now I'm using an extended parameter, so I can set all the
possible script files and select the one to use at runtime with the
combo-box.
This works, but requires to update the parameter file each time I add
a new script file.
Ideally I would like the combo-box to be automatically filled with all
the script files that are in a specific directory.

I looked into the Repast sources but I couldn't find myself a solution.

Thanks in advance,
John

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Repast-interest mailing list
Repast-interest@...
https://lists.sourceforge.net/lists/listinfo/repast-interest



--
Dr. John Tranier
Institute for Computing and Information Sciences
Utrecht University 
tel: +31 (30) 253 6761 
email: tranier@... 





------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Repast-interest mailing list
Repast-interest@...
https://lists.sourceforge.net/lists/listinfo/repast-interest

Re: How to define programmatically an extended parameter?

by Nick Collier-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I should have realized that the initializer would be run after the file is parsed. The initializer assumes that everything is setup and workable and so it runs after all that happens. 

The actual file that reads the extended_params file is repast.simphony.parameter.ParametersParser. One thing you could do I suppose is create your own version of this that would do the re-write before it loaded the parameters. Your version would have the same name and package and need to appear before the default version during class loading. There's been a few message recently on the list about that. See those with the subject:  Re: [Repast-interest] Could one .shp (ArcGIS) shape file be loaded  twice?

The only other thing I can think of is doing the re-write before simphony itself loads. For that you'd write your own class with a main method, call the re-writing stuff there and then call RepastMain.main. Obviously not ideal, but its all I can think of at the moment. It may not work if you use the packager / installer wizard to distribute the model. I don't know much about that but perhaps there some way to specify the main class in that.

Nick

On Oct 27, 2009, at 7:00 AM, John Tranier wrote:

Following your answer, Nick, I've implemented your solution 1. using velocity.
It works, but... the parameters file is parsed before the model initializer is executed. So the changes do not appear for the current run but the next one.

Until now I've used this solution, just running two times repast when I wanted to add a new scenario.
But now I would like to find a more elegant solution in order to distribute the model.

I've tried your 2nd solution, but the problem is that the RunEnvironment is not already initialized when the Model Initializer is executed. So I don't know how to access to the ParameterSchema in order to update it ...

Is there another trick you can think about to solve this problem?

Thanks in advance,
John


Le 4 sept. 09 à 17:14, Nick Collier a écrit :

Ah, I see. I should have read the question more closely. Unfortunately, there's no straight-forward way to do this at the moment.

Two workarounds that come to mind are:

1. Running some code before the scenario loads to re-write the extended parameters file appropriately. We often use velocity for things like this -- the idea is that the static parts of the file form a template and then you can fill in the rest programmatically. See, http://velocity.apache.org/ for more. The standard way to run code before a scenario loads is to use a ModelInitializer (see the javadocs). You specify the model initalizer with a line in your scenario file like:

<model.initializer class="repast.simphony.demo.mousetrap.TrapInitializer" />

The initializer should be run before the parameters file is parsed so any changes should show up.

2. The list of items that get put into the combobox comes from the list returned by ParameterSchema.getConstrainingList() method. If you really want to poke around in the code, you could hijack this list and add what you need.

Obviously, neither of these is ideal but some changes to parameters are in the works so hopefully this will be easier in the future.

Nick

On Sep 4, 2009, at 9:36 AM, John Tranier wrote:

Thanks for you answer Nick.
Actually, I've already been through that doc, and I'm currently using a value list attribute.
My point is that I've to fill the values manually in the parameter xml file while I would like that values to be automatically loaded (basically I want the list to contain all the files existing in a specific directory).

So my question was: how to add values in the list using java programming?

John


Le 4 sept. 09 à 15:26, Nick Collier a écrit :

There are some docs on that here:

http://repast.sourceforge.net/docs/reference/SIM/GUI%20Parameters%20and%20Probes.html

in particular if you have a value list attribute the values in that list should appear in a combobox.

Nick

On Sep 3, 2009, at 7:41 AM, John Tranier wrote:

Hi all,

Does somebody know how to add values in the combo-box of an extended
parameter with Java? Or to build in Java an extended parameter that
can be seen in the parameters GUI?

My simulation model takes a script file as parameter (for
initialization).
Right now I'm using an extended parameter, so I can set all the
possible script files and select the one to use at runtime with the
combo-box.
This works, but requires to update the parameter file each time I add
a new script file.
Ideally I would like the combo-box to be automatically filled with all
the script files that are in a specific directory.

I looked into the Repast sources but I couldn't find myself a solution.

Thanks in advance,
John

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Repast-interest mailing list
Repast-interest@...
https://lists.sourceforge.net/lists/listinfo/repast-interest



--
Dr. John Tranier
Institute for Computing and Information Sciences
Utrecht University 
tel: +31 (30) 253 6761 
email: tranier@... 






------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Repast-interest mailing list
Repast-interest@...
https://lists.sourceforge.net/lists/listinfo/repast-interest

Re: How to define programmatically an extended parameter?

by John Tranier :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Thank you again Nick.
I've made it by redefining the ParametersParser.class.

I've first tried to make my own main, but I couldn't make it work because of a runtime classpath problem (when I add my bin directory then the classLoader cannot find the Context class anymore ?!).
Anyway, only one solution is enough for me ;-)

John

Le 28 oct. 09 à 16:14, Nick Collier a écrit :

I should have realized that the initializer would be run after the file is parsed. The initializer assumes that everything is setup and workable and so it runs after all that happens. 

The actual file that reads the extended_params file is repast.simphony.parameter.ParametersParser. One thing you could do I suppose is create your own version of this that would do the re-write before it loaded the parameters. Your version would have the same name and package and need to appear before the default version during class loading. There's been a few message recently on the list about that. See those with the subject:  Re: [Repast-interest] Could one .shp (ArcGIS) shape file be loaded  twice?

The only other thing I can think of is doing the re-write before simphony itself loads. For that you'd write your own class with a main method, call the re-writing stuff there and then call RepastMain.main. Obviously not ideal, but its all I can think of at the moment. It may not work if you use the packager / installer wizard to distribute the model. I don't know much about that but perhaps there some way to specify the main class in that.

Nick

On Oct 27, 2009, at 7:00 AM, John Tranier wrote:

Following your answer, Nick, I've implemented your solution 1. using velocity.
It works, but... the parameters file is parsed before the model initializer is executed. So the changes do not appear for the current run but the next one.

Until now I've used this solution, just running two times repast when I wanted to add a new scenario.
But now I would like to find a more elegant solution in order to distribute the model.

I've tried your 2nd solution, but the problem is that the RunEnvironment is not already initialized when the Model Initializer is executed. So I don't know how to access to the ParameterSchema in order to update it ...

Is there another trick you can think about to solve this problem?

Thanks in advance,
John


Le 4 sept. 09 à 17:14, Nick Collier a écrit :

Ah, I see. I should have read the question more closely. Unfortunately, there's no straight-forward way to do this at the moment.

Two workarounds that come to mind are:

1. Running some code before the scenario loads to re-write the extended parameters file appropriately. We often use velocity for things like this -- the idea is that the static parts of the file form a template and then you can fill in the rest programmatically. See, http://velocity.apache.org/ for more. The standard way to run code before a scenario loads is to use a ModelInitializer (see the javadocs). You specify the model initalizer with a line in your scenario file like:

<model.initializer class="repast.simphony.demo.mousetrap.TrapInitializer" />

The initializer should be run before the parameters file is parsed so any changes should show up.

2. The list of items that get put into the combobox comes from the list returned by ParameterSchema.getConstrainingList() method. If you really want to poke around in the code, you could hijack this list and add what you need.

Obviously, neither of these is ideal but some changes to parameters are in the works so hopefully this will be easier in the future.

Nick

On Sep 4, 2009, at 9:36 AM, John Tranier wrote:

Thanks for you answer Nick.
Actually, I've already been through that doc, and I'm currently using a value list attribute.
My point is that I've to fill the values manually in the parameter xml file while I would like that values to be automatically loaded (basically I want the list to contain all the files existing in a specific directory).

So my question was: how to add values in the list using java programming?

John


Le 4 sept. 09 à 15:26, Nick Collier a écrit :

There are some docs on that here:

http://repast.sourceforge.net/docs/reference/SIM/GUI%20Parameters%20and%20Probes.html

in particular if you have a value list attribute the values in that list should appear in a combobox.

Nick

On Sep 3, 2009, at 7:41 AM, John Tranier wrote:

Hi all,

Does somebody know how to add values in the combo-box of an extended
parameter with Java? Or to build in Java an extended parameter that
can be seen in the parameters GUI?

My simulation model takes a script file as parameter (for
initialization).
Right now I'm using an extended parameter, so I can set all the
possible script files and select the one to use at runtime with the
combo-box.
This works, but requires to update the parameter file each time I add
a new script file.
Ideally I would like the combo-box to be automatically filled with all
the script files that are in a specific directory.

I looked into the Repast sources but I couldn't find myself a solution.

Thanks in advance,
John

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Repast-interest mailing list
Repast-interest@...
https://lists.sourceforge.net/lists/listinfo/repast-interest



--
Dr. John Tranier
Institute for Computing and Information Sciences
Utrecht University 
tel: +31 (30) 253 6761 
email: tranier@... 







--
Dr. John Tranier
Institute for Computing and Information Sciences
Utrecht University 
tel: +31 (30) 253 6761 
email: tranier@... 


------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Repast-interest mailing list
Repast-interest@...
https://lists.sourceforge.net/lists/listinfo/repast-interest