I have a network and simulate it in netlogo.In my network i have n nodes with a random data from [0.1,2,...,19].
at the beginning one random node became sink and 3 random nodes start to send its data to sink.i declare a variable named gamma.after nodes send their data to sink,sink decide to whether store that data in its memory space or not base on gamma.after 0.5s this process repeat.at each time some nodes are sink and want some data.this is the way i distribute data in my network.
after all i have to change gamma from 0 to 1 to determine best value for that. and each time run my code to plot count of something.i mean:first run my code with gamma=1 and after run it again with gamma=0.98 and ...
if Entropy <= gamma
[
do something
]
If i press the setup button each time i change gamma my network setup change and i can not compare the same network with another gamma.
How can i compare my network with multi value of gammas??
I mean is that possible to save all my process and run it exaclly the same again?
You can use random-seed to always create the same network and then use a new seed (created and set with random-seed new-seed) to generate the random numbers and ask order etc for your processing. The tool BehaviorSpace will allow you to do many runs with different values of gamma.
Using this approach will guarantee you the same network. However, just because a particular value of gamma is best for one network, does not make it the best for other networks. So you could create multiple networks with different seeds and have NetLogo select each network (as #David suggests) or you could simply allow NetLogo to create the different networks and run many simulations so that you have a more robust answer that works over an 'average' network.
It is possible if you design some tests first, when you put random data each time you press setup the previous graph is not the same as the new one, thus you'll need to load the same data everytime you want to test.
An idea:
Make text files with the node data and the value of gamma. For 4 nodes you'd have something like:
dat1.txt
1 3 2 9
1
dat2.txt
1 3 2 9
0.98
dat3.txt
1 3 2 9
0.96
And so on...
You can genereate this files with a procedure and an specific seed (see random-numbers), this means that if you want to generate 30 tests (30 sets of 4 nodes in the above example), you'll need 30 different seeds.
Related
Every time I run a simulation with the same parameters in the Run window I get exactly the same results. The results are different if a different number of replications is set each time the run is started
These are my settings in the run window:
enter image description here
I have a lot of Process blocks. Most of them have a normal distribution in duration. Why are the results not different?
If it helps in any way, her is a photo of the constructed model:
enter image description here
Arena uses the same random nr stream for your run unless you tell it to use another - so your first rep will look the same every time. The answer depends on the distributions you sample from. If you change the logic and sample at other times, the answer will change. Each following rep will have a unique answer based on the random nr streams you are sampling from. It makes it easier/possible to find errors if you can execute exactly the same run.
Arena provides (by default) ten different "streams" of (pseudo) random numbers. If you don't ask the system to use a particular stream, it will use stream 10. For example NORM(10,2) will use stream 10 to calculate a random normally distributed number (mean 10, standard deviation 2); NORM(10,2,4) will use stream 4 to calculate a similarly distributed number.
By default, the 10 random number generators for the streams are initialised at the beginning of each run to 14561, 25971, 31131, 22553, 12121, 32323, 19991, 18765, 14327, and 32535 (from Arena help). At the end of one replication, the generators will not be re-initialised, so they will start the next replication with a new value.
You can control the random number generator initialisation with the SEEDS element.
As #Marlize says, this helps to ensure that you can reproduce a simulation result if you need to.
I need to create an agent with a parameter "Class" that has 3 possible values. I need to be able to determine the number of agents with each class value at the Simulation screen before the simulation starts, by using a slider that determines the number of Agents.Class=="A", Agents.Class=="B" and so on.
I've tried creating an action chart that uses RandomTrue to assign the class.
The inputs for this action chart are:
A parameter sums the output of the 3 sliders to determine the total n of agents
Another parameter computes the percentage of agents.class=="A" from the total n of agents
A third parameter computes the percentage of the agents.class="B" from the remaining n of agents (n-agents.class=="A")
I'm not allowed to post pictures yet, but see action chart Here .
The issue with this is that when using percentages, it will round here or there and the actual number of agents with desired class may have one more or one less.
How can I make this with an exact number of agents created with each class?
This does not make sense mathematically. If you create 10 agents and the random number splits it using 0.66 and 0.33, then you cannot create 6.66 agents.
So some rounding must happen, unless you create infinite agents.
However, you can decide to round the random number. If you know you will create 100 agents, you could use Math.ceil(uniform(0, randomA)*100.) or similar. If randomA would be 0.66666, you would get 67 as a result.
(Math.floor would give you 66)
It isn't clear to me why you're converting the number to %-ages at all? Are you going to create N agents in total? If so you can just use amounts for class 'A' and class 'B' agents in two separate Source objects (one for each class) to create the agents at the start.
I'm working on a model in Netlogo and I'm having a problem understanding how to set up an "experiment". In my model, I have a matrix that has all of the values that I'm interested in (6 in total) and the matrix is updated whenever a condition is met (every time X turtles are killed off) basically capturing a snapshot of the model at that point. The previous values in the matrix are cleared, so the matrix is a 1x6, not a 10000x6 matrix with only one line being updated for each snapshot.
What I would like to do is to set up an experiment to run my model several hundred times, collecting this matrix each time for the first X number of snapshots or until Y ticks have occurred. But I can't see a way to do that in the experiment setup?
Is this possible to do, or would I have to create the 100x6 (100 snapshots) and then just export that matrix to a CSV somehow?
I've never set up an experiment in Netlogo, so this might be super easy to do or just be completely impossible.
If I understand your question correctly, then you want 6 values reported at specific ticks during the run. Those ticks are chosen by meeting a condition rather than a certain number of ticks. NetLogo has an experiment management tool called BehaviorSpace. It is straightforward to set up your several hundred runs (potentially with different values for any inputs on sliders etc). It's not so straightforward to only output on certain ticks.
The BehaviorSpace dialogue box has a checkmark for every tick or at the end only. If you have it set to every tick, then you can export your six numbers every tick automatically. In your case, it is likely to be easier to do that than to try and only output occasionally. You could add a seventh reporter that is true/false for whether the matrix is being reset this tick. Then all you have to do in post-processing is select the lines where that seventh reporter is true.
If you want to run the model for exactly N snapshots, then you would also need to set up a global variable that is incremented each snapshot point. Your BehaviorSpace settings would then use that counter for the stop condition.
I'm not sure I understand your question, but usually you will have a Setup function and a Run function, correct? So I'm guessing the code structure below should be kind of what you are looking for. I haven't used netlogo in a while so the exact matrix code you'll have to figure out yourself.
globals your-1by6-matrix your-100by6-matrix
to setup
;reset your experiment
end
to run
;run your experiment
end
to run100times
repeat 100[
setup
run
;save your 1by6matrix into your 100by6matrix
]
;use your 100by6matrix to plot or export
end
I am working on an exercise to build influencer score for each user in my data set. What that means is that a user with higher engagement should get higher score and vice versa. however, i have many different type of engagement variables and i am not sure which one should weight higher.
so, i first did a cluster analysis to divide users into different group based on engagement activity using 5 different types of engagement. Based on this, i found that one of the cluster has high level of engagement across all the different types of engagement variables. This is the group i am interested in. however, it is possible that the group size i get may be smaller than the number of users i want to use in future. so, i want to now use these clusters and create a propensity score.
e.g. in the cluster analysis, say i get 5 clusters c1, c2,c3,c4,c5 and c5 is my cluster of interest. so, i give all users in c5 a value of 1 (= influencer) and i give all users in c1 to c4 a value of 0 (= not influencer). now, i use this binary variable and build a logistic regression model (using same engagement variables as used for clustering) to get propensity for everyone to an influencer. this way, i can change the threshold to reduce or increase the numbers of users i want to select.
Now, the issue i am running in is that one of the engagement variable is able to predict influencer very well and hence my propensity scores are very close to either 1 or 0 which defeats the purpose of why i wanted the propensity score in the first place.
S0, 2 questions -
1) is this approach of building a unsupervised classification and then using this to build supervised classification a sound approach of what i am trying to do?
2) how do i reduce the contribution from the variable that predicts influencer really well to ensure that i get much more smoother curve instead of values near 0 or 1. i don't want to remove this variable from the model as this is important from business perspective.
I have designed a simple simulink and stateflow diagrams on Matlab. It works perfectly! But I have two issues:
1) The model runs too fast. The transition time between two states are amazingly fast that I can not see. I tried to change some parameters, but I was not succeed. What should I change (maybe on Model Configuration Parameters?) to make it slower so we can see the transitions?
2) Currently I just have a constant input. How can I set a series of constants, probably periodic? I assume there should be a special component. I need, like an input of say 0 at time 0, then 1 after 1 minute, 2 at time 3, etc ?
1) I had the same issues with some interactive simulations where the CPU would make them run too fast for the user to interact. Using a Simulink Real Time Execution Block brought the solution, despite it gives heavy CPU load due to the solution it uses. With this, if you define a 10sec simulation, that's what it will last. If you don't want to pass through this burden, just lengthen your simulation, or inspect thoroughly the scopes throughout the whole simulation (disabling point limit in the Scope, clicking the Parameters button and then unchecking Data History/Limit data points to last...)
2) Simulink/Sources/Repeating Sequence. You define vectors of times and the value to output in that time. Keep in mind that the block interpolates the values between two points, therefore, if you want to change from 2 to 3 in T=1s, you have to define two points, one U=2 in T=1s and another U=3 in T=1s. For example, 0 in (0..1), 5 in (1..2), 10 in (2..3) and 15 in (3..4):
Time values: [0 1 1 2 2 3 3 4]
Output values: [0 0 5 5 10 10 15 15]
If you just want to check the transitions, you don't need to make it slower. You can try to use the Debug mode available in Stateflow and you can see how your model works step by step.
The option to slow down Stateflow animation (so that, for example, you can better see the transitions between states during simulation) is under the Display menu in the Simulink menu bar.
In the latest release (R2014b), the option is under Display->Stateflow Animation (as well as under Simulation->Stateflow Animation). (See here for more details.)
In older releases, it's under Display->Data Display in Simulation->Chart Animation Delay (sec) (although, I'm not 100% sure when this option was moved in the menus).
Note that you have to be inside of the chart for these options to be enabled in the menu.