Skip to content

Commit

Permalink
Merge pull request #12 from SoenBeier/Test
Browse files Browse the repository at this point in the history
Korrekturen
  • Loading branch information
SoenBeier authored Apr 4, 2019
2 parents f47f45a + c6ac39c commit 1a7577a
Show file tree
Hide file tree
Showing 3 changed files with 122 additions and 50 deletions.
18 changes: 10 additions & 8 deletions initial_situation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,22 +28,24 @@ Die restlichen Optionen können nach Belieben eingestellt werden und werden zu k
*/


const static int grid_height = 120;
const static int grid_width = 120;
const static int grid_height = 50;
const static int grid_width = 50;


static int max_number_of_iterations = 10000;
static bool iteration_break_condition = true; ///kann das Program auch vorher schon abbrechen(wenn alle Personen im Ziel sind)?

static const char plant_layout[] = "einzel_haus.bmp";//Name des Gebäudeplans
static const char plant_layout[] = "29x29_Haus.bmp";//Name des Gebäudeplans

static const char movement_update = 'p'; //'s' - sequential, 'p' - parallel
//BEIM PARALLELEN NOCHMAL NACHSCHAUEN: C[][] WIRD WIRKLICH RICHTIG GEWÄHLT ?? was hat es mit den einsen in der Matrix zu tun?

static int grafic_delay = 100;// Je höher, desto langsamer aktuallisiert sich die grafische Anzeige
static int grafic_delay = 150;// Je höher, desto langsamer aktuallisiert sich die grafische Anzeige

static int decay_param = 15; //Zerfallsparameter fürs dynamische Feld [0,100]
static int diffusion_param = 15; //Verteilungsparameter fürs dynamische Feld [0,100] ERZEUGT FEHLER BEIM AUSFÜHREN!
static int decay_param = 0; //Zerfallsparameter fürs dynamische Feld [0,100]
static int diffusion_param = 0; //Verteilungsparameter fürs dynamische Feld [0,100] ERZEUGT FEHLER BEIM AUSFÜHREN!

static int panik_schwelle=10; ///ab welcher anzhal von konflikten geraet jmd in panik

/*
Veränderungen am Ablauf des Programms, wenn "reject_other_D_fields" aktiviert ist:
Expand Down Expand Up @@ -86,10 +88,10 @@ friction: Gibt die Wahrscheinlichkeit an, dass sich eine Person in einem Iterati
bool foreign_call = false; //experimentell; Werte werden mit der Konsole hinzugefügt, dies kann für die Analyse benutzt werden
// wird hier ein negativer eintrag gewählt, so wird dieser Parameter nicht gesetzt

double k_S = 15; //Einfluss von s auf die Bewegung der Personen
double k_S = 2; //Einfluss von s auf die Bewegung der Personen
double k_D = 0; //Einfluss von D auf die Bewegung der Personen
double w_S = -1; ///Wissen der Personen über die Ausgänge (zufaellig im default)
double friction = -1; ///zufaellig im default
double friction = 0; ///zufaellig im default

};

Expand Down
134 changes: 99 additions & 35 deletions klassen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,8 @@ int quantity_persons;


// ###### Dynamic floor field DZur Uni Potsdam(Brandenburg):
double k_D = 1;
double k_D = 1;
int panic_par;
int D[grid_width][grid_height];

void set_D_on_zero()
Expand Down Expand Up @@ -553,22 +554,22 @@ int quantity_persons;
for (int y=0; y<grid_height; y++)
{
int d_abs_beginn = abs(persvec[i].D[x][y]);
for (int j=0; j<d_abs_beginn; j++) ///je staerker das d feld am puntk x y ost, desto stärker kann es zerfallen
for (int j=0; j<d_abs_beginn; j++) ///je staerker das d feld am puntk x y ist, desto stärker kann es zerfallen
{
//zerfall des d Feldes:
//-----------------------------
//schreibe wahrscheinlichkeitsarray
for (int k=0; k < propability_arr_dec.size(); k++)
{
propability_arr_dec[k]=0;
}
if (decay_param!=0)
{
for (int k=0; k<decay_param ; k++)
{
propability_arr_dec[k]=1;
propability_arr_dec[k]=0;
}
if (decay_param!=0)
{
for (int k=0; k<decay_param ; k++)
{
propability_arr_dec[k]=1;
}
}
}
/*if (i==1)
{
cout << "Person " << i << " hat die Koordinaten: (x;y) = " << "(" << persvec[i].x << ";" << persvec[i].y << ")" << endl;
Expand All @@ -579,9 +580,9 @@ int quantity_persons;


//generiere zufällige zahl und überprüfe ob d feld zerfallen soll
int r_2=rand()%100;
if (propability_arr_dec[r_2]==1) //verifikation: D feld soll sich auflösen
{
int r_2=rand()%100;
if (propability_arr_dec[r_2]==1) //verifikation: D feld soll sich auflösen
{
//if (/*falls 1 Nachbar frei ist*/ persvec[i].D[x][y+1]==0 || persvec[i].D[x][y-1]==0 || persvec[i].D[x+1][y]==0 || persvec[i].D[x-1][y]==0 || /*falls 2 Nachbarn frei sind*/ persvec[i].D[x+1][y]==persvec[i].D[x][y+1]==0 || persvec[i].D[x-1][y]==persvec[i].D[x][y+1]==0 || persvec[i].D[x-1][y]==persvec[i].D[x][y-1]==0 || persvec[i].D[x+1][y]==persvec[i].D[x][y-1]==0 || /*falls 3 Nachbarn frei sind*/ persvec[i].D[x-1][y]==persvec[i].D[x][y+1]==persvec[i].D[x+1][y]==0 || persvec[i].D[x][y-1]==persvec[i].D[x-1][y]==persvec[i].D[x][y+1]==0 || persvec[i].D[x-1][y]==persvec[i].D[x][y-1]==persvec[i].D[x+1][y]==0 || persvec[i].D[x][y-1]==persvec[i].D[x+1][y]==persvec[i].D[x][y+1]==0)
//{
/*if (i==1)
Expand Down Expand Up @@ -634,7 +635,7 @@ int quantity_persons;
{
for (int y=0; y<grid_height; y++)
{
for (int k=0; k<persvec[i].D[x][y]; k++) ///je stärker das d feld desto schneller kann es sich verteilen
for (int k=0; k<abs(persvec[i].D[x][y]); k++) ///je stärker das d feld desto schneller kann es sich verteilen
{
//Verteilung des D-Felds
//------------
Expand Down Expand Up @@ -663,7 +664,7 @@ int quantity_persons;
{
if (can_d_field_be_here(x-1, y, obstvec)==true)
{
if (persvec[i].D[x][y]>=0)
if (persvec[i].D[x][y]>0)
{
persvec[i].D[x-1][y]++;
persvec[i].D[x][y]--; ///d feld verwischt
Expand All @@ -680,7 +681,7 @@ int quantity_persons;
{
if (can_d_field_be_here(x+1, y, obstvec)==true)
{
if (persvec[i].D[x][y]>=0)
if (persvec[i].D[x][y]>0)
{
persvec[i].D[x+1][y]++;
persvec[i].D[x][y]--; ///d feld verwischt
Expand All @@ -697,7 +698,7 @@ int quantity_persons;
{
if (can_d_field_be_here(x, y-1, obstvec)==true)
{
if (persvec[i].D[x][y]>=0)
if (persvec[i].D[x][y]>0)
{
persvec[i].D[x][y-1]++;
persvec[i].D[x][y]--; ///d feld verwischt
Expand All @@ -714,7 +715,7 @@ int quantity_persons;
{
if (can_d_field_be_here(x, y+1, obstvec)==true)
{
if (persvec[i].D[x][y]>=0)
if (persvec[i].D[x][y]>0)
{
persvec[i].D[x][y+1]++;
persvec[i].D[x][y]--; ///d feld verwischt
Expand All @@ -734,7 +735,7 @@ int quantity_persons;
{
if (can_d_field_be_here(x+1, y, obstvec)==true)
{
if (persvec[i].D[x][y]>=0)
if (persvec[i].D[x][y]>0)
{
persvec[i].D[x+1][y]++;
persvec[i].D[x][y]--; ///d feld verwischt
Expand All @@ -751,7 +752,7 @@ int quantity_persons;
{
if (can_d_field_be_here(x, y-1, obstvec)==true)
{
if (persvec[i].D[x][y]>=0)
if (persvec[i].D[x][y]>0)
{
persvec[i].D[x][y-1]++;
persvec[i].D[x][y]--; ///d feld verwischt
Expand All @@ -768,7 +769,7 @@ int quantity_persons;
{
if (can_d_field_be_here(x, y+1, obstvec)==true)
{
if (persvec[i].D[x][y]>=0)
if (persvec[i].D[x][y]>0)
{
persvec[i].D[x][y+1]++;
persvec[i].D[x][y]--; ///d feld verwischt
Expand All @@ -785,7 +786,7 @@ int quantity_persons;
{
if (can_d_field_be_here(x-1, y, obstvec)==true)
{
if (persvec[i].D[x][y]>=0)
if (persvec[i].D[x][y]>0)
{
persvec[i].D[x-1][y]++;
persvec[i].D[x][y]--; ///d feld verwischt
Expand All @@ -805,7 +806,7 @@ int quantity_persons;
{
if (can_d_field_be_here(x, y-1, obstvec)==true)
{
if (persvec[i].D[x][y]>=0)
if (persvec[i].D[x][y]>0)
{
persvec[i].D[x][y-1]++;
persvec[i].D[x][y]--; ///d feld verwischt
Expand All @@ -822,7 +823,7 @@ int quantity_persons;
{
if (can_d_field_be_here(x, y+1, obstvec)==true)
{
if (persvec[i].D[x][y]>=0)
if (persvec[i].D[x][y]>0)
{
persvec[i].D[x][y+1]++;
persvec[i].D[x][y]--; ///d feld verwischt
Expand All @@ -839,7 +840,7 @@ int quantity_persons;
{
if (can_d_field_be_here(x-1, y, obstvec)==true)
{
if (persvec[i].D[x][y]>=0)
if (persvec[i].D[x][y]>0)
{
persvec[i].D[x-1][y]++;
persvec[i].D[x][y]--; ///d feld verwischt
Expand All @@ -856,7 +857,7 @@ int quantity_persons;
{
if (can_d_field_be_here(x+1, y, obstvec)==true)
{
if (persvec[i].D[x][y]>=0)
if (persvec[i].D[x][y]>0)
{
persvec[i].D[x+1][y]++;
persvec[i].D[x][y]--; ///d feld verwischt
Expand All @@ -876,7 +877,7 @@ int quantity_persons;
{
if (can_d_field_be_here(x, y+1, obstvec)==true)
{
if (persvec[i].D[x][y]>=0)
if (persvec[i].D[x][y]>0)
{
persvec[i].D[x][y+1]++;
persvec[i].D[x][y]--; ///d feld verwischt
Expand All @@ -893,7 +894,7 @@ int quantity_persons;
{
if (can_d_field_be_here(x-1, y, obstvec)==true)
{
if (persvec[i].D[x][y]>=0)
if (persvec[i].D[x][y]>0)
{
persvec[i].D[x-1][y]++;
persvec[i].D[x][y]--; ///d feld verwischt
Expand All @@ -910,7 +911,7 @@ int quantity_persons;
{
if (can_d_field_be_here(x+1, y, obstvec)==true)
{
if (persvec[i].D[x][y]>=0)
if (persvec[i].D[x][y]>0)
{
persvec[i].D[x+1][y]++;
persvec[i].D[x][y]--; ///d feld verwischt
Expand All @@ -927,7 +928,7 @@ int quantity_persons;
{
if (can_d_field_be_here(x, y-1, obstvec)==true)
{
if (persvec[i].D[x][y]>=0)
if (persvec[i].D[x][y]>0)
{
persvec[i].D[x][y-1]++;
persvec[i].D[x][y]--; ///d feld verwischt
Expand Down Expand Up @@ -976,14 +977,77 @@ int quantity_persons;
}
return true;
}


int iterat_val;

void set_panic_par(vector <person> &persvec, int i, int iteration)
{
if (iteration==0)
{
persvec[i].iterat_val=0;
}

///rising panic parameter
if (persvec[i].had_a_conflict==true)
{
persvec[i].panic_par++;
persvec[i].iterat_val=persvec[i].iteration;
r=0;
g=255;
b=0;
}

///zerfall vom panikparameter
if (persvec[i].iterat_val+1==persvec[i].iteration && persvec[i].had_a_conflict==false && persvec[i].evacuated==false)
{
persvec[i].panic_par--;
r=0;
g=0;
b=255;
}

///panikschwelle -> diffusion
if (persvec[i].panic_par>=panik_schwelle)
{
for (int k=0; k<persvec.size(); k++)
{
if (persvec[k].x==persvec[i].x-1 && persvec[k].y==persvec[i].y)
{
persvec[k].panic_par++;
}
if (persvec[k].x==persvec[i].x+1 && persvec[k].y==persvec[i].y)
{
persvec[k].panic_par++;
}
if (persvec[k].x==persvec[i].x && persvec[k].y==persvec[i].y-1)
{
persvec[k].panic_par++;
}
if (persvec[k].x==persvec[i].x-1 && persvec[k].y==persvec[i].y+1)
{
persvec[k].panic_par++;
}
r=255;
g=0;
b=0;
}
}
}

void print_D()
{
for (int i = 0; i < grid_height; i++){
for(int j = 0; j < grid_width; j++){
cout << D[i][j] << ":";
{
cout << "----------------------------------------------------------------" << endl;
for(int j = 0; j < grid_height; j++){
for(int i = 0; i < grid_width; i++){
if (D[i][j] > 9999){cout << "" << (int)D[i][j] << ";" ;}
else if (D[i][j] > 999){cout << " " << (int)D[i][j] << ";" ;}
else if (D[i][j] > 99){cout << " " << (int)D[i][j] << ";" ;}
else if (D[i][j] > 9){cout << " " << (int)D[i][j] << ";" ;}
else {cout << " " << D[i][j] << ";" ;}

}
cout << endl;
cout << endl;
}
}

Expand Down
20 changes: 13 additions & 7 deletions main_s.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -252,9 +252,14 @@ void move_people_parallel(vector<person> &persvec, vector<obstacle> &obstvec, ve
persvec[i].desired_x = persvec[i].x;
persvec[i].desired_y = persvec[i].y;
persvec[i].wins_conflict = true; //Möchte die Person stehen bleiben, so gewinnt diese Person immer den Konflikt
persvec[i].desired_direction = 's';
persvec[i].desired_direction = 's';
//Wenn die Person keine Bewegungsmöglichkeit mehr hat wird das als Konflikt gezählt
if((persvec[i].get_T(1,0) + persvec[i].get_T(2,1) + persvec[i].get_T(1,2) + persvec[i].get_T(0,1)) == 0){
persvec[i].had_a_conflict = true;
}
}
}
}


///Entscheidung welche Person sich bewegen darf und welche beispielsweise bei einem Konflikt stehen bleiben muss:
for(int i = 0; i <persvec.size(); i++){
Expand Down Expand Up @@ -282,7 +287,7 @@ void move_people_parallel(vector<person> &persvec, vector<obstacle> &obstvec, ve
if(persvec[conflict_partner[j]].wins_conflict == true){
conflict_done = true;
}

persvec[conflict_partner[j]].had_a_conflict=true;
}
}

Expand Down Expand Up @@ -378,7 +383,8 @@ void update_object_parameters(int iteration, vector<person> &persvec, vector<des
if(corridor_conditions == false){ persvec[j].renew_w_S_and_S(destvec); }
persvec[j].last_movement_direction = persvec[j].set_last_movement_direction(persvec[j].ax, persvec[j].ay, persvec[j].x, persvec[j].y);
persvec[j].a_last_movement_direction = persvec[j].set_last_movement_direction(persvec[j].aax, persvec[j].aay, persvec[j].ax, persvec[j].ay);
persvec[j].set_D_3(persvec, j);
persvec[j].set_D_3(persvec, j);
persvec[j].set_panic_par(persvec, j, iteration);
persvec[j].diffusion_dyn_f(propability_arr_diff, persvec, persvec[j].x, persvec[j].y,j, obstvec, propability_arr_dec);
persvec[j].decay_dyn_f(propability_arr_dec, persvec, j);
}
Expand Down Expand Up @@ -679,6 +685,7 @@ int main(int argc, char* args[]){
int quantity_obstacles = initcoord_obst_vec.size();

//Ausgabe der Koordinaten der noch zu erstellenden Personen, Hindernissen, Zielen
cout << "------------------------------" << endl;
cout << "dest " ;
print_init_vector(initcoord_dest_vec);
cout << "Anzahl Ziele: " << initcoord_dest_vec.size()<< endl;
Expand Down Expand Up @@ -795,9 +802,8 @@ for(int i = 0; i < 4;i++){

for(int i = 0; i < max_number_of_iterations; i++){
//################## iteration method
//persvec[20].print_coords();
//persvec[20].print_T();
//persvec[20].print_S();
//persvec[0].print_D();

has_pers_reached_destination(destvec,persvec);

if(movement_update == 's'){
Expand Down

0 comments on commit 1a7577a

Please sign in to comment.