Quantcast

My code dose not stop using "RunEnvironment.getInstance().endAt(100)"

classic Classic list List threaded Threaded
14 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

My code dose not stop using "RunEnvironment.getInstance().endAt(100)"

Elham Foruzan
Hello,

My code had some problem with intialization when I was using the countiuos projection. I just used the grid, and it works now. However, the program is not finished at tick that I tell it to stop. For example, As you can see, when I ask it to stop at tick 100, it don't stop and I should stop it from run time simulator. 

Also, may I ask some body explain how can I plot a characterestic of specific agent (e.g. coustomer 1 ) using non-aggregated option in run time simulator. I am assuming that it is the way to do that, But I appreciate if you explain if there is another way as well. 
Thank you very much. 
    
  package smartGrids;

import repast.simphony.engine.schedule.ScheduledMethod;

import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Collection;

import repast.simphony.context.Context;
import repast.simphony.context.DefaultContext;
import repast.simphony.context.space.continuous.ContinuousSpaceFactory;
import repast.simphony.context.space.continuous.ContinuousSpaceFactoryFinder;
import repast.simphony.context.space.graph.NetworkBuilder;
import repast.simphony.context.space.grid.GridFactory;
import repast.simphony.context.space.grid.GridFactoryFinder;
import repast.simphony.dataLoader.ContextBuilder;
import repast.simphony.engine.environment.RunEnvironment;
import repast.simphony.essentials.RepastEssentials;
import repast.simphony.parameter.Parameters;
import repast.simphony.space.continuous.ContinuousSpace;
import repast.simphony.space.continuous.NdPoint;
import repast.simphony.space.continuous.RandomCartesianAdder;
import repast.simphony.space.grid.Grid;
import repast.simphony.space.grid.GridBuilderParameters;
import repast.simphony.space.grid.SimpleGridAdder;
import repast.simphony.space.grid.WrapAroundBorders;

public class smartGridsBuilder implements ContextBuilder<Object> {
ArrayList<Agent> allAgents = new ArrayList<Agent>();
@Override
public Context build ( Context < Object > context ) {
context.setId("smartGrids");
 
GridFactory gridFactory = GridFactoryFinder.createGridFactory(null);
Grid<Object> grid = gridFactory.createGrid("grid",context,
new GridBuilderParameters<Object>(new WrapAroundBorders(),
new SimpleGridAdder<Object>(), true, 100, 100));
 
 
  ContinuousSpaceFactory spaceFactory = ContinuousSpaceFactoryFinder
.createContinuousSpaceFactory(null);
ContinuousSpace<Object> space = spaceFactory.createContinuousSpace(
"space", context, new RandomCartesianAdder<Object>(),
new repast.simphony.space.continuous.WrapAroundBorders(), 100,
100);
 
 
 
Parameters params = RunEnvironment.getInstance().getParameters();
double LoadVari = (Double) params.getValue("load_vari");
double load_k = (Double) params.getValue("load_k");
double LoadMaximum  = (Double) params.getValue("Load_Max");
int consumerCount = (Integer) params.getValue("consumer_Count");
for (int i = 0; i < consumerCount; i++) {
consumers.add(new Consumers(space, grid,"Consumer "+(i+1),LoadMaximum,LoadVari,DAY,Qtablec));
context.add(consumers.get(i));
allAgents.add(consumers.get(i));
}
context.add(ac);
for(Object obj: context){
NdPoint pt=space.getLocation(obj);
grid.moveTo(obj, (int)pt.getX(),(int)pt.getY());
System.out.println((int)pt.getX());
}
if (RunEnvironment.getInstance().isBatch()) {
RunEnvironment.getInstance().endAt(100);
}
return context ;
 }

------------------------------------------------------------------------------
Developer Access Program for Intel Xeon Phi Processors
Access to Intel Xeon Phi processor-based developer platforms.
With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today. http://sdm.link/xeonphi
_______________________________________________
Repast-interest mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/repast-interest
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: My code dose not stop using "RunEnvironment.getInstance().endAt(100)"

srcnick
Are you running in batch mode? The endAt call is surrounded with an “if” that checks if you are running in batch mode. As for the plotting, if you have other agents of the same type, I don’t think you can plot just a single one. The non-aggregated plot will plot that characteristic for each agent of that type.

Nick

> On Nov 10, 2016, at 3:55 PM, Elham Foruzan <[hidden email]> wrote:
>
> Hello,
>
> My code had some problem with intialization when I was using the countiuos projection. I just used the grid, and it works now. However, the program is not finished at tick that I tell it to stop. For example, As you can see, when I ask it to stop at tick 100, it don't stop and I should stop it from run time simulator.
>
> Also, may I ask some body explain how can I plot a characterestic of specific agent (e.g. coustomer 1 ) using non-aggregated option in run time simulator. I am assuming that it is the way to do that, But I appreciate if you explain if there is another way as well.
> Thank you very much.
>    
>   package smartGrids;
>
> import repast.simphony.engine.schedule.ScheduledMethod;
>
> import java.text.DecimalFormat;
> import java.util.ArrayList;
> import java.util.Collection;
>
> import repast.simphony.context.Context;
> import repast.simphony.context.DefaultContext;
> import repast.simphony.context.space.continuous.ContinuousSpaceFactory;
> import repast.simphony.context.space.continuous.ContinuousSpaceFactoryFinder;
> import repast.simphony.context.space.graph.NetworkBuilder;
> import repast.simphony.context.space.grid.GridFactory;
> import repast.simphony.context.space.grid.GridFactoryFinder;
> import repast.simphony.dataLoader.ContextBuilder;
> import repast.simphony.engine.environment.RunEnvironment;
> import repast.simphony.essentials.RepastEssentials;
> import repast.simphony.parameter.Parameters;
> import repast.simphony.space.continuous.ContinuousSpace;
> import repast.simphony.space.continuous.NdPoint;
> import repast.simphony.space.continuous.RandomCartesianAdder;
> import repast.simphony.space.grid.Grid;
> import repast.simphony.space.grid.GridBuilderParameters;
> import repast.simphony.space.grid.SimpleGridAdder;
> import repast.simphony.space.grid.WrapAroundBorders;
>
> public class smartGridsBuilder implements ContextBuilder<Object> {
>
>
> ArrayList<Agent> allAgents = new ArrayList<Agent>();
>
>
>
> @Override
> public Context build ( Context < Object > context ) {
> context.setId("smartGrids");
>
> GridFactory gridFactory = GridFactoryFinder.createGridFactory(null);
> Grid<Object> grid = gridFactory.createGrid("grid",context,
> new GridBuilderParameters<Object>(new WrapAroundBorders(),
> new SimpleGridAdder<Object>(), true, 100, 100));
>
>
>   ContinuousSpaceFactory spaceFactory = ContinuousSpaceFactoryFinder
> .createContinuousSpaceFactory(null);
> ContinuousSpace<Object> space = spaceFactory.createContinuousSpace(
> "space", context, new RandomCartesianAdder<Object>(),
> new repast.simphony.space.continuous.WrapAroundBorders(), 100,
> 100);
>
>
>
>
>
>
> Parameters params = RunEnvironment.getInstance().getParameters();
>
> double LoadVari = (Double) params.getValue("load_vari");
> double load_k = (Double) params.getValue("load_k");
> double LoadMaximum  = (Double) params.getValue("Load_Max");
>
> int consumerCount = (Integer) params.getValue("consumer_Count");
> for (int i = 0; i < consumerCount; i++) {
>
> consumers.add(new Consumers(space, grid,"Consumer "+(i+1),LoadMaximum,LoadVari,DAY,Qtablec));
> context.add(consumers.get(i));
> allAgents.add(consumers.get(i));
> }
>
> context.add(ac);
>
>
> for(Object obj: context){
> NdPoint pt=space.getLocation(obj);
> grid.moveTo(obj, (int)pt.getX(),(int)pt.getY());
> System.out.println((int)pt.getX());
> }
>
>
> if (RunEnvironment.getInstance().isBatch()) {
> RunEnvironment.getInstance().endAt(100);
> }
>
> return context ;
>  }
>
> ------------------------------------------------------------------------------
> Developer Access Program for Intel Xeon Phi Processors
> Access to Intel Xeon Phi processor-based developer platforms.
> With one year of Intel Parallel Studio XE.
> Training and support from Colfax.
> Order your platform today. http://sdm.link/xeonphi_______________________________________________
> Repast-interest mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/repast-interest


------------------------------------------------------------------------------
Developer Access Program for Intel Xeon Phi Processors
Access to Intel Xeon Phi processor-based developer platforms.
With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today. http://sdm.link/xeonphi
_______________________________________________
Repast-interest mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/repast-interest
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: My code dose not stop using "RunEnvironment.getInstance().endAt(100)"

Jonas Andersen
Hi Elham,

Just confirmed that I'm successfully using the RunEnvironment.getInstance().endAt(double) to end the simulation at a specific step (called in the ContextBuilder.build(Context).

As for plotting a subset of the agents, I'm using some proxy agents for similar purposes. Perhaps that could also work for you?

Basically, I have another class like MyAgentReportProxy, which is also an agent, but holds a reference to a real MyAgent agent. This proxy then exposes getters for the data I want reported and simply reads the data from the wrapped agent in those getters. A number of MyAgentReportProxy instances are then created in the ContextBuilder with references to different MyAgent instances. You then add the MyAgent to the display as usual but for the reporting you select the MyAgentReportProxy.

Best regards,

Jonas




On 12 November 2016 at 16:30, Nick Collier <[hidden email]> wrote:
Are you running in batch mode? The endAt call is surrounded with an “if” that checks if you are running in batch mode. As for the plotting, if you have other agents of the same type, I don’t think you can plot just a single one. The non-aggregated plot will plot that characteristic for each agent of that type.

Nick

> On Nov 10, 2016, at 3:55 PM, Elham Foruzan <[hidden email]> wrote:
>
> Hello,
>
> My code had some problem with intialization when I was using the countiuos projection. I just used the grid, and it works now. However, the program is not finished at tick that I tell it to stop. For example, As you can see, when I ask it to stop at tick 100, it don't stop and I should stop it from run time simulator.
>
> Also, may I ask some body explain how can I plot a characterestic of specific agent (e.g. coustomer 1 ) using non-aggregated option in run time simulator. I am assuming that it is the way to do that, But I appreciate if you explain if there is another way as well.
> Thank you very much.
>
>   package smartGrids;
>
> import repast.simphony.engine.schedule.ScheduledMethod;
>
> import java.text.DecimalFormat;
> import java.util.ArrayList;
> import java.util.Collection;
>
> import repast.simphony.context.Context;
> import repast.simphony.context.DefaultContext;
> import repast.simphony.context.space.continuous.ContinuousSpaceFactory;
> import repast.simphony.context.space.continuous.ContinuousSpaceFactoryFinder;
> import repast.simphony.context.space.graph.NetworkBuilder;
> import repast.simphony.context.space.grid.GridFactory;
> import repast.simphony.context.space.grid.GridFactoryFinder;
> import repast.simphony.dataLoader.ContextBuilder;
> import repast.simphony.engine.environment.RunEnvironment;
> import repast.simphony.essentials.RepastEssentials;
> import repast.simphony.parameter.Parameters;
> import repast.simphony.space.continuous.ContinuousSpace;
> import repast.simphony.space.continuous.NdPoint;
> import repast.simphony.space.continuous.RandomCartesianAdder;
> import repast.simphony.space.grid.Grid;
> import repast.simphony.space.grid.GridBuilderParameters;
> import repast.simphony.space.grid.SimpleGridAdder;
> import repast.simphony.space.grid.WrapAroundBorders;
>
> public class smartGridsBuilder implements ContextBuilder<Object> {
>
>
>       ArrayList<Agent> allAgents = new ArrayList<Agent>();
>
>
>
>       @Override
>        public Context build ( Context < Object > context ) {
>                context.setId("smartGrids");
>
>                GridFactory gridFactory = GridFactoryFinder.createGridFactory(null);
>                       Grid<Object> grid = gridFactory.createGrid("grid",context,
>                                       new GridBuilderParameters<Object>(new WrapAroundBorders(),
>                                                       new SimpleGridAdder<Object>(), true, 100, 100));
>
>
>                  ContinuousSpaceFactory spaceFactory = ContinuousSpaceFactoryFinder
>                                       .createContinuousSpaceFactory(null);
>                       ContinuousSpace<Object> space = spaceFactory.createContinuousSpace(
>                                       "space", context, new RandomCartesianAdder<Object>(),
>                                       new repast.simphony.space.continuous.WrapAroundBorders(), 100,
>                                       100);
>
>
>
>
>
>
>       Parameters params = RunEnvironment.getInstance().getParameters();
>
>       double LoadVari = (Double) params.getValue("load_vari");
>       double load_k = (Double) params.getValue("load_k");
>       double LoadMaximum  = (Double) params.getValue("Load_Max");
>
>       int consumerCount = (Integer) params.getValue("consumer_Count");
>       for (int i = 0; i < consumerCount; i++) {
>
>               consumers.add(new Consumers(space, grid,"Consumer "+(i+1),LoadMaximum,LoadVari,DAY,Qtablec));
>               context.add(consumers.get(i));
>               allAgents.add(consumers.get(i));
>       }
>
>       context.add(ac);
>
>
>       for(Object obj: context){
>               NdPoint pt=space.getLocation(obj);
>               grid.moveTo(obj, (int)pt.getX(),(int)pt.getY());
>               System.out.println((int)pt.getX());
>       }
>
>
>       if (RunEnvironment.getInstance().isBatch()) {
>                       RunEnvironment.getInstance().endAt(100);
>       }
>
>       return context ;
>  }
>
> ------------------------------------------------------------------------------
> Developer Access Program for Intel Xeon Phi Processors
> Access to Intel Xeon Phi processor-based developer platforms.
> With one year of Intel Parallel Studio XE.
> Training and support from Colfax.
> Order your platform today. http://sdm.link/xeonphi_______________________________________________
> Repast-interest mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/repast-interest


------------------------------------------------------------------------------
Developer Access Program for Intel Xeon Phi Processors
Access to Intel Xeon Phi processor-based developer platforms.
With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today. http://sdm.link/xeonphi
_______________________________________________
Repast-interest mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/repast-interest


------------------------------------------------------------------------------

_______________________________________________
Repast-interest mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/repast-interest
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: My code dose not stop using "RunEnvironment.getInstance().endAt(100)"

srcnick
In reply to this post by srcnick
Jonas’ advice re. proxy agents is a good one if you want to focus on a single agent where there are multiple types of that agent. For aggregate vs. non-aggregate and other data collection info, see:


Nick
On Nov 12, 2016, at 2:23 PM, [hidden email] wrote:

Nick, thank you so much. You are right. I just deleted the if , and it is working now. I should read more about the batch mode and its different with the regular mode. 

I have four type of agents, and more that one agent for each type. I am interested in looking at one agent Q table value, and seeing how it improves. Then If I want to look at just one agent is there a way to do that?
 I didn't get what you said about non-aggregated plot. Then If i have 10 customer agents and I want to look at how they average Q value improve during a day, I should use a aggregated feature. But then what is a difference between non-aggregated and aggregated? Can I see one feature of a specific agent type (e.g. Q value )  for those 10 agents in one plot using non-aggregated function?

Thank you for your prompt reply and  your kind support.




------------------------------------------------------------
Elham Foruzan
PhD Student
Department of Electrical and Computer Engineering
University of Nebraska-Lincoln
214.4 B Scott Engineering 


From: Nick Collier <[hidden email]>
Sent: Saturday, November 12, 2016 8:30:56 AM
To: Elham Foruzan
Cc: [hidden email]
Subject: Re: [Repast-interest] My code dose not stop using "RunEnvironment.getInstance().endAt(100)"
 
Are you running in batch mode? The endAt call is surrounded with an “if” that checks if you are running in batch mode. As for the plotting, if you have other agents of the same type, I don’t think you can plot just a single one. The non-aggregated plot will plot that characteristic for each agent of that type.

Nick

> On Nov 10, 2016, at 3:55 PM, Elham Foruzan <[hidden email]> wrote:
> 
> Hello,
> 
> My code had some problem with intialization when I was using the countiuos projection. I just used the grid, and it works now. However, the program is not finished at tick that I tell it to stop. For example, As you can see, when I ask it to stop at tick 100, it don't stop and I should stop it from run time simulator. 
> 
> Also, may I ask some body explain how can I plot a characterestic of specific agent (e.g. coustomer 1 ) using non-aggregated option in run time simulator. I am assuming that it is the way to do that, But I appreciate if you explain if there is another way as well. 
> Thank you very much. 
>     
>   package smartGrids;
> 
> import repast.simphony.engine.schedule.ScheduledMethod;
> 
> import java.text.DecimalFormat;
> import java.util.ArrayList;
> import java.util.Collection;
> 
> import repast.simphony.context.Context;
> import repast.simphony.context.DefaultContext;
> import repast.simphony.context.space.continuous.ContinuousSpaceFactory;
> import repast.simphony.context.space.continuous.ContinuousSpaceFactoryFinder;
> import repast.simphony.context.space.graph.NetworkBuilder;
> import repast.simphony.context.space.grid.GridFactory;
> import repast.simphony.context.space.grid.GridFactoryFinder;
> import repast.simphony.dataLoader.ContextBuilder;
> import repast.simphony.engine.environment.RunEnvironment;
> import repast.simphony.essentials.RepastEssentials;
> import repast.simphony.parameter.Parameters;
> import repast.simphony.space.continuous.ContinuousSpace;
> import repast.simphony.space.continuous.NdPoint;
> import repast.simphony.space.continuous.RandomCartesianAdder;
> import repast.simphony.space.grid.Grid;
> import repast.simphony.space.grid.GridBuilderParameters;
> import repast.simphony.space.grid.SimpleGridAdder;
> import repast.simphony.space.grid.WrapAroundBorders;
> 
> public class smartGridsBuilder implements ContextBuilder<Object> {
>        
>        
>        ArrayList<Agent> allAgents = new ArrayList<Agent>();
>        
>        
>        
>        @Override
>         public Context build ( Context < Object > context ) {
>                 context.setId("smartGrids");
>                 
>                 GridFactory gridFactory = GridFactoryFinder.createGridFactory(null);
>                        Grid<Object> grid = gridFactory.createGrid("grid",context,
>                                        new GridBuilderParameters<Object>(new WrapAroundBorders(),
>                                                        new SimpleGridAdder<Object>(), true, 100, 100));
>                 
>                 
>                   ContinuousSpaceFactory spaceFactory = ContinuousSpaceFactoryFinder
>                                        .createContinuousSpaceFactory(null);
>                        ContinuousSpace<Object> space = spaceFactory.createContinuousSpace(
>                                        "space", context, new RandomCartesianAdder<Object>(),
>                                        new repast.simphony.space.continuous.WrapAroundBorders(), 100,
>                                        100);
>                 
>                        
>                                 
>                 
>                        
>                        
>        Parameters params = RunEnvironment.getInstance().getParameters();
>        
>        double LoadVari = (Double) params.getValue("load_vari");
>        double load_k = (Double) params.getValue("load_k");
>        double LoadMaximum  = (Double) params.getValue("Load_Max");
>        
>        int consumerCount = (Integer) params.getValue("consumer_Count");
>        for (int i = 0; i < consumerCount; i++) {
>                
>                consumers.add(new Consumers(space, grid,"Consumer "+(i+1),LoadMaximum,LoadVari,DAY,Qtablec));
>                context.add(consumers.get(i));
>                allAgents.add(consumers.get(i));
>        }
>                        
>        context.add(ac);
>        
>                        
>        for(Object obj: context){
>                NdPoint pt=space.getLocation(obj);
>                grid.moveTo(obj, (int)pt.getX(),(int)pt.getY());
>                System.out.println((int)pt.getX());
>        }
>                        
>                        
>        if (RunEnvironment.getInstance().isBatch()) {
>                        RunEnvironment.getInstance().endAt(100);
>        }
>                                
>        return context ;
>  }
>        
> ------------------------------------------------------------------------------
> Developer Access Program for Intel Xeon Phi Processors
> Access to Intel Xeon Phi processor-based developer platforms.
> With one year of Intel Parallel Studio XE.
> Training and support from Colfax.
> Order your platform today. http://sdm.link/xeonphi_______________________________________________
> Repast-interest mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/repast-interest


------------------------------------------------------------------------------
Developer Access Program for Intel Xeon Phi Processors
Access to Intel Xeon Phi processor-based developer platforms.
With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today. http://sdm.link/xeonphi
_______________________________________________
Repast-interest mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/repast-interest


------------------------------------------------------------------------------

_______________________________________________
Repast-interest mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/repast-interest
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: My code dose not stop using "RunEnvironment.getInstance().endAt(100)"

elham.foruzan@huskers.unl.edu
In reply to this post by Jonas Andersen

Thank you very much, Nick and Jonas for your time and help. 



------------------------------------------------------------

Elham Foruzan

PhD Student

Department of Electrical and Computer Engineering

University of Nebraska-Lincoln

214.4 B Scott Engineering 



From: Jonas Andersen <[hidden email]>
Sent: Tuesday, November 15, 2016 1:47:13 AM
To: Nick Collier
Cc: Repast List
Subject: Re: [Repast-interest] My code dose not stop using "RunEnvironment.getInstance().endAt(100)"
 
Hi Elham,

Just confirmed that I'm successfully using the RunEnvironment.getInstance().endAt(double) to end the simulation at a specific step (called in the ContextBuilder.build(Context).

As for plotting a subset of the agents, I'm using some proxy agents for similar purposes. Perhaps that could also work for you?

Basically, I have another class like MyAgentReportProxy, which is also an agent, but holds a reference to a real MyAgent agent. This proxy then exposes getters for the data I want reported and simply reads the data from the wrapped agent in those getters. A number of MyAgentReportProxy instances are then created in the ContextBuilder with references to different MyAgent instances. You then add the MyAgent to the display as usual but for the reporting you select the MyAgentReportProxy.

Best regards,

Jonas




On 12 November 2016 at 16:30, Nick Collier <[hidden email]> wrote:
Are you running in batch mode? The endAt call is surrounded with an “if” that checks if you are running in batch mode. As for the plotting, if you have other agents of the same type, I don’t think you can plot just a single one. The non-aggregated plot will plot that characteristic for each agent of that type.

Nick

> On Nov 10, 2016, at 3:55 PM, Elham Foruzan <[hidden email]> wrote:
>
> Hello,
>
> My code had some problem with intialization when I was using the countiuos projection. I just used the grid, and it works now. However, the program is not finished at tick that I tell it to stop. For example, As you can see, when I ask it to stop at tick 100, it don't stop and I should stop it from run time simulator.
>
> Also, may I ask some body explain how can I plot a characterestic of specific agent (e.g. coustomer 1 ) using non-aggregated option in run time simulator. I am assuming that it is the way to do that, But I appreciate if you explain if there is another way as well.
> Thank you very much.
>
>   package smartGrids;
>
> import repast.simphony.engine.schedule.ScheduledMethod;
>
> import java.text.DecimalFormat;
> import java.util.ArrayList;
> import java.util.Collection;
>
> import repast.simphony.context.Context;
> import repast.simphony.context.DefaultContext;
> import repast.simphony.context.space.continuous.ContinuousSpaceFactory;
> import repast.simphony.context.space.continuous.ContinuousSpaceFactoryFinder;
> import repast.simphony.context.space.graph.NetworkBuilder;
> import repast.simphony.context.space.grid.GridFactory;
> import repast.simphony.context.space.grid.GridFactoryFinder;
> import repast.simphony.dataLoader.ContextBuilder;
> import repast.simphony.engine.environment.RunEnvironment;
> import repast.simphony.essentials.RepastEssentials;
> import repast.simphony.parameter.Parameters;
> import repast.simphony.space.continuous.ContinuousSpace;
> import repast.simphony.space.continuous.NdPoint;
> import repast.simphony.space.continuous.RandomCartesianAdder;
> import repast.simphony.space.grid.Grid;
> import repast.simphony.space.grid.GridBuilderParameters;
> import repast.simphony.space.grid.SimpleGridAdder;
> import repast.simphony.space.grid.WrapAroundBorders;
>
> public class smartGridsBuilder implements ContextBuilder<Object> {
>
>
>       ArrayList<Agent> allAgents = new ArrayList<Agent>();
>
>
>
>       @Override
>        public Context build ( Context < Object > context ) {
>                context.setId("smartGrids");
>
>                GridFactory gridFactory = GridFactoryFinder.createGridFactory(null);
>                       Grid<Object> grid = gridFactory.createGrid("grid",context,
>                                       new GridBuilderParameters<Object>(new WrapAroundBorders(),
>                                                       new SimpleGridAdder<Object>(), true, 100, 100));
>
>
>                  ContinuousSpaceFactory spaceFactory = ContinuousSpaceFactoryFinder
>                                       .createContinuousSpaceFactory(null);
>                       ContinuousSpace<Object> space = spaceFactory.createContinuousSpace(
>                                       "space", context, new RandomCartesianAdder<Object>(),
>                                       new repast.simphony.space.continuous.WrapAroundBorders(), 100,
>                                       100);
>
>
>
>
>
>
>       Parameters params = RunEnvironment.getInstance().getParameters();
>
>       double LoadVari = (Double) params.getValue("load_vari");
>       double load_k = (Double) params.getValue("load_k");
>       double LoadMaximum  = (Double) params.getValue("Load_Max");
>
>       int consumerCount = (Integer) params.getValue("consumer_Count");
>       for (int i = 0; i < consumerCount; i++) {
>
>               consumers.add(new Consumers(space, grid,"Consumer "+(i+1),LoadMaximum,LoadVari,DAY,Qtablec));
>               context.add(consumers.get(i));
>               allAgents.add(consumers.get(i));
>       }
>
>       context.add(ac);
>
>
>       for(Object obj: context){
>               NdPoint pt=space.getLocation(obj);
>               grid.moveTo(obj, (int)pt.getX(),(int)pt.getY());
>               System.out.println((int)pt.getX());
>       }
>
>
>       if (RunEnvironment.getInstance().isBatch()) {
>                       RunEnvironment.getInstance().endAt(100);
>       }
>
>       return context ;
>  }
>
> ------------------------------------------------------------------------------
> Developer Access Program for Intel Xeon Phi Processors
> Access to Intel Xeon Phi processor-based developer platforms.
> With one year of Intel Parallel Studio XE.
> Training and support from Colfax.
> Order your platform today. http://sdm.link/xeonphi_______________________________________________
> Repast-interest mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/repast-interest


------------------------------------------------------------------------------
Developer Access Program for Intel Xeon Phi Processors
Access to Intel Xeon Phi processor-based developer platforms.
With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today. http://sdm.link/xeonphi
_______________________________________________
Repast-interest mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/repast-interest


------------------------------------------------------------------------------

_______________________________________________
Repast-interest mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/repast-interest
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: My code dose not stop using "RunEnvironment.getInstance().endAt(100)"

srcnick
In reply to this post by srcnick
Just to clarify, in case others find this later, the proxy approach is good when you want to focus on a single agent where there are multiple _instances_ of that type of agent, not multiple types as I said below.

Nick
On Nov 15, 2016, at 4:44 PM, Nicholson Collier <[hidden email]> wrote:

Jonas’ advice re. proxy agents is a good one if you want to focus on a single agent where there are multiple types of that agent. For aggregate vs. non-aggregate and other data collection info, see:


Nick
On Nov 12, 2016, at 2:23 PM, [hidden email] wrote:

Nick, thank you so much. You are right. I just deleted the if , and it is working now. I should read more about the batch mode and its different with the regular mode. 

I have four type of agents, and more that one agent for each type. I am interested in looking at one agent Q table value, and seeing how it improves. Then If I want to look at just one agent is there a way to do that?
 I didn't get what you said about non-aggregated plot. Then If i have 10 customer agents and I want to look at how they average Q value improve during a day, I should use a aggregated feature. But then what is a difference between non-aggregated and aggregated? Can I see one feature of a specific agent type (e.g. Q value )  for those 10 agents in one plot using non-aggregated function?

Thank you for your prompt reply and  your kind support.




------------------------------------------------------------
Elham Foruzan
PhD Student
Department of Electrical and Computer Engineering
University of Nebraska-Lincoln
214.4 B Scott Engineering 


From: Nick Collier <[hidden email]>
Sent: Saturday, November 12, 2016 8:30:56 AM
To: Elham Foruzan
Cc: [hidden email]
Subject: Re: [Repast-interest] My code dose not stop using "RunEnvironment.getInstance().endAt(100)"
 
Are you running in batch mode? The endAt call is surrounded with an “if” that checks if you are running in batch mode. As for the plotting, if you have other agents of the same type, I don’t think you can plot just a single one. The non-aggregated plot will plot that characteristic for each agent of that type.

Nick

> On Nov 10, 2016, at 3:55 PM, Elham Foruzan <[hidden email]> wrote:
> 
> Hello,
> 
> My code had some problem with intialization when I was using the countiuos projection. I just used the grid, and it works now. However, the program is not finished at tick that I tell it to stop. For example, As you can see, when I ask it to stop at tick 100, it don't stop and I should stop it from run time simulator. 
> 
> Also, may I ask some body explain how can I plot a characterestic of specific agent (e.g. coustomer 1 ) using non-aggregated option in run time simulator. I am assuming that it is the way to do that, But I appreciate if you explain if there is another way as well. 
> Thank you very much. 
>     
>   package smartGrids;
> 
> import repast.simphony.engine.schedule.ScheduledMethod;
> 
> import java.text.DecimalFormat;
> import java.util.ArrayList;
> import java.util.Collection;
> 
> import repast.simphony.context.Context;
> import repast.simphony.context.DefaultContext;
> import repast.simphony.context.space.continuous.ContinuousSpaceFactory;
> import repast.simphony.context.space.continuous.ContinuousSpaceFactoryFinder;
> import repast.simphony.context.space.graph.NetworkBuilder;
> import repast.simphony.context.space.grid.GridFactory;
> import repast.simphony.context.space.grid.GridFactoryFinder;
> import repast.simphony.dataLoader.ContextBuilder;
> import repast.simphony.engine.environment.RunEnvironment;
> import repast.simphony.essentials.RepastEssentials;
> import repast.simphony.parameter.Parameters;
> import repast.simphony.space.continuous.ContinuousSpace;
> import repast.simphony.space.continuous.NdPoint;
> import repast.simphony.space.continuous.RandomCartesianAdder;
> import repast.simphony.space.grid.Grid;
> import repast.simphony.space.grid.GridBuilderParameters;
> import repast.simphony.space.grid.SimpleGridAdder;
> import repast.simphony.space.grid.WrapAroundBorders;
> 
> public class smartGridsBuilder implements ContextBuilder<Object> {
>        
>        
>        ArrayList<Agent> allAgents = new ArrayList<Agent>();
>        
>        
>        
>        @Override
>         public Context build ( Context < Object > context ) {
>                 context.setId("smartGrids");
>                 
>                 GridFactory gridFactory = GridFactoryFinder.createGridFactory(null);
>                        Grid<Object> grid = gridFactory.createGrid("grid",context,
>                                        new GridBuilderParameters<Object>(new WrapAroundBorders(),
>                                                        new SimpleGridAdder<Object>(), true, 100, 100));
>                 
>                 
>                   ContinuousSpaceFactory spaceFactory = ContinuousSpaceFactoryFinder
>                                        .createContinuousSpaceFactory(null);
>                        ContinuousSpace<Object> space = spaceFactory.createContinuousSpace(
>                                        "space", context, new RandomCartesianAdder<Object>(),
>                                        new repast.simphony.space.continuous.WrapAroundBorders(), 100,
>                                        100);
>                 
>                        
>                                 
>                 
>                        
>                        
>        Parameters params = RunEnvironment.getInstance().getParameters();
>        
>        double LoadVari = (Double) params.getValue("load_vari");
>        double load_k = (Double) params.getValue("load_k");
>        double LoadMaximum  = (Double) params.getValue("Load_Max");
>        
>        int consumerCount = (Integer) params.getValue("consumer_Count");
>        for (int i = 0; i < consumerCount; i++) {
>                
>                consumers.add(new Consumers(space, grid,"Consumer "+(i+1),LoadMaximum,LoadVari,DAY,Qtablec));
>                context.add(consumers.get(i));
>                allAgents.add(consumers.get(i));
>        }
>                        
>        context.add(ac);
>        
>                        
>        for(Object obj: context){
>                NdPoint pt=space.getLocation(obj);
>                grid.moveTo(obj, (int)pt.getX(),(int)pt.getY());
>                System.out.println((int)pt.getX());
>        }
>                        
>                        
>        if (RunEnvironment.getInstance().isBatch()) {
>                        RunEnvironment.getInstance().endAt(100);
>        }
>                                
>        return context ;
>  }
>        
> ------------------------------------------------------------------------------
> Developer Access Program for Intel Xeon Phi Processors
> Access to Intel Xeon Phi processor-based developer platforms.
> With one year of Intel Parallel Studio XE.
> Training and support from Colfax.
> Order your platform today. http://sdm.link/xeonphi_______________________________________________
> Repast-interest mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/repast-interest


------------------------------------------------------------------------------
Developer Access Program for Intel Xeon Phi Processors
Access to Intel Xeon Phi processor-based developer platforms.
With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today. http://sdm.link/xeonphi
_______________________________________________
Repast-interest mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/repast-interest



------------------------------------------------------------------------------

_______________________________________________
Repast-interest mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/repast-interest
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: My code dose not stop using "RunEnvironment.getInstance().endAt(100)"

Elham Foruzan
Nick, 

I decided to use the non-aggregated data source, and write all the Q values for my customer agent inside the text file. However, I have two problems:

First, when I define a non-aggregated data set for customer agent, the simulation slow down significantle. Even it stops during execution due to memory problem.

Second, it changes the results of other agents values!! this is very confusing for me.

Also, I am not sure, it might be a problem with how I implement "NonAggregateDataSource".
Please take a look this code implementing NonAggregateDataSource:
getValueOfState() is the method inside customer class that I am looking to look at its value.
Same as always, Thank you very much for your help and time.  


public class Consumers extends Agent implements NonAggregateDataSource{

public String getId() {
return "Customer Q Value";
}


@Override
public Class<?> getDataType() {
return double.class;
}


@Override
public Class<?> getSourceType() {
return this.getClass();
}

@Override
public Object get(Object obj) {
return ((Consumers) obj).getValueOfState();
}

}

------------------------------------------------------------

Elham Foruzan

PhD Student

Department of Electrical and Computer Engineering

University of Nebraska-Lincoln

214.4 B Scott Engineering 



On Wed, Nov 16, 2016 at 8:05 AM, Nick Collier <[hidden email]> wrote:
Just to clarify, in case others find this later, the proxy approach is good when you want to focus on a single agent where there are multiple _instances_ of that type of agent, not multiple types as I said below.

Nick

On Nov 15, 2016, at 4:44 PM, Nicholson Collier <[hidden email]> wrote:

Jonas’ advice re. proxy agents is a good one if you want to focus on a single agent where there are multiple types of that agent. For aggregate vs. non-aggregate and other data collection info, see:


Nick
On Nov 12, 2016, at 2:23 PM, [hidden email] wrote:

Nick, thank you so much. You are right. I just deleted the if , and it is working now. I should read more about the batch mode and its different with the regular mode. 

I have four type of agents, and more that one agent for each type. I am interested in looking at one agent Q table value, and seeing how it improves. Then If I want to look at just one agent is there a way to do that?
 I didn't get what you said about non-aggregated plot. Then If i have 10 customer agents and I want to look at how they average Q value improve during a day, I should use a aggregated feature. But then what is a difference between non-aggregated and aggregated? Can I see one feature of a specific agent type (e.g. Q value )  for those 10 agents in one plot using non-aggregated function?

Thank you for your prompt reply and  your kind support.




------------------------------------------------------------
Elham Foruzan
PhD Student
Department of Electrical and Computer Engineering
University of Nebraska-Lincoln
214.4 B Scott Engineering 


From: Nick Collier <[hidden email]>
Sent: Saturday, November 12, 2016 8:30:56 AM
To: Elham Foruzan
Cc: [hidden email]
Subject: Re: [Repast-interest] My code dose not stop using "RunEnvironment.getInstance().endAt(100)"
 
Are you running in batch mode? The endAt call is surrounded with an “if” that checks if you are running in batch mode. As for the plotting, if you have other agents of the same type, I don’t think you can plot just a single one. The non-aggregated plot will plot that characteristic for each agent of that type.

Nick

> On Nov 10, 2016, at 3:55 PM, Elham Foruzan <[hidden email]> wrote:
> 
> Hello,
> 
> My code had some problem with intialization when I was using the countiuos projection. I just used the grid, and it works now. However, the program is not finished at tick that I tell it to stop. For example, As you can see, when I ask it to stop at tick 100, it don't stop and I should stop it from run time simulator. 
> 
> Also, may I ask some body explain how can I plot a characterestic of specific agent (e.g. coustomer 1 ) using non-aggregated option in run time simulator. I am assuming that it is the way to do that, But I appreciate if you explain if there is another way as well. 
> Thank you very much. 
>     
>   package smartGrids;
> 
> import repast.simphony.engine.schedule.ScheduledMethod;
> 
> import java.text.DecimalFormat;
> import java.util.ArrayList;
> import java.util.Collection;
> 
> import repast.simphony.context.Context;
> import repast.simphony.context.DefaultContext;
> import repast.simphony.context.space.continuous.ContinuousSpaceFactory;
> import repast.simphony.context.space.continuous.ContinuousSpaceFactoryFinder;
> import repast.simphony.context.space.graph.NetworkBuilder;
> import repast.simphony.context.space.grid.GridFactory;
> import repast.simphony.context.space.grid.GridFactoryFinder;
> import repast.simphony.dataLoader.ContextBuilder;
> import repast.simphony.engine.environment.RunEnvironment;
> import repast.simphony.essentials.RepastEssentials;
> import repast.simphony.parameter.Parameters;
> import repast.simphony.space.continuous.ContinuousSpace;
> import repast.simphony.space.continuous.NdPoint;
> import repast.simphony.space.continuous.RandomCartesianAdder;
> import repast.simphony.space.grid.Grid;
> import repast.simphony.space.grid.GridBuilderParameters;
> import repast.simphony.space.grid.SimpleGridAdder;
> import repast.simphony.space.grid.WrapAroundBorders;
> 
> public class smartGridsBuilder implements ContextBuilder<Object> {
>        
>        
>        ArrayList<Agent> allAgents = new ArrayList<Agent>();
>        
>        
>        
>        @Override
>         public Context build ( Context < Object > context ) {
>                 context.setId("smartGrids");
>                 
>                 GridFactory gridFactory = GridFactoryFinder.createGridFactory(null);
>                        Grid<Object> grid = gridFactory.createGrid("grid",context,
>                                        new GridBuilderParameters<Object>(new WrapAroundBorders(),
>                                                        new SimpleGridAdder<Object>(), true, 100, 100));
>                 
>                 
>                   ContinuousSpaceFactory spaceFactory = ContinuousSpaceFactoryFinder
>                                        .createContinuousSpaceFactory(null);
>                        ContinuousSpace<Object> space = spaceFactory.createContinuousSpace(
>                                        "space", context, new RandomCartesianAdder<Object>(),
>                                        new repast.simphony.space.continuous.WrapAroundBorders(), 100,
>                                        100);
>                 
>                        
>                                 
>                 
>                        
>                        
>        Parameters params = RunEnvironment.getInstance().getParameters();
>        
>        double LoadVari = (Double) params.getValue("load_vari");
>        double load_k = (Double) params.getValue("load_k");
>        double LoadMaximum  = (Double) params.getValue("Load_Max");
>        
>        int consumerCount = (Integer) params.getValue("consumer_Count");
>        for (int i = 0; i < consumerCount; i++) {
>                
>                consumers.add(new Consumers(space, grid,"Consumer "+(i+1),LoadMaximum,LoadVari,DAY,Qtablec));
>                context.add(consumers.get(i));
>                allAgents.add(consumers.get(i));
>        }
>                        
>        context.add(ac);
>        
>                        
>        for(Object obj: context){
>                NdPoint pt=space.getLocation(obj);
>                grid.moveTo(obj, (int)pt.getX(),(int)pt.getY());
>                System.out.println((int)pt.getX());
>        }
>                        
>                        
>        if (RunEnvironment.getInstance().isBatch()) {
>                        RunEnvironment.getInstance().endAt(100);
>        }
>                                
>        return context ;
>  }
>        
> ------------------------------------------------------------------------------
> Developer Access Program for Intel Xeon Phi Processors
> Access to Intel Xeon Phi processor-based developer platforms.
> With one year of Intel Parallel Studio XE.
> Training and support from Colfax.
> Order your platform today. http://sdm.link/xeonphi_______________________________________________
> Repast-interest mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/repast-interest


------------------------------------------------------------------------------
Developer Access Program for Intel Xeon Phi Processors
Access to Intel Xeon Phi processor-based developer platforms.
With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today. http://sdm.link/xeonphi
_______________________________________________
Repast-interest mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/repast-interest



------------------------------------------------------------------------------

_______________________________________________
Repast-interest mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/repast-interest



------------------------------------------------------------------------------

_______________________________________________
Repast-interest mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/repast-interest
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: My code dose not stop using "RunEnvironment.getInstance().endAt(100)"

srcnick
Is there a reason you implemented NonAggregateDataSource? You should be able to select Non Aggregate DataSource from the wizard and choose the agent type you want as the data source. You can then select the methods to use to return the data. For a non aggregate source, you should also have a method that returns a unique id for each agent, otherwise you won’t be able to tell what data is from what. You can set that id when you create the agents. For exampel,

public class Customer {

int id;
...

public Customer(int id)  {
this.id = id;
}

public int getId() {
return id;
}


public double getQValue() {
// return the Q value for this agent
}
...
}


Then in the data source wizard, you would select the getId and getQValue methods.

Nick
On Nov 16, 2016, at 2:10 PM, Elham Foruzan <[hidden email]> wrote:

Nick, 

I decided to use the non-aggregated data source, and write all the Q values for my customer agent inside the text file. However, I have two problems:

First, when I define a non-aggregated data set for customer agent, the simulation slow down significantle. Even it stops during execution due to memory problem.

Second, it changes the results of other agents values!! this is very confusing for me.

Also, I am not sure, it might be a problem with how I implement "NonAggregateDataSource".
Please take a look this code implementing NonAggregateDataSource:
getValueOfState() is the method inside customer class that I am looking to look at its value.
Same as always, Thank you very much for your help and time.  


public class Consumers extends Agent implements NonAggregateDataSource{

public String getId() {
return "Customer Q Value";
}


@Override
public Class<?> getDataType() {
return double.class;
}


@Override
public Class<?> getSourceType() {
return this.getClass();
}

@Override
public Object get(Object obj) {
return ((Consumers) obj).getValueOfState();
}

}

------------------------------------------------------------
Elham Foruzan
PhD Student
Department of Electrical and Computer Engineering
University of Nebraska-Lincoln
214.4 B Scott Engineering 


On Wed, Nov 16, 2016 at 8:05 AM, Nick Collier <[hidden email]> wrote:
Just to clarify, in case others find this later, the proxy approach is good when you want to focus on a single agent where there are multiple _instances_ of that type of agent, not multiple types as I said below.

Nick

On Nov 15, 2016, at 4:44 PM, Nicholson Collier <[hidden email]> wrote:

Jonas’ advice re. proxy agents is a good one if you want to focus on a single agent where there are multiple types of that agent. For aggregate vs. non-aggregate and other data collection info, see:


Nick
On Nov 12, 2016, at 2:23 PM, [hidden email] wrote:

Nick, thank you so much. You are right. I just deleted the if , and it is working now. I should read more about the batch mode and its different with the regular mode. 

I have four type of agents, and more that one agent for each type. I am interested in looking at one agent Q table value, and seeing how it improves. Then If I want to look at just one agent is there a way to do that?
 I didn't get what you said about non-aggregated plot. Then If i have 10 customer agents and I want to look at how they average Q value improve during a day, I should use a aggregated feature. But then what is a difference between non-aggregated and aggregated? Can I see one feature of a specific agent type (e.g. Q value )  for those 10 agents in one plot using non-aggregated function?

Thank you for your prompt reply and  your kind support.




------------------------------------------------------------
Elham Foruzan
PhD Student
Department of Electrical and Computer Engineering
University of Nebraska-Lincoln
214.4 B Scott Engineering 


From: Nick Collier <[hidden email]>
Sent: Saturday, November 12, 2016 8:30:56 AM
To: Elham Foruzan
Cc: [hidden email]
Subject: Re: [Repast-interest] My code dose not stop using "RunEnvironment.getInstance().endAt(100)"
 
Are you running in batch mode? The endAt call is surrounded with an “if” that checks if you are running in batch mode. As for the plotting, if you have other agents of the same type, I don’t think you can plot just a single one. The non-aggregated plot will plot that characteristic for each agent of that type.

Nick

> On Nov 10, 2016, at 3:55 PM, Elham Foruzan <[hidden email]> wrote:
> 
> Hello,
> 
> My code had some problem with intialization when I was using the countiuos projection. I just used the grid, and it works now. However, the program is not finished at tick that I tell it to stop. For example, As you can see, when I ask it to stop at tick 100, it don't stop and I should stop it from run time simulator. 
> 
> Also, may I ask some body explain how can I plot a characterestic of specific agent (e.g. coustomer 1 ) using non-aggregated option in run time simulator. I am assuming that it is the way to do that, But I appreciate if you explain if there is another way as well. 
> Thank you very much. 
>     
>   package smartGrids;
> 
> import repast.simphony.engine.schedule.ScheduledMethod;
> 
> import java.text.DecimalFormat;
> import java.util.ArrayList;
> import java.util.Collection;
> 
> import repast.simphony.context.Context;
> import repast.simphony.context.DefaultContext;
> import repast.simphony.context.space.continuous.ContinuousSpaceFactory;
> import repast.simphony.context.space.continuous.ContinuousSpaceFactoryFinder;
> import repast.simphony.context.space.graph.NetworkBuilder;
> import repast.simphony.context.space.grid.GridFactory;
> import repast.simphony.context.space.grid.GridFactoryFinder;
> import repast.simphony.dataLoader.ContextBuilder;
> import repast.simphony.engine.environment.RunEnvironment;
> import repast.simphony.essentials.RepastEssentials;
> import repast.simphony.parameter.Parameters;
> import repast.simphony.space.continuous.ContinuousSpace;
> import repast.simphony.space.continuous.NdPoint;
> import repast.simphony.space.continuous.RandomCartesianAdder;
> import repast.simphony.space.grid.Grid;
> import repast.simphony.space.grid.GridBuilderParameters;
> import repast.simphony.space.grid.SimpleGridAdder;
> import repast.simphony.space.grid.WrapAroundBorders;
> 
> public class smartGridsBuilder implements ContextBuilder<Object> {
>        
>        
>        ArrayList<Agent> allAgents = new ArrayList<Agent>();
>        
>        
>        
>        @Override
>         public Context build ( Context < Object > context ) {
>                 context.setId("smartGrids");
>                 
>                 GridFactory gridFactory = GridFactoryFinder.createGridFactory(null);
>                        Grid<Object> grid = gridFactory.createGrid("grid",context,
>                                        new GridBuilderParameters<Object>(new WrapAroundBorders(),
>                                                        new SimpleGridAdder<Object>(), true, 100, 100));
>                 
>                 
>                   ContinuousSpaceFactory spaceFactory = ContinuousSpaceFactoryFinder
>                                        .createContinuousSpaceFactory(null);
>                        ContinuousSpace<Object> space = spaceFactory.createContinuousSpace(
>                                        "space", context, new RandomCartesianAdder<Object>(),
>                                        new repast.simphony.space.continuous.WrapAroundBorders(), 100,
>                                        100);
>                 
>                        
>                                 
>                 
>                        
>                        
>        Parameters params = RunEnvironment.getInstance().getParameters();
>        
>        double LoadVari = (Double) params.getValue("load_vari");
>        double load_k = (Double) params.getValue("load_k");
>        double LoadMaximum  = (Double) params.getValue("Load_Max");
>        
>        int consumerCount = (Integer) params.getValue("consumer_Count");
>        for (int i = 0; i < consumerCount; i++) {
>                
>                consumers.add(new Consumers(space, grid,"Consumer "+(i+1),LoadMaximum,LoadVari,DAY,Qtablec));
>                context.add(consumers.get(i));
>                allAgents.add(consumers.get(i));
>        }
>                        
>        context.add(ac);
>        
>                        
>        for(Object obj: context){
>                NdPoint pt=space.getLocation(obj);
>                grid.moveTo(obj, (int)pt.getX(),(int)pt.getY());
>                System.out.println((int)pt.getX());
>        }
>                        
>                        
>        if (RunEnvironment.getInstance().isBatch()) {
>                        RunEnvironment.getInstance().endAt(100);
>        }
>                                
>        return context ;
>  }
>        
> ------------------------------------------------------------------------------
> Developer Access Program for Intel Xeon Phi Processors
> Access to Intel Xeon Phi processor-based developer platforms.
> With one year of Intel Parallel Studio XE.
> Training and support from Colfax.
> Order your platform today. http://sdm.link/xeonphi_______________________________________________
> Repast-interest mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/repast-interest


------------------------------------------------------------------------------
Developer Access Program for Intel Xeon Phi Processors
Access to Intel Xeon Phi processor-based developer platforms.
With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today. http://sdm.link/xeonphi
_______________________________________________
Repast-interest mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/repast-interest



------------------------------------------------------------------------------

_______________________________________________
Repast-interest mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/repast-interest




------------------------------------------------------------------------------

_______________________________________________
Repast-interest mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/repast-interest
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: My code dose not stop using "RunEnvironment.getInstance().endAt(100)"

elham.foruzan@huskers.unl.edu

Nick,


Thank you so much for your quik answer, I appreciate your help. 

You send me a document (https://repast.github.io/docs/DataCollection.pdf). it mentioned for non aggregated data set you need to implement "repast.simphony.data2. NonAggregateDataSourc", page 4 , then I started to implement it.

Now, I just implemented what you said without implementing data2... . but still I have memory problem. Also, instead of a chart, I see this screen. 

Without non-aggregated plot I can run more that 100000 tick without any problem, with non-aggregated plot simulation stops at the middle of running.




------------------------------------------------------------

Elham Foruzan

PhD Student

Department of Electrical and Computer Engineering

University of Nebraska-Lincoln

214.4 B Scott Engineering 



From: Nick Collier <[hidden email]>
Sent: Thursday, November 17, 2016 6:55:37 AM
To: Elham Foruzan
Cc: Repast List
Subject: Re: [Repast-interest] My code dose not stop using "RunEnvironment.getInstance().endAt(100)"
 
Is there a reason you implemented NonAggregateDataSource? You should be able to select Non Aggregate DataSource from the wizard and choose the agent type you want as the data source. You can then select the methods to use to return the data. For a non aggregate source, you should also have a method that returns a unique id for each agent, otherwise you won’t be able to tell what data is from what. You can set that id when you create the agents. For exampel,

public class Customer {

int id;
...

public Customer(int id)  {
this.id = id;
}

public int getId() {
return id;
}


public double getQValue() {
// return the Q value for this agent
}
...
}


Then in the data source wizard, you would select the getId and getQValue methods.

Nick
On Nov 16, 2016, at 2:10 PM, Elham Foruzan <[hidden email]> wrote:

Nick, 

I decided to use the non-aggregated data source, and write all the Q values for my customer agent inside the text file. However, I have two problems:

First, when I define a non-aggregated data set for customer agent, the simulation slow down significantle. Even it stops during execution due to memory problem.

Second, it changes the results of other agents values!! this is very confusing for me.

Also, I am not sure, it might be a problem with how I implement "NonAggregateDataSource".
Please take a look this code implementing NonAggregateDataSource:
getValueOfState() is the method inside customer class that I am looking to look at its value.
Same as always, Thank you very much for your help and time.  


public class Consumers extends Agent implements NonAggregateDataSource{

public String getId() {
return "Customer Q Value";
}


@Override
public Class<?> getDataType() {
return double.class;
}


@Override
public Class<?> getSourceType() {
return this.getClass();
}

@Override
public Object get(Object obj) {
return ((Consumers) obj).getValueOfState();
}

}

------------------------------------------------------------
Elham Foruzan
PhD Student
Department of Electrical and Computer Engineering
University of Nebraska-Lincoln
214.4 B Scott Engineering 


On Wed, Nov 16, 2016 at 8:05 AM, Nick Collier <[hidden email]> wrote:
Just to clarify, in case others find this later, the proxy approach is good when you want to focus on a single agent where there are multiple _instances_ of that type of agent, not multiple types as I said below.

Nick

On Nov 15, 2016, at 4:44 PM, Nicholson Collier <[hidden email]> wrote:

Jonas’ advice re. proxy agents is a good one if you want to focus on a single agent where there are multiple types of that agent. For aggregate vs. non-aggregate and other data collection info, see:


Nick
On Nov 12, 2016, at 2:23 PM, [hidden email] wrote:

Nick, thank you so much. You are right. I just deleted the if , and it is working now. I should read more about the batch mode and its different with the regular mode. 

I have four type of agents, and more that one agent for each type. I am interested in looking at one agent Q table value, and seeing how it improves. Then If I want to look at just one agent is there a way to do that?
 I didn't get what you said about non-aggregated plot. Then If i have 10 customer agents and I want to look at how they average Q value improve during a day, I should use a aggregated feature. But then what is a difference between non-aggregated and aggregated? Can I see one feature of a specific agent type (e.g. Q value )  for those 10 agents in one plot using non-aggregated function?

Thank you for your prompt reply and  your kind support.




------------------------------------------------------------
Elham Foruzan
PhD Student
Department of Electrical and Computer Engineering
University of Nebraska-Lincoln
214.4 B Scott Engineering 


From: Nick Collier <[hidden email]>
Sent: Saturday, November 12, 2016 8:30:56 AM
To: Elham Foruzan
Cc: [hidden email]
Subject: Re: [Repast-interest] My code dose not stop using "RunEnvironment.getInstance().endAt(100)"
 
Are you running in batch mode? The endAt call is surrounded with an “if” that checks if you are running in batch mode. As for the plotting, if you have other agents of the same type, I don’t think you can plot just a single one. The non-aggregated plot will plot that characteristic for each agent of that type.

Nick

> On Nov 10, 2016, at 3:55 PM, Elham Foruzan <[hidden email]> wrote:
> 
> Hello,
> 
> My code had some problem with intialization when I was using the countiuos projection. I just used the grid, and it works now. However, the program is not finished at tick that I tell it to stop. For example, As you can see, when I ask it to stop at tick 100, it don't stop and I should stop it from run time simulator. 
> 
> Also, may I ask some body explain how can I plot a characterestic of specific agent (e.g. coustomer 1 ) using non-aggregated option in run time simulator. I am assuming that it is the way to do that, But I appreciate if you explain if there is another way as well. 
> Thank you very much. 
>     
>   package smartGrids;
> 
> import repast.simphony.engine.schedule.ScheduledMethod;
> 
> import java.text.DecimalFormat;
> import java.util.ArrayList;
> import java.util.Collection;
> 
> import repast.simphony.context.Context;
> import repast.simphony.context.DefaultContext;
> import repast.simphony.context.space.continuous.ContinuousSpaceFactory;
> import repast.simphony.context.space.continuous.ContinuousSpaceFactoryFinder;
> import repast.simphony.context.space.graph.NetworkBuilder;
> import repast.simphony.context.space.grid.GridFactory;
> import repast.simphony.context.space.grid.GridFactoryFinder;
> import repast.simphony.dataLoader.ContextBuilder;
> import repast.simphony.engine.environment.RunEnvironment;
> import repast.simphony.essentials.RepastEssentials;
> import repast.simphony.parameter.Parameters;
> import repast.simphony.space.continuous.ContinuousSpace;
> import repast.simphony.space.continuous.NdPoint;
> import repast.simphony.space.continuous.RandomCartesianAdder;
> import repast.simphony.space.grid.Grid;
> import repast.simphony.space.grid.GridBuilderParameters;
> import repast.simphony.space.grid.SimpleGridAdder;
> import repast.simphony.space.grid.WrapAroundBorders;
> 
> public class smartGridsBuilder implements ContextBuilder<Object> {
>        
>        
>        ArrayList<Agent> allAgents = new ArrayList<Agent>();
>        
>        
>        
>        @Override
>         public Context build ( Context < Object > context ) {
>                 context.setId("smartGrids");
>                 
>                 GridFactory gridFactory = GridFactoryFinder.createGridFactory(null);
>                        Grid<Object> grid = gridFactory.createGrid("grid",context,
>                                        new GridBuilderParameters<Object>(new WrapAroundBorders(),
>                                                        new SimpleGridAdder<Object>(), true, 100, 100));
>                 
>                 
>                   ContinuousSpaceFactory spaceFactory = ContinuousSpaceFactoryFinder
>                                        .createContinuousSpaceFactory(null);
>                        ContinuousSpace<Object> space = spaceFactory.createContinuousSpace(
>                                        "space", context, new RandomCartesianAdder<Object>(),
>                                        new repast.simphony.space.continuous.WrapAroundBorders(), 100,
>                                        100);
>                 
>                        
>                                 
>                 
>                        
>                        
>        Parameters params = RunEnvironment.getInstance().getParameters();
>        
>        double LoadVari = (Double) params.getValue("load_vari");
>        double load_k = (Double) params.getValue("load_k");
>        double LoadMaximum  = (Double) params.getValue("Load_Max");
>        
>        int consumerCount = (Integer) params.getValue("consumer_Count");
>        for (int i = 0; i < consumerCount; i++) {
>                
>                consumers.add(new Consumers(space, grid,"Consumer "+(i+1),LoadMaximum,LoadVari,DAY,Qtablec));
>                context.add(consumers.get(i));
>                allAgents.add(consumers.get(i));
>        }
>                        
>        context.add(ac);
>        
>                        
>        for(Object obj: context){
>                NdPoint pt=space.getLocation(obj);
>                grid.moveTo(obj, (int)pt.getX(),(int)pt.getY());
>                System.out.println((int)pt.getX());
>        }
>                        
>                        
>        if (RunEnvironment.getInstance().isBatch()) {
>                        RunEnvironment.getInstance().endAt(100);
>        }
>                                
>        return context ;
>  }
>        
> ------------------------------------------------------------------------------
> Developer Access Program for Intel Xeon Phi Processors
> Access to Intel Xeon Phi processor-based developer platforms.
> With one year of Intel Parallel Studio XE.
> Training and support from Colfax.
> Order your platform today. http://sdm.link/xeonphi_______________________________________________
> Repast-interest mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/repast-interest


------------------------------------------------------------------------------
Developer Access Program for Intel Xeon Phi Processors
Access to Intel Xeon Phi processor-based developer platforms.
With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today. http://sdm.link/xeonphi
_______________________________________________
Repast-interest mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/repast-interest



------------------------------------------------------------------------------

_______________________________________________
Repast-interest mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/repast-interest




------------------------------------------------------------------------------

_______________________________________________
Repast-interest mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/repast-interest
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: My code dose not stop using "RunEnvironment.getInstance().endAt(100)"

srcnick
The chart rendering has trouble efficiently drawing a large number of time series (i.e. one for each of 100s of agents). In general this isn’t a problem that comes up too often because visually a chart with that many time series can’t tell you much as its a muddle.  At any rate, if you try to plot that many, eventually the rendering gets so slow that it seems to hang the simulation. One alternative is to write all the data to a file using a file sink, and then plot the interesting portions of that post-run using R, excel, pandas, or whatever you like.

Nick


On Nov 17, 2016, at 10:43 AM, [hidden email] wrote:

Nick,

Thank you so much for your quik answer, I appreciate your help. 
You send me a document (https://repast.github.io/docs/DataCollection.pdf). it mentioned for non aggregated data set you need to implement "repast.simphony.data2. NonAggregateDataSourc", page 4 , then I started to implement it.
Now, I just implemented what you said without implementing data2... . but still I have memory problem. Also, instead of a chart, I see this screen. 
Without non-aggregated plot I can run more that 100000 tick without any problem, with non-aggregated plot simulation stops at the middle of running.

<pastedImage.png>

------------------------------------------------------------
Elham Foruzan
PhD Student
Department of Electrical and Computer Engineering
University of Nebraska-Lincoln
214.4 B Scott Engineering 


From: Nick Collier <[hidden email]>
Sent: Thursday, November 17, 2016 6:55:37 AM
To: Elham Foruzan
Cc: Repast List
Subject: Re: [Repast-interest] My code dose not stop using "RunEnvironment.getInstance().endAt(100)"
 
Is there a reason you implemented NonAggregateDataSource? You should be able to select Non Aggregate DataSource from the wizard and choose the agent type you want as the data source. You can then select the methods to use to return the data. For a non aggregate source, you should also have a method that returns a unique id for each agent, otherwise you won’t be able to tell what data is from what. You can set that id when you create the agents. For exampel,

public class Customer {

int id;
...

public Customer(int id)  {
this.id = id;
}

public int getId() {
return id;
}


public double getQValue() {
// return the Q value for this agent
}
...
}


Then in the data source wizard, you would select the getId and getQValue methods.

Nick
On Nov 16, 2016, at 2:10 PM, Elham Foruzan <[hidden email]> wrote:

Nick, 

I decided to use the non-aggregated data source, and write all the Q values for my customer agent inside the text file. However, I have two problems:

First, when I define a non-aggregated data set for customer agent, the simulation slow down significantle. Even it stops during execution due to memory problem.

Second, it changes the results of other agents values!! this is very confusing for me.

Also, I am not sure, it might be a problem with how I implement "NonAggregateDataSource".
Please take a look this code implementing NonAggregateDataSource:
getValueOfState() is the method inside customer class that I am looking to look at its value.
Same as always, Thank you very much for your help and time.  


public class Consumers extends Agent implements NonAggregateDataSource{

public String getId() {
return "Customer Q Value";
}


@Override
public Class<?> getDataType() {
return double.class;
}


@Override
public Class<?> getSourceType() {
return this.getClass();
}

@Override
public Object get(Object obj) {
return ((Consumers) obj).getValueOfState();
}

}

------------------------------------------------------------
Elham Foruzan
PhD Student
Department of Electrical and Computer Engineering
University of Nebraska-Lincoln
214.4 B Scott Engineering 


On Wed, Nov 16, 2016 at 8:05 AM, Nick Collier <[hidden email]> wrote:
Just to clarify, in case others find this later, the proxy approach is good when you want to focus on a single agent where there are multiple _instances_ of that type of agent, not multiple types as I said below.

Nick

On Nov 15, 2016, at 4:44 PM, Nicholson Collier <[hidden email]> wrote:

Jonas’ advice re. proxy agents is a good one if you want to focus on a single agent where there are multiple types of that agent. For aggregate vs. non-aggregate and other data collection info, see:


Nick
On Nov 12, 2016, at 2:23 PM, [hidden email] wrote:

Nick, thank you so much. You are right. I just deleted the if , and it is working now. I should read more about the batch mode and its different with the regular mode. 

I have four type of agents, and more that one agent for each type. I am interested in looking at one agent Q table value, and seeing how it improves. Then If I want to look at just one agent is there a way to do that?
 I didn't get what you said about non-aggregated plot. Then If i have 10 customer agents and I want to look at how they average Q value improve during a day, I should use a aggregated feature. But then what is a difference between non-aggregated and aggregated? Can I see one feature of a specific agent type (e.g. Q value )  for those 10 agents in one plot using non-aggregated function?

Thank you for your prompt reply and  your kind support.




------------------------------------------------------------
Elham Foruzan
PhD Student
Department of Electrical and Computer Engineering
University of Nebraska-Lincoln
214.4 B Scott Engineering 


From: Nick Collier <[hidden email]>
Sent: Saturday, November 12, 2016 8:30:56 AM
To: Elham Foruzan
Cc: [hidden email]
Subject: Re: [Repast-interest] My code dose not stop using "RunEnvironment.getInstance().endAt(100)"
 
Are you running in batch mode? The endAt call is surrounded with an “if” that checks if you are running in batch mode. As for the plotting, if you have other agents of the same type, I don’t think you can plot just a single one. The non-aggregated plot will plot that characteristic for each agent of that type.

Nick

> On Nov 10, 2016, at 3:55 PM, Elham Foruzan <[hidden email]> wrote:
> 
> Hello,
> 
> My code had some problem with intialization when I was using the countiuos projection. I just used the grid, and it works now. However, the program is not finished at tick that I tell it to stop. For example, As you can see, when I ask it to stop at tick 100, it don't stop and I should stop it from run time simulator. 
> 
> Also, may I ask some body explain how can I plot a characterestic of specific agent (e.g. coustomer 1 ) using non-aggregated option in run time simulator. I am assuming that it is the way to do that, But I appreciate if you explain if there is another way as well. 
> Thank you very much. 
>     
>   package smartGrids;
> 
> import repast.simphony.engine.schedule.ScheduledMethod;
> 
> import java.text.DecimalFormat;
> import java.util.ArrayList;
> import java.util.Collection;
> 
> import repast.simphony.context.Context;
> import repast.simphony.context.DefaultContext;
> import repast.simphony.context.space.continuous.ContinuousSpaceFactory;
> import repast.simphony.context.space.continuous.ContinuousSpaceFactoryFinder;
> import repast.simphony.context.space.graph.NetworkBuilder;
> import repast.simphony.context.space.grid.GridFactory;
> import repast.simphony.context.space.grid.GridFactoryFinder;
> import repast.simphony.dataLoader.ContextBuilder;
> import repast.simphony.engine.environment.RunEnvironment;
> import repast.simphony.essentials.RepastEssentials;
> import repast.simphony.parameter.Parameters;
> import repast.simphony.space.continuous.ContinuousSpace;
> import repast.simphony.space.continuous.NdPoint;
> import repast.simphony.space.continuous.RandomCartesianAdder;
> import repast.simphony.space.grid.Grid;
> import repast.simphony.space.grid.GridBuilderParameters;
> import repast.simphony.space.grid.SimpleGridAdder;
> import repast.simphony.space.grid.WrapAroundBorders;
> 
> public class smartGridsBuilder implements ContextBuilder<Object> {
>        
>        
>        ArrayList<Agent> allAgents = new ArrayList<Agent>();
>        
>        
>        
>        @Override
>         public Context build ( Context < Object > context ) {
>                 context.setId("smartGrids");
>                 
>                 GridFactory gridFactory = GridFactoryFinder.createGridFactory(null);
>                        Grid<Object> grid = gridFactory.createGrid("grid",context,
>                                        new GridBuilderParameters<Object>(new WrapAroundBorders(),
>                                                        new SimpleGridAdder<Object>(), true, 100, 100));
>                 
>                 
>                   ContinuousSpaceFactory spaceFactory = ContinuousSpaceFactoryFinder
>                                        .createContinuousSpaceFactory(null);
>                        ContinuousSpace<Object> space = spaceFactory.createContinuousSpace(
>                                        "space", context, new RandomCartesianAdder<Object>(),
>                                        new repast.simphony.space.continuous.WrapAroundBorders(), 100,
>                                        100);
>                 
>                        
>                                 
>                 
>                        
>                        
>        Parameters params = RunEnvironment.getInstance().getParameters();
>        
>        double LoadVari = (Double) params.getValue("load_vari");
>        double load_k = (Double) params.getValue("load_k");
>        double LoadMaximum  = (Double) params.getValue("Load_Max");
>        
>        int consumerCount = (Integer) params.getValue("consumer_Count");
>        for (int i = 0; i < consumerCount; i++) {
>                
>                consumers.add(new Consumers(space, grid,"Consumer "+(i+1),LoadMaximum,LoadVari,DAY,Qtablec));
>                context.add(consumers.get(i));
>                allAgents.add(consumers.get(i));
>        }
>                        
>        context.add(ac);
>        
>                        
>        for(Object obj: context){
>                NdPoint pt=space.getLocation(obj);
>                grid.moveTo(obj, (int)pt.getX(),(int)pt.getY());
>                System.out.println((int)pt.getX());
>        }
>                        
>                        
>        if (RunEnvironment.getInstance().isBatch()) {
>                        RunEnvironment.getInstance().endAt(100);
>        }
>                                
>        return context ;
>  }
>        
> ------------------------------------------------------------------------------
> Developer Access Program for Intel Xeon Phi Processors
> Access to Intel Xeon Phi processor-based developer platforms.
> With one year of Intel Parallel Studio XE.
> Training and support from Colfax.
> Order your platform today. http://sdm.link/xeonphi_______________________________________________
> Repast-interest mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/repast-interest


------------------------------------------------------------------------------
Developer Access Program for Intel Xeon Phi Processors
Access to Intel Xeon Phi processor-based developer platforms.
With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today. http://sdm.link/xeonphi
_______________________________________________
Repast-interest mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/repast-interest



------------------------------------------------------------------------------

_______________________________________________
Repast-interest mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/repast-interest


------------------------------------------------------------------------------

_______________________________________________
Repast-interest mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/repast-interest
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: My code dose not stop using "RunEnvironment.getInstance().endAt(100)"

Elham Foruzan
You have been extremely supportive through this time with problems.
Thank you So much. 

------------------------------------------------------------

Elham Foruzan

PhD Student

Department of Electrical and Computer Engineering

University of Nebraska-Lincoln

214.4 B Scott Engineering 



On Thu, Nov 17, 2016 at 11:53 AM, Nick Collier <[hidden email]> wrote:
The chart rendering has trouble efficiently drawing a large number of time series (i.e. one for each of 100s of agents). In general this isn’t a problem that comes up too often because visually a chart with that many time series can’t tell you much as its a muddle.  At any rate, if you try to plot that many, eventually the rendering gets so slow that it seems to hang the simulation. One alternative is to write all the data to a file using a file sink, and then plot the interesting portions of that post-run using R, excel, pandas, or whatever you like.

Nick


On Nov 17, 2016, at 10:43 AM, [hidden email] wrote:

Nick,

Thank you so much for your quik answer, I appreciate your help. 
You send me a document (https://repast.github.io/docs/DataCollection.pdf). it mentioned for non aggregated data set you need to implement "repast.simphony.data2. NonAggregateDataSourc", page 4 , then I started to implement it.
Now, I just implemented what you said without implementing data2... . but still I have memory problem. Also, instead of a chart, I see this screen. 
Without non-aggregated plot I can run more that 100000 tick without any problem, with non-aggregated plot simulation stops at the middle of running.

<pastedImage.png>

------------------------------------------------------------
Elham Foruzan
PhD Student
Department of Electrical and Computer Engineering
University of Nebraska-Lincoln
214.4 B Scott Engineering 


From: Nick Collier <[hidden email]>
Sent: Thursday, November 17, 2016 6:55:37 AM
To: Elham Foruzan
Cc: Repast List
Subject: Re: [Repast-interest] My code dose not stop using "RunEnvironment.getInstance().endAt(100)"
 
Is there a reason you implemented NonAggregateDataSource? You should be able to select Non Aggregate DataSource from the wizard and choose the agent type you want as the data source. You can then select the methods to use to return the data. For a non aggregate source, you should also have a method that returns a unique id for each agent, otherwise you won’t be able to tell what data is from what. You can set that id when you create the agents. For exampel,

public class Customer {

int id;
...

public Customer(int id)  {
this.id = id;
}

public int getId() {
return id;
}


public double getQValue() {
// return the Q value for this agent
}
...
}


Then in the data source wizard, you would select the getId and getQValue methods.

Nick
On Nov 16, 2016, at 2:10 PM, Elham Foruzan <[hidden email]> wrote:

Nick, 

I decided to use the non-aggregated data source, and write all the Q values for my customer agent inside the text file. However, I have two problems:

First, when I define a non-aggregated data set for customer agent, the simulation slow down significantle. Even it stops during execution due to memory problem.

Second, it changes the results of other agents values!! this is very confusing for me.

Also, I am not sure, it might be a problem with how I implement "NonAggregateDataSource".
Please take a look this code implementing NonAggregateDataSource:
getValueOfState() is the method inside customer class that I am looking to look at its value.
Same as always, Thank you very much for your help and time.  


public class Consumers extends Agent implements NonAggregateDataSource{

public String getId() {
return "Customer Q Value";
}


@Override
public Class<?> getDataType() {
return double.class;
}


@Override
public Class<?> getSourceType() {
return this.getClass();
}

@Override
public Object get(Object obj) {
return ((Consumers) obj).getValueOfState();
}

}

------------------------------------------------------------
Elham Foruzan
PhD Student
Department of Electrical and Computer Engineering
University of Nebraska-Lincoln
214.4 B Scott Engineering 


On Wed, Nov 16, 2016 at 8:05 AM, Nick Collier <[hidden email]> wrote:
Just to clarify, in case others find this later, the proxy approach is good when you want to focus on a single agent where there are multiple _instances_ of that type of agent, not multiple types as I said below.

Nick

On Nov 15, 2016, at 4:44 PM, Nicholson Collier <[hidden email]> wrote:

Jonas’ advice re. proxy agents is a good one if you want to focus on a single agent where there are multiple types of that agent. For aggregate vs. non-aggregate and other data collection info, see:


Nick
On Nov 12, 2016, at 2:23 PM, [hidden email] wrote:

Nick, thank you so much. You are right. I just deleted the if , and it is working now. I should read more about the batch mode and its different with the regular mode. 

I have four type of agents, and more that one agent for each type. I am interested in looking at one agent Q table value, and seeing how it improves. Then If I want to look at just one agent is there a way to do that?
 I didn't get what you said about non-aggregated plot. Then If i have 10 customer agents and I want to look at how they average Q value improve during a day, I should use a aggregated feature. But then what is a difference between non-aggregated and aggregated? Can I see one feature of a specific agent type (e.g. Q value )  for those 10 agents in one plot using non-aggregated function?

Thank you for your prompt reply and  your kind support.




------------------------------------------------------------
Elham Foruzan
PhD Student
Department of Electrical and Computer Engineering
University of Nebraska-Lincoln
214.4 B Scott Engineering 


From: Nick Collier <[hidden email]>
Sent: Saturday, November 12, 2016 8:30:56 AM
To: Elham Foruzan
Cc: [hidden email]
Subject: Re: [Repast-interest] My code dose not stop using "RunEnvironment.getInstance().endAt(100)"
 
Are you running in batch mode? The endAt call is surrounded with an “if” that checks if you are running in batch mode. As for the plotting, if you have other agents of the same type, I don’t think you can plot just a single one. The non-aggregated plot will plot that characteristic for each agent of that type.

Nick

> On Nov 10, 2016, at 3:55 PM, Elham Foruzan <[hidden email]> wrote:
> 
> Hello,
> 
> My code had some problem with intialization when I was using the countiuos projection. I just used the grid, and it works now. However, the program is not finished at tick that I tell it to stop. For example, As you can see, when I ask it to stop at tick 100, it don't stop and I should stop it from run time simulator. 
> 
> Also, may I ask some body explain how can I plot a characterestic of specific agent (e.g. coustomer 1 ) using non-aggregated option in run time simulator. I am assuming that it is the way to do that, But I appreciate if you explain if there is another way as well. 
> Thank you very much. 
>     
>   package smartGrids;
> 
> import repast.simphony.engine.schedule.ScheduledMethod;
> 
> import java.text.DecimalFormat;
> import java.util.ArrayList;
> import java.util.Collection;
> 
> import repast.simphony.context.Context;
> import repast.simphony.context.DefaultContext;
> import repast.simphony.context.space.continuous.ContinuousSpaceFactory;
> import repast.simphony.context.space.continuous.ContinuousSpaceFactoryFinder;
> import repast.simphony.context.space.graph.NetworkBuilder;
> import repast.simphony.context.space.grid.GridFactory;
> import repast.simphony.context.space.grid.GridFactoryFinder;
> import repast.simphony.dataLoader.ContextBuilder;
> import repast.simphony.engine.environment.RunEnvironment;
> import repast.simphony.essentials.RepastEssentials;
> import repast.simphony.parameter.Parameters;
> import repast.simphony.space.continuous.ContinuousSpace;
> import repast.simphony.space.continuous.NdPoint;
> import repast.simphony.space.continuous.RandomCartesianAdder;
> import repast.simphony.space.grid.Grid;
> import repast.simphony.space.grid.GridBuilderParameters;
> import repast.simphony.space.grid.SimpleGridAdder;
> import repast.simphony.space.grid.WrapAroundBorders;
> 
> public class smartGridsBuilder implements ContextBuilder<Object> {
>        
>        
>        ArrayList<Agent> allAgents = new ArrayList<Agent>();
>        
>        
>        
>        @Override
>         public Context build ( Context < Object > context ) {
>                 context.setId("smartGrids");
>                 
>                 GridFactory gridFactory = GridFactoryFinder.createGridFactory(null);
>                        Grid<Object> grid = gridFactory.createGrid("grid",context,
>                                        new GridBuilderParameters<Object>(new WrapAroundBorders(),
>                                                        new SimpleGridAdder<Object>(), true, 100, 100));
>                 
>                 
>                   ContinuousSpaceFactory spaceFactory = ContinuousSpaceFactoryFinder
>                                        .createContinuousSpaceFactory(null);
>                        ContinuousSpace<Object> space = spaceFactory.createContinuousSpace(
>                                        "space", context, new RandomCartesianAdder<Object>(),
>                                        new repast.simphony.space.continuous.WrapAroundBorders(), 100,
>                                        100);
>                 
>                        
>                                 
>                 
>                        
>                        
>        Parameters params = RunEnvironment.getInstance().getParameters();
>        
>        double LoadVari = (Double) params.getValue("load_vari");
>        double load_k = (Double) params.getValue("load_k");
>        double LoadMaximum  = (Double) params.getValue("Load_Max");
>        
>        int consumerCount = (Integer) params.getValue("consumer_Count");
>        for (int i = 0; i < consumerCount; i++) {
>                
>                consumers.add(new Consumers(space, grid,"Consumer "+(i+1),LoadMaximum,LoadVari,DAY,Qtablec));
>                context.add(consumers.get(i));
>                allAgents.add(consumers.get(i));
>        }
>                        
>        context.add(ac);
>        
>                        
>        for(Object obj: context){
>                NdPoint pt=space.getLocation(obj);
>                grid.moveTo(obj, (int)pt.getX(),(int)pt.getY());
>                System.out.println((int)pt.getX());
>        }
>                        
>                        
>        if (RunEnvironment.getInstance().isBatch()) {
>                        RunEnvironment.getInstance().endAt(100);
>        }
>                                
>        return context ;
>  }
>        
> ------------------------------------------------------------------------------
> Developer Access Program for Intel Xeon Phi Processors
> Access to Intel Xeon Phi processor-based developer platforms.
> With one year of Intel Parallel Studio XE.
> Training and support from Colfax.
> Order your platform today. http://sdm.link/xeonphi_______________________________________________
> Repast-interest mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/repast-interest


------------------------------------------------------------------------------
Developer Access Program for Intel Xeon Phi Processors
Access to Intel Xeon Phi processor-based developer platforms.
With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today. http://sdm.link/xeonphi
_______________________________________________
Repast-interest mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/repast-interest



------------------------------------------------------------------------------

_______________________________________________
Repast-interest mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/repast-interest



------------------------------------------------------------------------------

_______________________________________________
Repast-interest mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/repast-interest
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: My code dose not stop using "RunEnvironment.getInstance().endAt(100)"

elham.foruzan@huskers.unl.edu
In reply to this post by srcnick

Hello,


I am facing a new problem. I have five different types of agents. When I have one from each type, the program works fine. However, If I enter more agents for one type using parameter option, the number of agents increases to three or four times(for example even I enter 2 for customer type, and one for the rest, the number of returning agents are 14!! it should be 6). Also, every agent has a name, I use this name to distinguish them. Then getId method will return the name of each agent. 

 I used a printing method to analyze what is going on, but I saw that the same name appeared 3 times. 

This is the output of agents and you can see customer 1 counted 3 times:

Any idea how can I solve this problem? 


Buyer size 14

Buyer name Consumer 1
Buyer name Storage 1
Buyer name Consumer 1
Buyer name Consumer 3
Buyer name Storage 1
Buyer name Consumer 3
Buyer name Storage 1
..
 

Thank you.

------------------------------------------------------------

Elham Foruzan

PhD Student

Department of Electrical and Computer Engineering

Department of Computer Science and Engineering

University of Nebraska-Lincoln

214.4 B Scott Engineering 



From: Nick Collier <[hidden email]>
Sent: Thursday, November 17, 2016 10:53:51 AM
To: [hidden email]
Cc: Elham Foruzan; Repast List
Subject: Re: [Repast-interest] My code dose not stop using "RunEnvironment.getInstance().endAt(100)"
 
The chart rendering has trouble efficiently drawing a large number of time series (i.e. one for each of 100s of agents). In general this isn’t a problem that comes up too often because visually a chart with that many time series can’t tell you much as its a muddle.  At any rate, if you try to plot that many, eventually the rendering gets so slow that it seems to hang the simulation. One alternative is to write all the data to a file using a file sink, and then plot the interesting portions of that post-run using R, excel, pandas, or whatever you like.

Nick


On Nov 17, 2016, at 10:43 AM, [hidden email] wrote:

Nick,

Thank you so much for your quik answer, I appreciate your help. 
You send me a document (https://repast.github.io/docs/DataCollection.pdf). it mentioned for non aggregated data set you need to implement "repast.simphony.data2. NonAggregateDataSourc", page 4 , then I started to implement it.
Now, I just implemented what you said without implementing data2... . but still I have memory problem. Also, instead of a chart, I see this screen. 
Without non-aggregated plot I can run more that 100000 tick without any problem, with non-aggregated plot simulation stops at the middle of running.

<pastedImage.png>

------------------------------------------------------------
Elham Foruzan
PhD Student
Department of Electrical and Computer Engineering
University of Nebraska-Lincoln
214.4 B Scott Engineering 


From: Nick Collier <[hidden email]>
Sent: Thursday, November 17, 2016 6:55:37 AM
To: Elham Foruzan
Cc: Repast List
Subject: Re: [Repast-interest] My code dose not stop using "RunEnvironment.getInstance().endAt(100)"
 
Is there a reason you implemented NonAggregateDataSource? You should be able to select Non Aggregate DataSource from the wizard and choose the agent type you want as the data source. You can then select the methods to use to return the data. For a non aggregate source, you should also have a method that returns a unique id for each agent, otherwise you won’t be able to tell what data is from what. You can set that id when you create the agents. For exampel,

public class Customer {

int id;
...

public Customer(int id)  {
this.id = id;
}

public int getId() {
return id;
}


public double getQValue() {
// return the Q value for this agent
}
...
}


Then in the data source wizard, you would select the getId and getQValue methods.

Nick
On Nov 16, 2016, at 2:10 PM, Elham Foruzan <[hidden email]> wrote:

Nick, 

I decided to use the non-aggregated data source, and write all the Q values for my customer agent inside the text file. However, I have two problems:

First, when I define a non-aggregated data set for customer agent, the simulation slow down significantle. Even it stops during execution due to memory problem.

Second, it changes the results of other agents values!! this is very confusing for me.

Also, I am not sure, it might be a problem with how I implement "NonAggregateDataSource".
Please take a look this code implementing NonAggregateDataSource:
getValueOfState() is the method inside customer class that I am looking to look at its value.
Same as always, Thank you very much for your help and time.  


public class Consumers extends Agent implements NonAggregateDataSource{

public String getId() {
return "Customer Q Value";
}


@Override
public Class<?> getDataType() {
return double.class;
}


@Override
public Class<?> getSourceType() {
return this.getClass();
}

@Override
public Object get(Object obj) {
return ((Consumers) obj).getValueOfState();
}

}

------------------------------------------------------------
Elham Foruzan
PhD Student
Department of Electrical and Computer Engineering
University of Nebraska-Lincoln
214.4 B Scott Engineering 


On Wed, Nov 16, 2016 at 8:05 AM, Nick Collier <[hidden email]> wrote:
Just to clarify, in case others find this later, the proxy approach is good when you want to focus on a single agent where there are multiple _instances_ of that type of agent, not multiple types as I said below.

Nick

On Nov 15, 2016, at 4:44 PM, Nicholson Collier <[hidden email]> wrote:

Jonas’ advice re. proxy agents is a good one if you want to focus on a single agent where there are multiple types of that agent. For aggregate vs. non-aggregate and other data collection info, see:


Nick
On Nov 12, 2016, at 2:23 PM, [hidden email] wrote:

Nick, thank you so much. You are right. I just deleted the if , and it is working now. I should read more about the batch mode and its different with the regular mode. 

I have four type of agents, and more that one agent for each type. I am interested in looking at one agent Q table value, and seeing how it improves. Then If I want to look at just one agent is there a way to do that?
 I didn't get what you said about non-aggregated plot. Then If i have 10 customer agents and I want to look at how they average Q value improve during a day, I should use a aggregated feature. But then what is a difference between non-aggregated and aggregated? Can I see one feature of a specific agent type (e.g. Q value )  for those 10 agents in one plot using non-aggregated function?

Thank you for your prompt reply and  your kind support.




------------------------------------------------------------
Elham Foruzan
PhD Student
Department of Electrical and Computer Engineering
University of Nebraska-Lincoln
214.4 B Scott Engineering 


From: Nick Collier <[hidden email]>
Sent: Saturday, November 12, 2016 8:30:56 AM
To: Elham Foruzan
Cc: [hidden email]
Subject: Re: [Repast-interest] My code dose not stop using "RunEnvironment.getInstance().endAt(100)"
 
Are you running in batch mode? The endAt call is surrounded with an “if” that checks if you are running in batch mode. As for the plotting, if you have other agents of the same type, I don’t think you can plot just a single one. The non-aggregated plot will plot that characteristic for each agent of that type.

Nick

> On Nov 10, 2016, at 3:55 PM, Elham Foruzan <[hidden email]> wrote:
> 
> Hello,
> 
> My code had some problem with intialization when I was using the countiuos projection. I just used the grid, and it works now. However, the program is not finished at tick that I tell it to stop. For example, As you can see, when I ask it to stop at tick 100, it don't stop and I should stop it from run time simulator. 
> 
> Also, may I ask some body explain how can I plot a characterestic of specific agent (e.g. coustomer 1 ) using non-aggregated option in run time simulator. I am assuming that it is the way to do that, But I appreciate if you explain if there is another way as well. 
> Thank you very much. 
>     
>   package smartGrids;
> 
> import repast.simphony.engine.schedule.ScheduledMethod;
> 
> import java.text.DecimalFormat;
> import java.util.ArrayList;
> import java.util.Collection;
> 
> import repast.simphony.context.Context;
> import repast.simphony.context.DefaultContext;
> import repast.simphony.context.space.continuous.ContinuousSpaceFactory;
> import repast.simphony.context.space.continuous.ContinuousSpaceFactoryFinder;
> import repast.simphony.context.space.graph.NetworkBuilder;
> import repast.simphony.context.space.grid.GridFactory;
> import repast.simphony.context.space.grid.GridFactoryFinder;
> import repast.simphony.dataLoader.ContextBuilder;
> import repast.simphony.engine.environment.RunEnvironment;
> import repast.simphony.essentials.RepastEssentials;
> import repast.simphony.parameter.Parameters;
> import repast.simphony.space.continuous.ContinuousSpace;
> import repast.simphony.space.continuous.NdPoint;
> import repast.simphony.space.continuous.RandomCartesianAdder;
> import repast.simphony.space.grid.Grid;
> import repast.simphony.space.grid.GridBuilderParameters;
> import repast.simphony.space.grid.SimpleGridAdder;
> import repast.simphony.space.grid.WrapAroundBorders;
> 
> public class smartGridsBuilder implements ContextBuilder<Object> {
>        
>        
>        ArrayList<Agent> allAgents = new ArrayList<Agent>();
>        
>        
>        
>        @Override
>         public Context build ( Context < Object > context ) {
>                 context.setId("smartGrids");
>                 
>                 GridFactory gridFactory = GridFactoryFinder.createGridFactory(null);
>                        Grid<Object> grid = gridFactory.createGrid("grid",context,
>                                        new GridBuilderParameters<Object>(new WrapAroundBorders(),
>                                                        new SimpleGridAdder<Object>(), true, 100, 100));
>                 
>                 
>                   ContinuousSpaceFactory spaceFactory = ContinuousSpaceFactoryFinder
>                                        .createContinuousSpaceFactory(null);
>                        ContinuousSpace<Object> space = spaceFactory.createContinuousSpace(
>                                        "space", context, new RandomCartesianAdder<Object>(),
>                                        new repast.simphony.space.continuous.WrapAroundBorders(), 100,
>                                        100);
>                 
>                        
>                                 
>                 
>                        
>                        
>        Parameters params = RunEnvironment.getInstance().getParameters();
>        
>        double LoadVari = (Double) params.getValue("load_vari");
>        double load_k = (Double) params.getValue("load_k");
>        double LoadMaximum  = (Double) params.getValue("Load_Max");
>        
>        int consumerCount = (Integer) params.getValue("consumer_Count");
>        for (int i = 0; i < consumerCount; i++) {
>                
>                consumers.add(new Consumers(space, grid,"Consumer "+(i+1),LoadMaximum,LoadVari,DAY,Qtablec));
>                context.add(consumers.get(i));
>                allAgents.add(consumers.get(i));
>        }
>                        
>        context.add(ac);
>        
>                        
>        for(Object obj: context){
>                NdPoint pt=space.getLocation(obj);
>                grid.moveTo(obj, (int)pt.getX(),(int)pt.getY());
>                System.out.println((int)pt.getX());
>        }
>                        
>                        
>        if (RunEnvironment.getInstance().isBatch()) {
>                        RunEnvironment.getInstance().endAt(100);
>        }
>                                
>        return context ;
>  }
>        
> ------------------------------------------------------------------------------
> Developer Access Program for Intel Xeon Phi Processors
> Access to Intel Xeon Phi processor-based developer platforms.
> With one year of Intel Parallel Studio XE.
> Training and support from Colfax.
> Order your platform today. http://sdm.link/xeonphi_______________________________________________
> Repast-interest mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/repast-interest


------------------------------------------------------------------------------
Developer Access Program for Intel Xeon Phi Processors
Access to Intel Xeon Phi processor-based developer platforms.
With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today. http://sdm.link/xeonphi
_______________________________________________
Repast-interest mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/repast-interest



------------------------------------------------------------------------------

_______________________________________________
Repast-interest mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/repast-interest


------------------------------------------------------------------------------

_______________________________________________
Repast-interest mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/repast-interest
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: My code dose not stop using "RunEnvironment.getInstance().endAt(100)"

elham.foruzan@huskers.unl.edu

Hello,


Regarding the previous email, I found the source of the problem but I don't know how to solve it. 

The problem was related to runtime simulator. I save all the agents that I create in the agent ArrayList in the contextBiulder. every time that hit reset run, it reset the run but it has not rested the ArrayList  including my agents inside the context builder. hence, it appends to the previous array. 

The question is that, why it not clear what it was in the array list, at the top of my contextBuilder I have 

ArrayList<Agent> allAgents = new ArrayList<Agent>();

and then appending into that my agents, then when I hit the initialize run in the runtime simulator, why it does not execute the contextBiulder?  

Thanks,



------------------------------------------------------------

Elham Foruzan

PhD Student

Department of Electrical and Computer Engineering

Department of Computer Science and Engineering

University of Nebraska-Lincoln

214.4 B Scott Engineering 



From: [hidden email]
Sent: Tuesday, November 22, 2016 2:08:35 PM
To: Nick Collier
Cc: Elham Foruzan; Repast List
Subject: Re: [Repast-interest] My code dose not stop using "RunEnvironment.getInstance().endAt(100)"
 

Hello,


I am facing a new problem. I have five different types of agents. When I have one from each type, the program works fine. However, If I enter more agents for one type using parameter option, the number of agents increases to three or four times(for example even I enter 2 for customer type, and one for the rest, the number of returning agents are 14!! it should be 6). Also, every agent has a name, I use this name to distinguish them. Then getId method will return the name of each agent. 

 I used a printing method to analyze what is going on, but I saw that the same name appeared 3 times. 

This is the output of agents and you can see customer 1 counted 3 times:

Any idea how can I solve this problem? 


Buyer size 14

Buyer name Consumer 1
Buyer name Storage 1
Buyer name Consumer 1
Buyer name Consumer 3
Buyer name Storage 1
Buyer name Consumer 3
Buyer name Storage 1
..
 

Thank you.

------------------------------------------------------------

Elham Foruzan

PhD Student

Department of Electrical and Computer Engineering

Department of Computer Science and Engineering

University of Nebraska-Lincoln

214.4 B Scott Engineering 



From: Nick Collier <[hidden email]>
Sent: Thursday, November 17, 2016 10:53:51 AM
To: [hidden email]
Cc: Elham Foruzan; Repast List
Subject: Re: [Repast-interest] My code dose not stop using "RunEnvironment.getInstance().endAt(100)"
 
The chart rendering has trouble efficiently drawing a large number of time series (i.e. one for each of 100s of agents). In general this isn’t a problem that comes up too often because visually a chart with that many time series can’t tell you much as its a muddle.  At any rate, if you try to plot that many, eventually the rendering gets so slow that it seems to hang the simulation. One alternative is to write all the data to a file using a file sink, and then plot the interesting portions of that post-run using R, excel, pandas, or whatever you like.

Nick


On Nov 17, 2016, at 10:43 AM, [hidden email] wrote:

Nick,

Thank you so much for your quik answer, I appreciate your help. 
You send me a document (https://repast.github.io/docs/DataCollection.pdf). it mentioned for non aggregated data set you need to implement "repast.simphony.data2. NonAggregateDataSourc", page 4 , then I started to implement it.
Now, I just implemented what you said without implementing data2... . but still I have memory problem. Also, instead of a chart, I see this screen. 
Without non-aggregated plot I can run more that 100000 tick without any problem, with non-aggregated plot simulation stops at the middle of running.

<pastedImage.png>

------------------------------------------------------------
Elham Foruzan
PhD Student
Department of Electrical and Computer Engineering
University of Nebraska-Lincoln
214.4 B Scott Engineering 


From: Nick Collier <[hidden email]>
Sent: Thursday, November 17, 2016 6:55:37 AM
To: Elham Foruzan
Cc: Repast List
Subject: Re: [Repast-interest] My code dose not stop using "RunEnvironment.getInstance().endAt(100)"
 
Is there a reason you implemented NonAggregateDataSource? You should be able to select Non Aggregate DataSource from the wizard and choose the agent type you want as the data source. You can then select the methods to use to return the data. For a non aggregate source, you should also have a method that returns a unique id for each agent, otherwise you won’t be able to tell what data is from what. You can set that id when you create the agents. For exampel,

public class Customer {

int id;
...

public Customer(int id)  {
this.id = id;
}

public int getId() {
return id;
}


public double getQValue() {
// return the Q value for this agent
}
...
}


Then in the data source wizard, you would select the getId and getQValue methods.

Nick
On Nov 16, 2016, at 2:10 PM, Elham Foruzan <[hidden email]> wrote:

Nick, 

I decided to use the non-aggregated data source, and write all the Q values for my customer agent inside the text file. However, I have two problems:

First, when I define a non-aggregated data set for customer agent, the simulation slow down significantle. Even it stops during execution due to memory problem.

Second, it changes the results of other agents values!! this is very confusing for me.

Also, I am not sure, it might be a problem with how I implement "NonAggregateDataSource".
Please take a look this code implementing NonAggregateDataSource:
getValueOfState() is the method inside customer class that I am looking to look at its value.
Same as always, Thank you very much for your help and time.  


public class Consumers extends Agent implements NonAggregateDataSource{

public String getId() {
return "Customer Q Value";
}


@Override
public Class<?> getDataType() {
return double.class;
}


@Override
public Class<?> getSourceType() {
return this.getClass();
}

@Override
public Object get(Object obj) {
return ((Consumers) obj).getValueOfState();
}

}

------------------------------------------------------------
Elham Foruzan
PhD Student
Department of Electrical and Computer Engineering
University of Nebraska-Lincoln
214.4 B Scott Engineering 


On Wed, Nov 16, 2016 at 8:05 AM, Nick Collier <[hidden email]> wrote:
Just to clarify, in case others find this later, the proxy approach is good when you want to focus on a single agent where there are multiple _instances_ of that type of agent, not multiple types as I said below.

Nick

On Nov 15, 2016, at 4:44 PM, Nicholson Collier <[hidden email]> wrote:

Jonas’ advice re. proxy agents is a good one if you want to focus on a single agent where there are multiple types of that agent. For aggregate vs. non-aggregate and other data collection info, see:


Nick
On Nov 12, 2016, at 2:23 PM, [hidden email] wrote:

Nick, thank you so much. You are right. I just deleted the if , and it is working now. I should read more about the batch mode and its different with the regular mode. 

I have four type of agents, and more that one agent for each type. I am interested in looking at one agent Q table value, and seeing how it improves. Then If I want to look at just one agent is there a way to do that?
 I didn't get what you said about non-aggregated plot. Then If i have 10 customer agents and I want to look at how they average Q value improve during a day, I should use a aggregated feature. But then what is a difference between non-aggregated and aggregated? Can I see one feature of a specific agent type (e.g. Q value )  for those 10 agents in one plot using non-aggregated function?

Thank you for your prompt reply and  your kind support.




------------------------------------------------------------
Elham Foruzan
PhD Student
Department of Electrical and Computer Engineering
University of Nebraska-Lincoln
214.4 B Scott Engineering 


From: Nick Collier <[hidden email]>
Sent: Saturday, November 12, 2016 8:30:56 AM
To: Elham Foruzan
Cc: [hidden email]
Subject: Re: [Repast-interest] My code dose not stop using "RunEnvironment.getInstance().endAt(100)"
 
Are you running in batch mode? The endAt call is surrounded with an “if” that checks if you are running in batch mode. As for the plotting, if you have other agents of the same type, I don’t think you can plot just a single one. The non-aggregated plot will plot that characteristic for each agent of that type.

Nick

> On Nov 10, 2016, at 3:55 PM, Elham Foruzan <[hidden email]> wrote:
> 
> Hello,
> 
> My code had some problem with intialization when I was using the countiuos projection. I just used the grid, and it works now. However, the program is not finished at tick that I tell it to stop. For example, As you can see, when I ask it to stop at tick 100, it don't stop and I should stop it from run time simulator. 
> 
> Also, may I ask some body explain how can I plot a characterestic of specific agent (e.g. coustomer 1 ) using non-aggregated option in run time simulator. I am assuming that it is the way to do that, But I appreciate if you explain if there is another way as well. 
> Thank you very much. 
>     
>   package smartGrids;
> 
> import repast.simphony.engine.schedule.ScheduledMethod;
> 
> import java.text.DecimalFormat;
> import java.util.ArrayList;
> import java.util.Collection;
> 
> import repast.simphony.context.Context;
> import repast.simphony.context.DefaultContext;
> import repast.simphony.context.space.continuous.ContinuousSpaceFactory;
> import repast.simphony.context.space.continuous.ContinuousSpaceFactoryFinder;
> import repast.simphony.context.space.graph.NetworkBuilder;
> import repast.simphony.context.space.grid.GridFactory;
> import repast.simphony.context.space.grid.GridFactoryFinder;
> import repast.simphony.dataLoader.ContextBuilder;
> import repast.simphony.engine.environment.RunEnvironment;
> import repast.simphony.essentials.RepastEssentials;
> import repast.simphony.parameter.Parameters;
> import repast.simphony.space.continuous.ContinuousSpace;
> import repast.simphony.space.continuous.NdPoint;
> import repast.simphony.space.continuous.RandomCartesianAdder;
> import repast.simphony.space.grid.Grid;
> import repast.simphony.space.grid.GridBuilderParameters;
> import repast.simphony.space.grid.SimpleGridAdder;
> import repast.simphony.space.grid.WrapAroundBorders;
> 
> public class smartGridsBuilder implements ContextBuilder<Object> {
>        
>        
>        ArrayList<Agent> allAgents = new ArrayList<Agent>();
>        
>        
>        
>        @Override
>         public Context build ( Context < Object > context ) {
>                 context.setId("smartGrids");
>                 
>                 GridFactory gridFactory = GridFactoryFinder.createGridFactory(null);
>                        Grid<Object> grid = gridFactory.createGrid("grid",context,
>                                        new GridBuilderParameters<Object>(new WrapAroundBorders(),
>                                                        new SimpleGridAdder<Object>(), true, 100, 100));
>                 
>                 
>                   ContinuousSpaceFactory spaceFactory = ContinuousSpaceFactoryFinder
>                                        .createContinuousSpaceFactory(null);
>                        ContinuousSpace<Object> space = spaceFactory.createContinuousSpace(
>                                        "space", context, new RandomCartesianAdder<Object>(),
>                                        new repast.simphony.space.continuous.WrapAroundBorders(), 100,
>                                        100);
>                 
>                        
>                                 
>                 
>                        
>                        
>        Parameters params = RunEnvironment.getInstance().getParameters();
>        
>        double LoadVari = (Double) params.getValue("load_vari");
>        double load_k = (Double) params.getValue("load_k");
>        double LoadMaximum  = (Double) params.getValue("Load_Max");
>        
>        int consumerCount = (Integer) params.getValue("consumer_Count");
>        for (int i = 0; i < consumerCount; i++) {
>                
>                consumers.add(new Consumers(space, grid,"Consumer "+(i+1),LoadMaximum,LoadVari,DAY,Qtablec));
>                context.add(consumers.get(i));
>                allAgents.add(consumers.get(i));
>        }
>                        
>        context.add(ac);
>        
>                        
>        for(Object obj: context){
>                NdPoint pt=space.getLocation(obj);
>                grid.moveTo(obj, (int)pt.getX(),(int)pt.getY());
>                System.out.println((int)pt.getX());
>        }
>                        
>                        
>        if (RunEnvironment.getInstance().isBatch()) {
>                        RunEnvironment.getInstance().endAt(100);
>        }
>                                
>        return context ;
>  }
>        
> ------------------------------------------------------------------------------
> Developer Access Program for Intel Xeon Phi Processors
> Access to Intel Xeon Phi processor-based developer platforms.
> With one year of Intel Parallel Studio XE.
> Training and support from Colfax.
> Order your platform today. http://sdm.link/xeonphi_______________________________________________
> Repast-interest mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/repast-interest


------------------------------------------------------------------------------
Developer Access Program for Intel Xeon Phi Processors
Access to Intel Xeon Phi processor-based developer platforms.
With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today. http://sdm.link/xeonphi
_______________________________________________
Repast-interest mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/repast-interest



------------------------------------------------------------------------------

_______________________________________________
Repast-interest mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/repast-interest


------------------------------------------------------------------------------

_______________________________________________
Repast-interest mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/repast-interest
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: My code dose not stop using "RunEnvironment.getInstance().endAt(100)"

srcnick
THe ContextBuilder persists between runs so you need to clear the allAgents list at the beginning of the build method. 

Nick

On Nov 22, 2016, at 5:26 PM, [hidden email] wrote:

Hello,

Regarding the previous email, I found the source of the problem but I don't know how to solve it. 
The problem was related to runtime simulator. I save all the agents that I create in the agent ArrayList in the contextBiulder. every time that hit reset run, it reset the run but it has not rested the ArrayList  including my agents  inside the context builder. hence, it appends to the previous array. 
The question is that, why it not clear what it was in the array list, at the top of my contextBuilder I have 
ArrayList<Agent> allAgents = new ArrayList<Agent>();
and then appending into that my agents, then when I hit the initialize run in the runtime simulator, why it does not execute the contextBiulder?  
Thanks,


------------------------------------------------------------
Elham Foruzan
PhD Student
Department of Electrical and Computer Engineering
Department of Computer Science and Engineering
University of Nebraska-Lincoln
214.4 B Scott Engineering 


From: [hidden email]
Sent: Tuesday, November 22, 2016 2:08:35 PM
To: Nick Collier
Cc: Elham Foruzan; Repast List
Subject: Re: [Repast-interest] My code dose not stop using "RunEnvironment.getInstance().endAt(100)"
 
Hello,

I am facing a new problem. I have five different types of agents. When I have one from each type, the program works fine. However, If I enter more agents for one type using parameter option, the number of agents increases to three or four times(for example even I enter 2 for customer type, and one for the rest, the number of returning agents are 14!! it should be 6). Also, every agent has a name, I use this name to distinguish them. Then getId method will return the name of each agent. 
 I used a printing method to analyze what is going on, but I saw that the same name appeared 3 times. 
This is the output of agents and you can see customer 1 counted 3 times:
Any idea how can I solve this problem? 

Buyer size 14

Buyer name Consumer 1
Buyer name Storage 1
Buyer name Consumer 1
Buyer name Consumer 3
Buyer name Storage 1
Buyer name Consumer 3
Buyer name Storage 1
..

Thank you.

------------------------------------------------------------
Elham Foruzan
PhD Student
Department of Electrical and Computer Engineering
Department of Computer Science and Engineering
University of Nebraska-Lincoln
214.4 B Scott Engineering 


From: Nick Collier <[hidden email]>
Sent: Thursday, November 17, 2016 10:53:51 AM
To: [hidden email]
Cc: Elham Foruzan; Repast List
Subject: Re: [Repast-interest] My code dose not stop using "RunEnvironment.getInstance().endAt(100)"
 
The chart rendering has trouble efficiently drawing a large number of time series (i.e. one for each of 100s of agents). In general this isn’t a problem that comes up too often because visually a chart with that many time series can’t tell you much as its a muddle.  At any rate, if you try to plot that many, eventually the rendering gets so slow that it seems to hang the simulation. One alternative is to write all the data to a file using a file sink, and then plot the interesting portions of that post-run using R, excel, pandas, or whatever you like.

Nick


On Nov 17, 2016, at 10:43 AM, [hidden email] wrote:

Nick,

Thank you so much for your quik answer, I appreciate your help. 
You send me a document (https://repast.github.io/docs/DataCollection.pdf). it mentioned for non aggregated data set you need to implement "repast.simphony.data2. NonAggregateDataSourc", page 4 , then I started to implement it.
Now, I just implemented what you said without implementing data2... . but still I have memory problem. Also, instead of a chart, I see this screen. 
Without non-aggregated plot I can run more that 100000 tick without any problem, with non-aggregated plot simulation stops at the middle of running.

<pastedImage.png>

------------------------------------------------------------
Elham Foruzan
PhD Student
Department of Electrical and Computer Engineering
University of Nebraska-Lincoln
214.4 B Scott Engineering 


From: Nick Collier <[hidden email]>
Sent: Thursday, November 17, 2016 6:55:37 AM
To: Elham Foruzan
Cc: Repast List
Subject: Re: [Repast-interest] My code dose not stop using "RunEnvironment.getInstance().endAt(100)"
 
Is there a reason you implemented NonAggregateDataSource? You should be able to select Non Aggregate DataSource from the wizard and choose the agent type you want as the data source. You can then select the methods to use to return the data. For a non aggregate source, you should also have a method that returns a unique id for each agent, otherwise you won’t be able to tell what data is from what. You can set that id when you create the agents. For exampel,

public class Customer {

int id;
...

public Customer(int id)  {
this.id = id;
}

public int getId() {
return id;
}


public double getQValue() {
// return the Q value for this agent
}
...
}


Then in the data source wizard, you would select the getId and getQValue methods.

Nick
On Nov 16, 2016, at 2:10 PM, Elham Foruzan <[hidden email]> wrote:

Nick, 

I decided to use the non-aggregated data source, and write all the Q values for my customer agent inside the text file. However, I have two problems:

First, when I define a non-aggregated data set for customer agent, the simulation slow down significantle. Even it stops during execution due to memory problem.

Second, it changes the results of other agents values!! this is very confusing for me.

Also, I am not sure, it might be a problem with how I implement "NonAggregateDataSource".
Please take a look this code implementing NonAggregateDataSource:
getValueOfState() is the method inside customer class that I am looking to look at its value.
Same as always, Thank you very much for your help and time.  


public class Consumers extends Agent implements NonAggregateDataSource{

public String getId() {
return "Customer Q Value";
}


@Override
public Class<?> getDataType() {
return double.class;
}


@Override
public Class<?> getSourceType() {
return this.getClass();
}

@Override
public Object get(Object obj) {
return ((Consumers) obj).getValueOfState();
}

}

------------------------------------------------------------
Elham Foruzan
PhD Student
Department of Electrical and Computer Engineering
University of Nebraska-Lincoln
214.4 B Scott Engineering 


On Wed, Nov 16, 2016 at 8:05 AM, Nick Collier <[hidden email]> wrote:
Just to clarify, in case others find this later, the proxy approach is good when you want to focus on a single agent where there are multiple _instances_ of that type of agent, not multiple types as I said below.

Nick

On Nov 15, 2016, at 4:44 PM, Nicholson Collier <[hidden email]> wrote:

Jonas’ advice re. proxy agents is a good one if you want to focus on a single agent where there are multiple types of that agent. For aggregate vs. non-aggregate and other data collection info, see:


Nick
On Nov 12, 2016, at 2:23 PM, [hidden email] wrote:

Nick, thank you so much. You are right. I just deleted the if , and it is working now. I should read more about the batch mode and its different with the regular mode. 

I have four type of agents, and more that one agent for each type. I am interested in looking at one agent Q table value, and seeing how it improves. Then If I want to look at just one agent is there a way to do that?
 I didn't get what you said about non-aggregated plot. Then If i have 10 customer agents and I want to look at how they average Q value improve during a day, I should use a aggregated feature. But then what is a difference between non-aggregated and aggregated? Can I see one feature of a specific agent type (e.g. Q value )  for those 10 agents in one plot using non-aggregated function?

Thank you for your prompt reply and  your kind support.




------------------------------------------------------------
Elham Foruzan
PhD Student
Department of Electrical and Computer Engineering
University of Nebraska-Lincoln
214.4 B Scott Engineering 


From: Nick Collier <[hidden email]>
Sent: Saturday, November 12, 2016 8:30:56 AM
To: Elham Foruzan
Cc: [hidden email]
Subject: Re: [Repast-interest] My code dose not stop using "RunEnvironment.getInstance().endAt(100)"
 
Are you running in batch mode? The endAt call is surrounded with an “if” that checks if you are running in batch mode. As for the plotting, if you have other agents of the same type, I don’t think you can plot just a single one. The non-aggregated plot will plot that characteristic for each agent of that type.

Nick

> On Nov 10, 2016, at 3:55 PM, Elham Foruzan <[hidden email]> wrote:
> 
> Hello,
> 
> My code had some problem with intialization when I was using the countiuos projection. I just used the grid, and it works now. However, the program is not finished at tick that I tell it to stop. For example, As you can see, when I ask it to stop at tick 100, it don't stop and I should stop it from run time simulator. 
> 
> Also, may I ask some body explain how can I plot a characterestic of specific agent (e.g. coustomer 1 ) using non-aggregated option in run time simulator. I am assuming that it is the way to do that, But I appreciate if you explain if there is another way as well. 
> Thank you very much. 
>     
>   package smartGrids;
> 
> import repast.simphony.engine.schedule.ScheduledMethod;
> 
> import java.text.DecimalFormat;
> import java.util.ArrayList;
> import java.util.Collection;
> 
> import repast.simphony.context.Context;
> import repast.simphony.context.DefaultContext;
> import repast.simphony.context.space.continuous.ContinuousSpaceFactory;
> import repast.simphony.context.space.continuous.ContinuousSpaceFactoryFinder;
> import repast.simphony.context.space.graph.NetworkBuilder;
> import repast.simphony.context.space.grid.GridFactory;
> import repast.simphony.context.space.grid.GridFactoryFinder;
> import repast.simphony.dataLoader.ContextBuilder;
> import repast.simphony.engine.environment.RunEnvironment;
> import repast.simphony.essentials.RepastEssentials;
> import repast.simphony.parameter.Parameters;
> import repast.simphony.space.continuous.ContinuousSpace;
> import repast.simphony.space.continuous.NdPoint;
> import repast.simphony.space.continuous.RandomCartesianAdder;
> import repast.simphony.space.grid.Grid;
> import repast.simphony.space.grid.GridBuilderParameters;
> import repast.simphony.space.grid.SimpleGridAdder;
> import repast.simphony.space.grid.WrapAroundBorders;
> 
> public class smartGridsBuilder implements ContextBuilder<Object> {
>        
>        
>        ArrayList<Agent> allAgents = new ArrayList<Agent>();
>        
>        
>        
>        @Override
>         public Context build ( Context < Object > context ) {
>                 context.setId("smartGrids");
>                 
>                 GridFactory gridFactory = GridFactoryFinder.createGridFactory(null);
>                        Grid<Object> grid = gridFactory.createGrid("grid",context,
>                                        new GridBuilderParameters<Object>(new WrapAroundBorders(),
>                                                        new SimpleGridAdder<Object>(), true, 100, 100));
>                 
>                 
>                   ContinuousSpaceFactory spaceFactory = ContinuousSpaceFactoryFinder
>                                        .createContinuousSpaceFactory(null);
>                        ContinuousSpace<Object> space = spaceFactory.createContinuousSpace(
>                                        "space", context, new RandomCartesianAdder<Object>(),
>                                        new repast.simphony.space.continuous.WrapAroundBorders(), 100,
>                                        100);
>                 
>                        
>                                 
>                 
>                        
>                        
>        Parameters params = RunEnvironment.getInstance().getParameters();
>        
>        double LoadVari = (Double) params.getValue("load_vari");
>        double load_k = (Double) params.getValue("load_k");
>        double LoadMaximum  = (Double) params.getValue("Load_Max");
>        
>        int consumerCount = (Integer) params.getValue("consumer_Count");
>        for (int i = 0; i < consumerCount; i++) {
>                
>                consumers.add(new Consumers(space, grid,"Consumer "+(i+1),LoadMaximum,LoadVari,DAY,Qtablec));
>                context.add(consumers.get(i));
>                allAgents.add(consumers.get(i));
>        }
>                        
>        context.add(ac);
>        
>                        
>        for(Object obj: context){
>                NdPoint pt=space.getLocation(obj);
>                grid.moveTo(obj, (int)pt.getX(),(int)pt.getY());
>                System.out.println((int)pt.getX());
>        }
>                        
>                        
>        if (RunEnvironment.getInstance().isBatch()) {
>                        RunEnvironment.getInstance().endAt(100);
>        }
>                                
>        return context ;
>  }
>        
> ------------------------------------------------------------------------------
> Developer Access Program for Intel Xeon Phi Processors
> Access to Intel Xeon Phi processor-based developer platforms.
> With one year of Intel Parallel Studio XE.
> Training and support from Colfax.
> Order your platform today. http://sdm.link/xeonphi_______________________________________________
> Repast-interest mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/repast-interest


------------------------------------------------------------------------------
Developer Access Program for Intel Xeon Phi Processors
Access to Intel Xeon Phi processor-based developer platforms.
With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today. http://sdm.link/xeonphi
_______________________________________________
Repast-interest mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/repast-interest



------------------------------------------------------------------------------

_______________________________________________
Repast-interest mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/repast-interest


------------------------------------------------------------------------------

_______________________________________________
Repast-interest mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/repast-interest
Loading...