Turtles location in Netlogo - location

I create 100 turtles in Netlogo and I want to locate them only in particular locations corresponding to Building type 1. These locations are the grey patches of the image (Building type 1).
I assigned the Building type 1 to the patches in grey of my shapefile using the GIS extension and the gis:apply-coverage primitive.
Can someone help me to develop a code for assign these turtles only to these grey patches randomly? or what is better only to this Building type 1 of my shape file?.

There's a couple of options depending on the number of buildings (compared to your 100 turtles). This code is untested, but will hopefully get you going in the right direction.
If each building should have no more than 1 turtle, then do this:
ask n-of 100 patches with [type = 1] [sprout turtles 1]
If there are lots of turtles and they can be assigned to any building patch:
create-turtles 100 [ move-to one-of patches with [type = 1] ]

Related

4x4 Matrix (3D) animation

I'm currently trying to animate a 3D object from one transform matrix to another. I know the "origin" and "target" transform matrix (4x4), and would like to get the "intermediate" matrices between to do an animation with a "progress" variable [0, 1].
For example, I could go from:
1 0 0 0
0 1 0 0
0 0 1 0
0 0 0 1
To:
0.70711 -0.70711 0 0
0.70711 0.70711 0 0
0 0 1 0
0 0 0 1
It's a simple 45deg rotation, and I would like to be able to find intermediate matrix for a 0.5 progression for example. Of course, here it's simple, and I perfectly know how to animate it, but I which for an algorithm able to work for more complex transform matrices (one which contains translations, rotations on multiple axis and scaling).
I found some articles:
https://research.cs.wisc.edu/graphics/Courses/838-s2002/Papers/polar-decomp.pdf
https://link.springer.com/article/10.1007/s11075-016-0098-7
And even search on the chrome and firefox source code which use this kind of algorithm to animate css transform property: https://github.com/chromium/chromium/blob/2ca8c5037021c9d2ecc00b787d58a31ed8fc8bcb/cc/animation/transform_operation.cc
Sadly, I was not able to find a clear solution. No authors provide a proper algorithm (the ones provided are extremely abstract and doesn't specify their "sub-functions/algorithm"). Only a very few papers are available. And finally they don't provide any example (from one matrix to another) so it's almost impossible to verify their method.
Has any of you already faced this problem and implemented a solution ? Clear example, or pseudo code would be perfect, if someone knows the answer.
In any case, thanks in advance for all your help.
So, I finally found a solution: the w3c provides an algorithm to interpolate the transform matrices: https://www.w3.org/TR/css-transforms-2/#matrix-interpolation
It works in 3 steps:
decomposition: splits the matrix in translation, scaling, skewing, perspective and rotation (quaternion) vectors
interpolation: creates interpolated new vectors from the previous ones
recomposition: compose a transform matrix from these vectors
It may not be the faster but it does the job.

Assign a value for movement within the neighbourhood in NetLogo

In NetLogo I would like to modify this code:
to go
ask patches with [not any? turtles-here]
[ move-particle-to-here ]
tick
end
to move-particle-to-here
let particle one-of turtles-on neighbors4
if particle != nobody [
ask particle [ move-to myself ]
]
end
and assign a value or probability for volume exclusive movement within the neighbourhood.
I have two breeds, one called 'solvent' and one called 'particle'. I want to ask the particles and solvent to move only with a certain probability or value. For example if a particle has 3 solvents in its neighbors4, it will move will a probability of (probability)^3.
Any help at all would be greatly appreciated as I have found little by searching online.
Thanks!

How to obtain the same landscape with different road grids?

I would like to get the same landscape at each time that I create a landscape in NetLogo. For this, I used
random-seed 0
create-landscape
It works when I keep the same configuration of roads (represented in white in the figure below) at each time that I create a landscape :
Figure 1:
However, when I change the configuration of roads, the location of blue, black, and red blocks is different (see figures below) by using random-seed 0.
Figure 2:
Figure 3:
For figures 2 and 3, I'm looking for a way to obtain the same location of blue, black, and red blocks than in Figure 1.
The roads have been built by using Traffic Grid. To built my landscapes, I create, in the first time, the road grid and then, I randomly place the black, blue, and red blocks.
Thanks very much for your help.
Something in your road network generation code affects the state of the random number generator. It can be lots of things. Even a simple ask, for example, makes use of randomness (to iterate through agents in random order). See the section on random numbers in the programming guide.
There are probably a couple of different ways to handle this, but I would suggest using with-local-randomness to isolate the code that creates blocks and have it use its own random number generator. Something like:
to create-landscapes
create-roads
with-local-randomness [
random-seed 0
create-blocks
]
end
Perhaps make the landscape first.... then overlay the roads. This may also simplify the landscape code, since your code won't have to worry about overwriting roads.
Also, perhaps its time to graduate from only using color. Perhaps patches need a variable like "is-road?" and another like "land-use"... fill those variables separately. Then it's a only a matter of how you display the information, such as:
ask patches
[ ifelse is-road?
[ set pcolor white ]
[ set pcolor item land-use land-use-colors ]
]

how to generate feature - image incidence matrix?

please help me to understand this idea from a paper which titled is "Scene Summarization for Online Image Collections" by Ian Simon Noah Snavely Steven M. Seitz, University of Washington.
Computing the Feature-Image Matrix :
We first transform the set of views into a feature-image
incidence matrix. To do so, we use the SIFT keypoint detector
to find feature points in all of the images in V. The
feature points are represented using the SIFT descriptor.
Then, for each pair of images, we perform feature matching
on the descriptors to extract a set of candidate matches.
We further prune the set of candidates by estimating a fundamental
matrix using RANSAC and removing all inconsistent
matches After the previous step is complete
for all images,
we organize the matches into tracks,
where a track is a connected component of features. We remove
tracks containing fewer than two features total, or at
least two features in the same image. At this point, we consider
each track as corresponding to a single 3D point in S.
From the set of tracks, it is easy to construct the |S|-by-|V|
feature-image incidence matrix.
the part which i confused about is the italic one.
how we organize matches into tracks ?
and how to construct feature-image incidence matrix ?
pls help me. . .
Example for 3 images track.
Detect features
Perform matching (1 - 2, 2 - 3). Now you have correspondences FeatureA_img1 = FeatureB_img2, FeatureC_img2 = FeatureD_img3, FeatureE_img1 = FeatureF_img3.
Check, if FeatureA_img1 == FeatureB_img2 AND FeatureB_img2 == FeatureC_img3, than you have the same feature in 3 images.
Save it in the array:
img1 img2 img3 ... imgn
FeatureA FeatureB FeatureC ...
Repeat this for all correspondences. The rows in this table are the tracks you are looking for.

Making a good XY (scatter) chart in VB6

I need to write an application in VB6 which makes a scatter plot out of a series of data points.
The current workflow:
User inputs info.
A bunch of calculations go down.
The output data is displayed in a series of 10 list boxes.
Each time the "calculate" button is clicked, 2 to 9 entries are entered into the list boxes.
One list box contains x coordinates.
One list box contains the y coordinates.
I need to:
Scan through those list boxes, and select my x's and y's.
Another list box field will change from time to time, varying between 0 and 100, and that field is what needs to differentiate which series on the eventual graph the x's and y's go into. So I will have Series 1 with six (x,y) data points, Series 26 with six data points, Series 99 with six data points, etc. Or eight data points. Or two data points. The user controls how many x's there are.
Ideally, I'll have a graph with multiple series displaying all this info.
I am not allowed to use a 3rd party solution (e.g. Excel). This all has to be contained in a VB6 application.
I'm currently trying to do this with MS Chart, as there seems to be the most documentation for that. However, this seems to focus on pie charts and other unrelated visualizations.
I'm totally open to using MS Graph but I don't know the tool and can't find good documentation.
A 2D array is, I think, a no go, since it would need to be of a constantly dynamically changing size, and that can't be done (or so I've been told). I would ideally cull through the runs, sort the data by that third series parameter, and then plug in the x's and y's, but I'm finding the commands and structure for MS Chart to be so dense that I'm just running around in very small circles.
Edit: It would probably help if you can visualize what my data looks like. (S for series, made up numbers.)
S X Y
1 0 1000000
1 2 500000
1 4 250000
1 6 100000
2 0 1000000
2 2 6500
2 4 5444
2 6 1111
I don't know MSGraph, but I'm sure there is some sort of canvas element in VB6 which you can use to easily draw dots yourself. Scatter plots are an easy graph to make on your own, so long as you don't need to calculate a line of best fit.
I would suggest looking into the canvas element and doing it by hand if you can't find a tool that does it for you.
Conclusion: MSChart and MSGraph can both go suck a lemon. I toiled and toiled and got a whole pile of nothing out of either one. I know they can do scatter plots, but I sure as heck can't make them do 'em well.
#BlackBear! After finding out that my predecessor had the same problems and just used Pset and Line to make some really impressive graphs, I did the same thing - even if it's not reproducible and generic in the future as was desired. The solution that works, albeit less functionally >> the solution with great functionality that exists only in myth.
If anyone is reading this down the line and has an actual answer about scatter plots and MSChart/Graph, I'd still love to know.

Resources