Closed stefkuypers closed 4 years ago
Thanks for letting me know Stef. I'll look into this issue and get back to you as soon as possible. Best wishes, Ross
Hi Stef,
I apologise for taking so long to get back to you on this issue. I have fixed the bug - thank you very much for pointing this issue out to me.
In order to get your code to work, please update to the latest version of JAS-mine: version 3.1.9. You can do this simply by changing the versions of both JAS-mine-core and JAS-mine-gui dependencies in your project's pom.xml to 3.1.9 (please see the detailed instructions of section 1 in http://www.jas-mine.net/home/documentation/tutorials/how-to-update-jasmine).
I'd also highly recommend you update the JAS-mine Plugin for Eclipse IDE (to version 3.1.9.0), by following section 3 on the same webpage, http://www.jas-mine.net/home/documentation/tutorials/how-to-update-jasmine). This will ensure that whenever you use the plugin to create a new JAS-mine project in future, version 3.1.9 of the JAS-mine-core and JAS-mine-gui dependencies will be used by default.
Many thanks for your patience and best wishes,
Ross
Hi Ross,
Thank you for the update.
I have a question/request. I have not found any support for scatter plots but maybe I’m missing something. Are there any plans to implement them in the future?
Although I managed to create a working model, I have the feeling that I’m missing some deeper knowledge of how the platform works. For example, in order to plot the sum of a member variable of my agents I currently use an event in the model which then iterates over all agents to calculate the sum. But I have the feeling I should be able to use the SumFunction somehow but can’t figure out how. I guess a diagram of the classes and how they inter operate could be helpful.
Kind regards, Stef Kuypers Stand-up Entrepreneur
www.circularmoney.org www.thestandupway.org @Stef_Kuypers
On 25 Jan 2017, at 19:37, Ross Richardson notifications@github.com wrote:
Hi Stef,
I apologise for taking so long to get back to you on this issue. I have fixed the bug - thank you very much for pointing this issue out to me.
In order to get your code to work, please update to the latest version of JAS-mine: version 3.1.9. You can do this simply by changing the versions of both JAS-mine-core and JAS-mine-gui dependencies in your project's pom.xml to 3.1.9 (please see the detailed instructions of section 1 in http://www.jas-mine.net/home/documentation/tutorials/how-to-update-jasmine http://www.jas-mine.net/home/documentation/tutorials/how-to-update-jasmine).
I'd also highly recommend you update the JAS-mine Plugin for Eclipse IDE (to version 3.1.9.0), by following section 3 on the same webpage, http://www.jas-mine.net/home/documentation/tutorials/how-to-update-jasmine http://www.jas-mine.net/home/documentation/tutorials/how-to-update-jasmine). This will ensure that whenever you use the plugin to create a new JAS-mine project in future, version 3.1.9 of the JAS-mine-core and JAS-mine-gui dependencies will be used by default.
Many thanks for your patience and best wishes,
Ross
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/jasmineRepo/JAS-mine-core/issues/1#issuecomment-275193682, or mute the thread https://github.com/notifications/unsubscribe-auth/AJrgPQRC6Ic67Z9YIHUWxWp8o9JW0iQRks5rV5ZrgaJpZM4Ln-k2.
Hi Stef,
Again, a very many apologies for not getting back to you sooner; the past few weeks have been particularly busy for me (moving house, conference presentation etc.) and I wanted to spend a bit of time to properly address your questions.
Regarding the scatterplots, I've just implemented a new class called 'ScatterplotSimulationPlotter' in the microsimulation.gui.plot package that provides this functionality for you; it is based on the scatterplot in JFreeChart (http://www.jfree.org/). I have therefore made another new release of the JAS-mine-gui project (version 3.1.9.1) - so please follow the instructions I gave in my previous message to you about how to update to the latest JAS-mine release. In particular, please ensure that any project's pom.xml file is updated to refer to the dependency JAS-mine-gui version 3.1.9.1 instead of version 3.1.9.0 (you do not have to update the JAS-mine-core version number as this has not been updated; it should still be version 3.1.9). This also means that there is a new JAS-mine Plugin for Eclipse IDE available, so I would recommend updating that too, following the instructions I gave in my previous message to you, so that any new JAS-mine project that you create will automatically have a pom.xml file that refers to this latest version of the JAS-mine-gui libraries.
Information about using the ScatterplotSimulationPlotter class can be found in the gui package API (http://www.jas-mine.net/home/documentation/api). If you would like to see an example of how to implement a scatterplot run in a dynamic simulation, I attach a 'PersonsObserver.java' class file that is adapted from the Observer class of the LIAM2-demo07 demonstration model (that you can download at https://github.com/jasmineRepo/LIAM2-demo07). To see this in action, please download the demo07 model, and replace the PersonsObserver.java class from the download with the version I have attached here (you can simply copy and paste the unzipped PersonsObserver.java file into the package explorer in Eclipse). Also, remember to check that the project's pom.xml file refers to JAS-mine-gui version 3.1.9.1 (if you have just downloaded it from github, it should be up to date). Otherwise, please update the pom.xml file following the instructions in my previous message.
At the same time, this test Observer class may also help answer your other question about how to sum up values of your agents' fields. In the PersonsObserver.java file, you can see how charts are created to display a variety of average values of a population of agents' quantities, using the MeanArrayFunction on top of cross-section objects (see http://www.jas-mine.net/home/documentation/tutorials/how-to-use-the-jasmine-statistical-package for more information about cross-sections and associated functions). In your case, to obtain a population sum, you should use the SumArrayFunction class instead of the MeanArrayFunction. In fact, I do this in the scatter plot example in the attached file, using the SumArrayFunction.Integer function for the y-axis values of the scatter plot, while using a MeanArrayFunction to create the x-axis values.
Please let me know if I have answered your questions sufficiently or whether you need any clarification. Also, please let me know if there's anything else I can help you with.
Best wishes,
Ross
Hi Ross,
Thanks for getting back to me and thanks for creating the ScatterPlotSimulationPlotter. This will be of tremendous help for my project. Everything is clear right now and if I have any more questions I’ll let you know.
Kind regards, Stef Kuypers Stand-up Entrepreneur
www.circularmoney.org www.thestandupway.org @Stef_Kuypers
On 24 Feb 2017, at 16:29, Ross Richardson notifications@github.com wrote:
Hi Stef,
Again, a very many apologies for not getting back to you sooner; the past few weeks have been particularly busy for me (moving house, conference presentation etc.) and I wanted to spend a bit of time to properly address your questions.
Regarding the scatterplots, I've just implemented a new class called 'ScatterplotSimulationPlotter' in the microsimulation.gui.plot package that provides this functionality for you; it is based on the scatterplot in JFreeChart (http://www.jfree.org/ http://www.jfree.org/). I have therefore made another new release of the JAS-mine-gui project (version 3.1.9.1) - so please follow the instructions I gave in my previous message to you about how to update to the latest JAS-mine release. In particular, please ensure that any project's pom.xml file is updated to refer to the dependency JAS-mine-gui version 3.1.9.1 instead of version 3.1.9.0 (you do not have to update the JAS-mine-core version number as this has not been updated; it should still be version 3.1.9). This also means that there is a new JAS-mine Plugin for Eclipse IDE available, so I would recommend updating that too, following the instructions I gave in my previous message to you, so that any new JAS-mine project that you create will automatically have a pom.xml file that refers to this latest version of the JAS-mine-gui libraries.
Information about using the ScatterplotSimulationPlotter class can be found in the gui package API (http://www.jas-mine.net/home/documentation/api http://www.jas-mine.net/home/documentation/api). If you would like to see an example of how to implement a scatterplot run in a dynamic simulation, I attach a 'PersonsObserver.java' class file that is adapted from the Observer class of the LIAM2-demo07 demonstration model (that you can download at https://github.com/jasmineRepo/LIAM2-demo07 https://github.com/jasmineRepo/LIAM2-demo07). To see this in action, please download the demo07 model, and replace the PersonsObserver.java class from the download with the version I have attached here (you can simply copy and paste the unzipped PersonsObserver.java file into the package explorer in Eclipse). Also, remember to check that the project's pom.xml file refers to JAS-mine-gui version 3.1.9.1 (if you have just downloaded it from github, it should be up to date). Otherwise, please update the pom.xml file following the instructions in my previous message.
At the same time, this test Observer class may also help answer your other question about how to sum up values of your agents' fields. In the PersonsObserver.java file, you can see how charts are created to display a variety of average values of a population of agents' quantities, using the MeanArrayFunction on top of cross-section objects (see http://www.jas-mine.net/home/documentation/tutorials/how-to-use-the-jasmine-statistical-package http://www.jas-mine.net/home/documentation/tutorials/how-to-use-the-jasmine-statistical-package for more information about cross-sections and associated functions). In your case, to obtain a population sum, you should use the SumArrayFunction class instead of the MeanArrayFunction. In fact, I do this in the scatter plot example in the attached file, using the SumArrayFunction.Integer function for the y-axis values of the scatter plot, while using a MeanArrayFunction to create the x-axis values.
Please let me know if I have answered your questions sufficiently or whether you need any clarification. Also, please let me know if there's anything else I can help you with.
Best wishes,
Ross
PersonsObserver.java.zip https://github.com/jasmineRepo/JAS-mine-core/files/799737/PersonsObserver.java.zip — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/jasmineRepo/JAS-mine-core/issues/1#issuecomment-282319650, or mute the thread https://github.com/notifications/unsubscribe-auth/AJrgPcEakEtt3qk9zhHOnWuphvvJoQuMks5rfvdQgaJpZM4Ln-k2.
Hi Ross,
The work on the simulation has been shelved for a while due to some papers I needed to write and some conferences I went to but I’m picking it up again. I’be been looking at the ScatterPlotSimulationPlotter but I’m stuck.
Here’s what I want to do: I have a Person class with 3 properties (enums):
Now I’d like to plot pairs of these properties against each other for every person in the simulation. But I can’t figure out how to feed that data into the ScatterPlotSimulationPlotter. Which plottable object do I need to create for that?
Kind regards, Stef Kuypers Stand-up Entrepreneur
www.circularmoney.org www.thestandupway.org @Stef_Kuypers
On 24 Feb 2017, at 16:29, Ross Richardson notifications@github.com wrote:
Hi Stef,
Again, a very many apologies for not getting back to you sooner; the past few weeks have been particularly busy for me (moving house, conference presentation etc.) and I wanted to spend a bit of time to properly address your questions.
Regarding the scatterplots, I've just implemented a new class called 'ScatterplotSimulationPlotter' in the microsimulation.gui.plot package that provides this functionality for you; it is based on the scatterplot in JFreeChart (http://www.jfree.org/ http://www.jfree.org/). I have therefore made another new release of the JAS-mine-gui project (version 3.1.9.1) - so please follow the instructions I gave in my previous message to you about how to update to the latest JAS-mine release. In particular, please ensure that any project's pom.xml file is updated to refer to the dependency JAS-mine-gui version 3.1.9.1 instead of version 3.1.9.0 (you do not have to update the JAS-mine-core version number as this has not been updated; it should still be version 3.1.9). This also means that there is a new JAS-mine Plugin for Eclipse IDE available, so I would recommend updating that too, following the instructions I gave in my previous message to you, so that any new JAS-mine project that you create will automatically have a pom.xml file that refers to this latest version of the JAS-mine-gui libraries.
Information about using the ScatterplotSimulationPlotter class can be found in the gui package API (http://www.jas-mine.net/home/documentation/api http://www.jas-mine.net/home/documentation/api). If you would like to see an example of how to implement a scatterplot run in a dynamic simulation, I attach a 'PersonsObserver.java' class file that is adapted from the Observer class of the LIAM2-demo07 demonstration model (that you can download at https://github.com/jasmineRepo/LIAM2-demo07 https://github.com/jasmineRepo/LIAM2-demo07). To see this in action, please download the demo07 model, and replace the PersonsObserver.java class from the download with the version I have attached here (you can simply copy and paste the unzipped PersonsObserver.java file into the package explorer in Eclipse). Also, remember to check that the project's pom.xml file refers to JAS-mine-gui version 3.1.9.1 (if you have just downloaded it from github, it should be up to date). Otherwise, please update the pom.xml file following the instructions in my previous message.
At the same time, this test Observer class may also help answer your other question about how to sum up values of your agents' fields. In the PersonsObserver.java file, you can see how charts are created to display a variety of average values of a population of agents' quantities, using the MeanArrayFunction on top of cross-section objects (see http://www.jas-mine.net/home/documentation/tutorials/how-to-use-the-jasmine-statistical-package http://www.jas-mine.net/home/documentation/tutorials/how-to-use-the-jasmine-statistical-package for more information about cross-sections and associated functions). In your case, to obtain a population sum, you should use the SumArrayFunction class instead of the MeanArrayFunction. In fact, I do this in the scatter plot example in the attached file, using the SumArrayFunction.Integer function for the y-axis values of the scatter plot, while using a MeanArrayFunction to create the x-axis values.
Please let me know if I have answered your questions sufficiently or whether you need any clarification. Also, please let me know if there's anything else I can help you with.
Best wishes,
Ross
PersonsObserver.java.zip https://github.com/jasmineRepo/JAS-mine-core/files/799737/PersonsObserver.java.zip — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/jasmineRepo/JAS-mine-core/issues/1#issuecomment-282319650, or mute the thread https://github.com/notifications/unsubscribe-auth/AJrgPcEakEtt3qk9zhHOnWuphvvJoQuMks5rfvdQgaJpZM4Ln-k2.
Hi Stef,
Apologies for the delay in my reply; you caught me just before another conference I was presenting at, and I've only just returned.
I attach an example of a pre-existing demo project (Demo07) that I have further modified to include an additional scatterplot example, so you can see how to create scatterplots for your persons: demo07.zip
The most relevant files to check are the PersonsObserver class where two scatterplots are created (lines 122 to 138), and the Person class that now implements the IIntSource and defines some new 'ScatterplotVariables' to be used in the scatterplots (lines 205 to 225).
In the PersonsObserver class, the first 'scatterPlotter' is the previous plot I made after your request a few months ago that displays data from population aggregates, and the new 'scatterPlotter2' plot displays data at the individual level, with data from 100 persons (by default in this particular model, although you can change the amount of people to display in the GUI's PersonObserver's parameters, with the variable "Max Persons In Scatterplot").
The data displayed relates to the CivilState and WorkState enum values of the persons in the model, where the values of the enums are the ordinal values (i.e. the order number in which they are defined in the enum class, starting from 0 upwards) - see the CivilState and WorkState classes in the model.enums package; these are analogous to your LifeStyle, JobStatus and SaveProfile enums.
In the constructor of a ScatterplotSimulationPlotter, you can adjust how much historic data you want to display, i.e. whether you want to accumulate data from all previous chart updates (an update may be scheduled at each time-step, but it doesn't have to), or show just the previous 'n' updates where, by setting n = 1, you can display just the most recent values. In the creation of scatterPlotter2, I chose just to show the most recent data, so the last argument of the constructor is set to 1. Note also that I have turned the legend of the second scatterplot off when calling the scatterPlotter2 constructor in order to avoid having a legend of 100 agents. All this is customizable though, and will depend on the exact details of what you want to do.
In order to allow these customizations, I have updated the ScatterplotSimulationPlotter class in the JAS-mine-gui library, so the latest version is now 3.2.1.1 (while JAS-mine-core's latest version is 3.2.1). The POM file in the attached project already points to the correct libraries, so if you have maven installed in your IDE, the appropriate versions of JAS-mine will be downloaded and used. I do, however recommend you update the JAS-mine Plugin for Eclipse IDE to the latest version if you happen to use it, to ensure that any new projects will use the latest version of JAS-mine by default.
I hope this demo provides all the information you need in order to get started, though let me know if you need anymore help!
Best wishes,
Ross
Hi Stef,
I have created an additional, simpler way to create the scatterplot in the two updated files below, which you can use to overwrite the two corresponding files in the project I sent you yesterday:
The new method in PersonsObserver.java is on line 136, and does not require the Person class to implement the IIntSource interface, nor define any new variables. What is required, however, is a couple of new methods (lines 758 to 764 in Person.java), which convert the enums to integers (in this case just using the ordinal values).
The addSeries() method on line 136 in PersonsObserver.java uses Java reflection to inspect the person object using these new methods to provide the values in the scatterplot chart. Due to the overheads of Java reflection, this might be a slightly slower technique than the previous methods, but you may find it adequate for your simulations.
Hope this helps!
Ross
Thank you so much Ross!
I’ll look into it as soon as I get back from holiday.
Cheers, Stef Kuypers Stand-up Entrepreneur
www.circularmoney.org www.thestandupway.org @Stef_Kuypers
On 8 Jul 2017, at 00:00, Ross Richardson notifications@github.com wrote:
Hi Stef,
I have created an additional, simpler way to create the scatterplot in the two updated files below, which you can use to overwrite the two corresponding files in the project I sent you yesterday:
PersonScatterplot.zip https://github.com/jasmineRepo/JAS-mine-core/files/1132520/PersonScatterplot.zip The new method in PersonsObserver.java is on line 136, and does not require the Person class to implement the IIntSource interface, nor define any new variables. What is required, however, is a couple of new methods (lines 758 to 764 in Person.java), which convert the enums to integers (in this case just using the ordinal values).
The addSeries() method on line 136 in PersonsObserver.java uses Java reflection to inspect the person object using these new methods to provide the values in the scatterplot chart. Due to the overheads of Java reflection, this might be a slightly slower technique than the previous methods, but you may find it adequate for your simulations.
Hope this helps!
Ross
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/jasmineRepo/JAS-mine-core/issues/1#issuecomment-313812204, or mute the thread https://github.com/notifications/unsubscribe-auth/AJrgPewK_o4mJFdHebAlNMG4LS6EEc1eks5sLrifgaJpZM4Ln-k2.
When I create a Series object (a Series.Integer in my case) with the following constructor: public Series.Integer(java.lang.Object source, java.lang.String valueName, boolean getFromMethod) I get a NullPointerException when the updateSource() method is invoked. This is because the valueList has not been initialized.
Maybe I might be using the constructor for the wrong reasons but I find it strange that it would generate this error. What I intend to do is to collect a number from the model ( model.getSomeNumber() ) and feed that in a Series for display.