Science topic

# Netlogo - Science topic

Explore the latest questions and answers in Netlogo, and find Netlogo experts.

Questions related to Netlogo

I have a set of positive COVID-19 cases by district in a state. I want to use agent based modelling to make the infected cases move around the state and count the number of infected, number of healthy and number of immune. I have a set of code which the number of population is random and not based on the location. Tried to watch youtube for the tutorial but could not find one which really helps. the code is as below. I want to insert the map of the state, number of population for each district and number of infected in Netlogo.

urtles-own [illness]

to setup

clear-all

reset-ticks

create-turtles 200 [

setxy random-xcor random-ycor

set shape "person"

set color pink

set size 1.0

set illness 0

]

ask n-of starting-number-infected turtles [

set color yellow

set shape "X"

set size 1.0

]

end

to go

tick

move

infect

recover

lose-immunity

end

to move

ask turtles [

rt random 360

fd movement

]

end

to infect

ask turtles [

if color = yellow [

ask turtles in-radius infect-distance [

if random-float 200 < infect-chance [

if color = pink [

set color yellow

set shape "X"

]

]

]

]

]

end

to recover

ask turtles [

if color = yellow [

set illness illness + 1

if illness > infectious-period [

set color white

set shape "circle"

set size 1.0

set illness 0

]

]

]

end

to lose-immunity

ask turtles [

if color = white and waning-immunity < random-float 100 [

set color pink

set shape "person"

]

]

end

i want to use agent basic modeling on map

Hi there!

I'm starting to model an urban simulation and I'm having a bit of a dilemma regarding what language to use. Have some experience in Netlogo and I'm starting to make a shift towards Repast, GAMA or MESA (geo-mesa), because it is recommended for large scale simulations.

Have been reading papers about which tool to use, but I need someone working on simulations to help me out.

Still, I have questions because:

1- The user base of MESA is scarce and i feel that dealing with issues will be dificult

2- So far i have only seen and read about limited research done in MESA. Specially, dealing with road network integrations. (move an agent along a network)

3- It seems that Netlogo is good for prototype, will not handle big data projects

Thanks in advance, and any pointers to courses or moocs would be great.

Suppose we have a system designed to deliver services to customers arriving during weekdays. The arrival process is modeled as a Poisson process with an Arrival rate of λ, also we use agent-based modeling with NetLogo to study the behavior of customers. After multiple Observation and replication of the model, the first 8 hours was selected as the warm-up period and the remaining time as the steady-state. If we consider the average length of stay (ALOS) as the crucial output data, how should we handle the initialization bias in this case?

As a workaround, is removing those data sufficient if we take into account the effects of the warm-up period on the ALOS?

The aim is to simulate the behavior of agricultural agents in different socio-ecological framework conditions and integrate the simulation with a GIS. I know my way around QGIS and have basic but no significant programming skills yet. I thought of using PYTHON, because I want to learn this language anyhow for GIS scripts, data analysis and statistics. What are the pros/cons of working with MESA, GAMA and SPADE in this regard? NETLOGO is also an option, but would not necessarily be my first choice ...

Thank you for any tips and experiences working in these environments, or for any other possible solutions that might be more feasible for this project!

I have data from experiments for number of variables as logging, salinity and water use of 150 farmers for 1000 time steps. Farmers' information on land size and distance from water source are available. I want to see that if logging salinity and water use is different considering farmer size and distance from water source as a starting point. I am not sure if cluster analysis will be of any help. I expect to see the graph attached here. Any lead for methods to analyze this type of data set!.

Thanks

I want to develop multi agent based control system for fire disaster management.

Could anyone share sample code of implementing agent-based model of the Emergency department in Netlogo with me?

**I would to ask about programming language is use in NetLogo? it is Java , c++ or what ?**

I am currently working on using GIS data inside Netlogo using the provided GIS extension. However, i am facing a runtime error saying that

"extension exception: shapefile data <filename> not found"

"error while observer running gis:load-dataset"

I think, the error might be caused by the data directory (where i put the shp data) which is unable to be called by the function.

Thus, i need some insight from other researchers that has experience using this software. million thanks.

I am using system dynamics as a method for constructing a model of the research-to-impact process in my PhD project.

My university doesn't have the 'usual' system dynamics software such as Vensim, Ithink, or Stella, but does have the system modelling software ExtendSim. I can see it's mainly been used for agent-based modelling, but is it possible to use it for system dynamics modelling too?

If not, does anybody have experience with the free system dynamics software packages NetLogo or Simantics System Dynamics, and what were your experiences with either of these?

Thanks very much,

Alexandra van Beek

In my project of thesis i need simulate the moment of decision in the organizational context. My idea is use Netlogo, but i want see some application in management before.

Hi, I am trying to to use a modification of the erosion model in the netlogo library to simulate erosion on a real landscape. I have already inputted the landscape. I need help with codes that can include vegetation cover (0 to 1) as an environmental parameter and also calculate the erosion rates (intend to display it on a monitor on the interface).

If you have a variable Xt that changes at every time t, but then is required any function of Xt, Xt-1, Xt-2 .-- and so on until X0 (past values).

Thanks for your opinion.

Is there any open NetLogo implementation code on tax evasion/compliance other than İcan (2013)?

/** IDEAL ENERGY LANDSCAPE OF HORN CLAUSES **/

/** Bipolar Sigmoid Activation Function **/

How to developed the code by using NetLogo for Bipolar Sigmoid Activation Function ?

/** IDEAL ENERGY LANDSCAPE OF HORN CLAUSES **/

/** Bipolar Sigmoid Activation Function **/

#include<stdio.h>

#include<stdlib.h>

#include<math.h>

#include<time.h>

#define NN 10 /** Neurons **/

#define Nc1 2 /** First order **/

#define Nc2 2 /** Second second order **/

#define Nc3 2 /** Third order **/

#define NH 100 /** Number of Hebbian Learning **/

#define RELAX 100 /** Relaxation time **/

#define NT 100 /** Number of trial **/

#define COMBMAX 100 /**Maximum combination for neurons **/

#define TOL 0.001 /** Tolerance value **/

#define TRUE 1

#define FALSE 0

#define NEGBIAS -0.0

#define NCHCHECK 5

void main()

{

time_tstart,end;

doubledif;

int c3[Nc3][3],c2[Nc2][2],c1[Nc1],i,j,k,l,y,z,n,m,NS[NN],Nbef[NN],iev,ievn,p,comb;

int NI[NN],NF[NN];

floatzM,yM,nrelaxM,nrelaxMM;

float J1[NN],J2[NN][NN],J3[NN][NN][NN];

float Erg1,Erg2,Erg3,E1,E2,E3;

floatdevG,devHD,devHG,devHL;

float ES;

floatEav;

float min;

float h[NN];

floatEavM;

floatvarians,variansR;

floatsp,spR;

float EM,EAM;

floatHamming_Distance,HDG,HDL,HDGlobal,HDLocal;

intchange,nchange,nrelax;

floatnR,NRE,htaf;

time (&start);

FILE *outf;

srand(time(NULL));

outf=fopen("ss_mine.txt","w");

printf(" hebb logic v 2.1 \n");

printf(" ---------------- \n\n");

printf("Ideal energy landscape of horn clauses \n\n");

fprintf(outf,"Ideal energy landscape of horn clauses \n\n");

printf(" no. of neurons: %d\n no. of learning events: %d\n RELAX time: %d\n no.of trials: %d\n COMBMAX: %d\n ",NN,NH,RELAX,NT,COMBMAX);

fprintf(outf," hebb logic v 2.1 \n");

fprintf(outf," ---------------- \n\n");

fprintf(outf," no. of neurons: %d\n no. of learning events: %d\n RELAX time: %d\n no.of trials: %d\n COMBMAX: %d\n",NN,NH,RELAX,NT,COMBMAX);

printf(" Nc1= %d Nc2= %d Nc3= %d \n",Nc1,Nc2,Nc3);

fprintf(outf," Nc1= %d Nc2= %d Nc3= %d \n",Nc1,Nc2,Nc3);

printf(" TOL = %f \n",TOL);

fprintf(outf," TOL = %f \n",TOL);

/**Initialize average energy **/

EavM=0; //average synaptic energy for NT

zM=0; //average global minima for synaptic

yM=0; //average local minima for synaptic

ES=-NN*NEGBIAS; //minimum energy suppose for synaptic

EM=0; //calculation of varians

EAM=0;

z=0; //global minima

y=0; //local minima

Eav=0; //energy average

HDG=0;

HDL=0;

HDGlobal=0;

HDLocal=0;

nrelaxM=0.0;

nrelaxMM=0.0;

Hamming_Distance=0;

nR=0;

NRE=0;

/** Generating minimum energy suppose to be **/

/** For first order **/

for(i=0;i<Nc1;i++){

ES+=-0.5;

}

/** For second order **/

for(i=0;i<Nc2;i++){

ES+=-0.25;

}

/** For third order **/

for(i=0;i<Nc3;i++){

ES+=-0.125;

}

printf("ES= %f \n\n",ES);

fprintf(outf,"ES= %f \n\n",ES);

/** Loop for random clauses combination **/

for(comb=0;comb<COMBMAX;comb++) { //combination loop begin

/** generate random clauses **/

/** First order **/

for(i=0;i<Nc1;i++){

stt:

c1[i]=(int)(((float)rand()/(float)RAND_MAX)*(float)NN);

for(j=0;j<i;j++)

{ if(c1[j]==c1[i])

gotostt;

}

}

/** Second order**/

for(i=0;i<Nc2;i++){

stt1:

c2[i][0]=(int)(((float)rand()/(float)RAND_MAX)*(float)NN);

stt11:

c2[i][1]=(int)(((float)rand()/(float)RAND_MAX)*(float)NN);

if (c2[i][0]==c2[i][1]) goto stt11;

for(j=0;j<i;j++) {

if(c2[j][0]==c2[i][0]&&c2[j][1]==c2[i][1]) goto stt1;

}

}

/** Third order **/

for(i=0;i<Nc3;i++){

stt2:

c3[i][0]=(int)(((float)rand()/(float)RAND_MAX)*(float)NN);

stt21:

c3[i][1]=(int)(((float)rand()/(float)RAND_MAX)*(float)NN);

if (c3[i][0]==c3[i][1]) goto stt21;

stt22:

c3[i][2]=(int)(((float)rand()/(float)RAND_MAX)*(float)NN);

if (c3[i][0]==c3[i][2]||c3[i][1]==c3[i][2]) goto stt22;

for(j=0;j<i;j++) {

if(c3[j][0]==c3[i][0]&&

((c3[j][1]==c3[i][1]&&c3[j][2]==c3[i][2])||

(c3[j][1]==c3[i][2]&&c3[j][2]==c3[i][1])))

goto stt2;

}

}

/** Initialize synaptic strengths to zero **/

for(i=0;i<NN;i++){

J1[i]=NEGBIAS;

for(j=0;j<NN;j++) {

J2[i][j]=0.0;

for(k=0;k<NN;k++) {

J3[i][j][k]=0.0;

}

}

}

/** Derive J1 for first order**/

for(i=0;i<Nc1;i++) {

J1[c1[i]]+=0.5;

}

/** Derive J2 for second order **/

for(i=0;i<Nc2;i++){

J2[c2[i][0]][c2[i][1]]+=0.25;

J2[c2[i][1]][c2[i][0]]+=0.25;

J1[c2[i][1]]+=-0.25;

J1[c2[i][0]]+=0.25;

}

/** Derive J3 for third order **/

for(i=0;i<Nc3;i++) {

J3[c3[i][0]][c3[i][1]][c3[i][2]]+=0.0625;

J3[c3[i][0]][c3[i][2]][c3[i][1]]+=0.0625;

J3[c3[i][1]][c3[i][2]][c3[i][0]]+=0.0625;

J3[c3[i][2]][c3[i][1]][c3[i][0]]+=0.0625;

J3[c3[i][2]][c3[i][0]][c3[i][1]]+=0.0625;

J3[c3[i][1]][c3[i][0]][c3[i][2]]+=0.0625;

J2[c3[i][1]][c3[i][0]]+=0.125;

J2[c3[i][0]][c3[i][1]]+=0.125;

J2[c3[i][1]][c3[i][2]]+=-0.125;

J2[c3[i][2]][c3[i][1]]+=-0.125;

J2[c3[i][0]][c3[i][2]]+=0.125;

J2[c3[i][2]][c3[i][0]]+=0.125;

J1[c3[i][2]]+=-0.125;

J1[c3[i][0]]+=0.125;

J1[c3[i][1]]+=-0.125;

}

/** Loop to generate random numbers**/

ievn=0; //number of events satisfy

for(iev=0;iev<NH;iev++) { //number of events satisfy and not satisfy

sth:

ievn++;

for(j=0;j<NN;j++){

if((float)rand()<(float)RAND_MAX/2.0)

NS[j]=-1;

else NS[j]=+1;

}

/** Checking clauses satisfaction by events **/

/** For first order **/

for(k=0;k<Nc1;k++){

if(NS[c1[k]]==-1) gotosth;

}

/** For Second Order **/

for(k=0;k<Nc2;k++){

if(NS[c2[k][0]]==-1 && NS[c2[k][1]]==+1)

gotosth;

}

/** For Third Order **/

for(k=0;k<Nc3;k++){

if(NS[c3[k][0]]==-1 && NS[c3[k][1]]==+1 && NS[c3[k][2]]==+1)

gotosth;

}

} //end of learning process

/**Looping number of trial **/

for(p=0;p<NT;p++){ //number of trial loop begin

/** Initialize random starting point **/

for(m=0;m<NN;m++){

if((float)rand()<(float)RAND_MAX/2.0)

NS[m]=-1;

else NS[m]=+1;

NI[m]=NS[m]; //Initial State

}

/** Looping energy relaxation **/

nrelax=0;

nchange=0;

do {

/** Calculating h **/

change=FALSE;

for(i=0;i<NN;i++){ //sub major loop

j=((float)NN)*(((float)rand()/(float)RAND_MAX));

h[j]=0;

h[j]+=J1[j];

for(k=0;k<NN;k++){

h[j]+=J2[j][k]*NS[k];

for(l=0;l<NN;l++){

h[j]+=J3[j][k][l]*NS[k]*NS[l];

}

}

/** Bipolar sigmoid activation function **/

htaf=(1-exp(-h[j]))/(1+exp(-h[j]));

Nbef[j]=NS[j];

if(htaf>=0)

NS[j]=+1;

else

NS[j]=-1;

if(NS[j]!=Nbef[j])

change=TRUE;

} //sub major loop end

if(change==TRUE)

nchange=0;

elsenchange+=1;

nrelax+=1;

} while (nchange<NCHCHECK);

/** Calculating Final State **/

for(m=0;m<NN;m++) {

NF[m]=NS[m]; //Final State

}

/** Energy Calculation **/

Erg1=0;Erg2=0;Erg3=0;

E1=0;E2=0;E3=0;

for(l=0;l<NN;l++){

for(j=0;j<NN;j++){

for(k=0;k<NN;k++){

E1+=J3[l][j][k]*NS[l]*NS[j]*NS[k];

Erg1=-E1/3;

}

}

}

for(l=0;l<NN;l++){

for(j=0;j<NN;j++){

E2+=J2[l][j]*NS[l]*NS[j];

Erg2=-E2/2;

Erg2+=Erg1;

}

}

for(l=0;l<NN;l++){

E3+=J1[l]*NS[l];

Erg3=-E3;

Erg3+=Erg2;

}

/** Calculating global and local minima **/

if(fabs(ES-Erg3)<=TOL) {

z+=1;

for(m=0;m<NN;m++)

HDG+=0.5*(1-NI[m]*NF[m]);

}

if(fabs(ES-Erg3)>TOL){

y+=1;

for(m=0;m<NN;m++)

HDL+=0.5*(1-NI[m]*NF[m]);

}

/** Calculating EM **/

EM+=Erg3*Erg3;

/**Calculating average energy **/

Eav+=Erg3/(float)NT;

/** Calculating nR **/

nR+=nrelax*nrelax;

/** Calculating relaxation **/

nrelaxM+=(nrelax-NCHCHECK)/((float)NT);

} // number of trials

} //Loop for number of combination

/**Calculating average energy for all the combination **/

EavM+=Eav/(float)COMBMAX; //average energy for synaptic

zM+=(float)z/((float)NT*(float)COMBMAX); //global minima for synaptic

yM+=(float)y/((float)NT*(float)COMBMAX); //local minima for synaptic

EAM+=EM/((float)NT*(float)COMBMAX); //varians calculation

nrelaxMM+=nrelaxM/(float)COMBMAX;

HDGlobal+=HDG/((float)NT*(float)COMBMAX * z);

HDLocal+=HDL/((float)NT*(float)COMBMAX * y);

NRE+=nR/((float)NT*(float)COMBMAX);

/** Calculating varians **/

varians=(float)EAM-pow(EavM,2);

/** Standard DEviation **/

sp=sqrt(varians);

/** Calculating varians for relax**/

variansR=(float)NRE-pow(nrelaxMM,2);

/** Standard DEviation for relax**/

spR=sqrt(variansR);

/** Calculating Hamming Distance **/

if(y==0)

Hamming_Distance+=HDGlobal;

else

Hamming_Distance+=HDGlobal+HDLocal;

/** Deviation for Hamming Distance**/

devHD=sqrt(Hamming_Distance-(Hamming_Distance*Hamming_Distance));

/** Deviation for global **/

devG=sqrt(zM-(zM*zM));

/** Deviation for HDG **/

devHG=sqrt(HDGlobal-(HDGlobal*HDGlobal));

/** Deviation for HDL **/

devHL=sqrt(HDLocal-(HDLocal*HDLocal));

/**Printing out clauses (one set only)**/

printf("\n Clauses:\n\n");

fprintf(outf,"\n Clauses:\n\n");

for(i=0;i<Nc1;i++){ //First order **/

printf("c1[%d] : %d <- .\n",i,c1[i]);

fprintf(outf,"c1[%d] : %d <-.\n",i,c1[i]);

}

printf("\n");

fprintf(outf,"\n");

for(i=0;i<Nc2;i++){ //Second order

printf("c2[%d] : %d <- %d .\n",i,c2[i][0],c2[i][1]);

fprintf(outf,"c2[%d] : %d <- %d .\n",i,c2[i][0],c2[i][1]);

}

printf("\n");

fprintf(outf,"\n");

for(i=0;i<Nc3;i++){ //Third order

printf("c3[%d] : %d <- %d, %d .\n",i,c3[i][0],c3[i][1],c3[i][2]);

fprintf(outf,"c3[%d] : %d <- %d, %d .\n",i,c3[i][0],c3[i][1],c3[i][2]);

}

printf("\n");

fprintf(outf,"\n");

/**For synaptic weight **/

printf("For synaptic weight\n\n");

fprintf(outf,"For synaptic weight\n\n");

printf

("\n zMHamming_Distance \n");

printf

(" %f %f \n",zM,Hamming_Distance);

fprintf

(outf,"\n zMHamming_Distance \n");

fprintf

(outf," %f %f \n",zM,Hamming_Distance);

/** printf("z= % d \n",z);

fprintf(outf,"z= % d \n",z);

printf("y= % d \n",y);

fprintf(outf,"y= % d \n",y);

printf("zM= % f \n",zM);

fprintf(outf,"zM= % f \n",zM);

printf("yM= % f \n",yM);

fprintf(outf,"yM= % f \n",yM);

printf("devG= % f \n",devG);

fprintf(outf,"devG= % f \n",devG);

printf("EavM= %f \n",EavM);

fprintf(outf,"EavM= %f \n",EavM);

printf("devEnergy= % f \n\n",sp);

fprintf(outf,"devEnergy= % f \n\n",sp);

printf("Hamming_Distance= %f \n",Hamming_Distance);

fprintf(outf,"Hamming_Distance= %f \n",Hamming_Distance);

printf("devHD= % f \n\n",devHD);

fprintf(outf,"devHD= % f \n\n",devHD);

printf("Hamming Distance for Global= %f \n",HDGlobal);

fprintf(outf,"Hamming Distance for Global= %f \n",HDGlobal);

printf("devHG= % f \n\n",devHG);

fprintf(outf,"devHD= % f \n\n",devHG);

printf("Hamming Distance for Local= %f \n",HDLocal);

fprintf(outf,"Hamming Distance for Local= %f \n",HDLocal);

printf("devHL= % f \n\n",devHL);

fprintf(outf,"devHL= % f \n\n",devHL);

printf("n relax= % f \n",nrelaxMM);

fprintf(outf,"n relax= % f \n",nrelaxMM);

printf("devRelax= % f \n",spR);

fprintf(outf,"devRelax= % f \n",spR); **/

time (&end);

dif = difftime (end,start);

printf ("\nIt took %.2lf seconds to run the program.\n", dif );

fprintf(outf,"\nIt took %.2lf seconds to run the program.\n", dif );

fclose(outf);

}

I am working on applying artificial intelligence to VANETS. I have already done some simulations using 4x4 and 6x6 road topologies. I am now trying to integrate real maps into the simulation, can anyone who is familiar with NetLogo simulation show me how this can be done?

How to develop the code by using NetLogo for Activation Function?

I wanted to used Netlogo but I am afraid it wouldn't scale well. I need to be able to implement mathematical formula for decision making and learning and also play with distributions. What is your experience with agent based modeling of financial markets?

I am interested in computing local moran's I in Netlogo to identify significant clustering. While I am able to export my data into another software to compute this, there is no software I am aware of to compute moran's I that will take into account the world wrapping.

I want to use a ABS tool for learning faster, at the beginning, about Agent-based modelling, but I am not sure which is better. Which is the most used by you? Also, I have been programming in python, nevertheless, I think I could improve more by doing models with those tools.

I have played a bit with netlogo over the holidays and produced a very simple model which demonstrates a difference between crowdsourcing and crowd tasking. All it does is to implement two types of agents which can report on "issues":

- Type 1 ("reporters") walks randomly and spontaneously reports "issues" in their neighbourhood.
- Type 2 ("observers") can be talked to confirm the findings.

The model nicely demonstrates the obvious: taskable volunteers are much better at confirming the findings than the random walkers.

I see plenty of possibilities for improving this model, but I am not sure what to go for first. Motivation? Different task types? More intelligent tasking mechanism? GIS? Service API?

In your opinion, what is/are the most important features which this crowdsourcing/ crowd tasking model should implement?

I have done some works with NetLogo simulation tool in artificial intelligence and I will be glad to have a discussion with anyone who is familiar with it. I want to integrate real maps into the simulation environment and will like to discuss how to go about it.