-
Notifications
You must be signed in to change notification settings - Fork 0
/
controls.h
116 lines (100 loc) · 3.39 KB
/
controls.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
#ifndef CONTROLS_H_INCLUDED
#define CONTROLS_H_INCLUDED
#include "const_parameters.h"
#include "farm_defn.h"
std::vector<int> ActiveSurveillanceFarms;
//Movement ban controls
void ImplementLocalMovementBan(int CentreFarm){
int BannedFarmID;
#ifdef VERBOSE
std::cout<<"Implementing movement ban around farm "<<CentreFarm<<std::endl;
#endif
//Here I implement ring movement bans
//If farm has never been detected before than construct its local farm list
if(!farms[CentreFarm]->EverBeenDetectedDuringRun){FindLocalFarms(CentreFarm);farms[CentreFarm]->EverBeenDetectedDuringRun = true;}
for(int n =0;n<farms[CentreFarm]->LocalFarmsID.size();n++){
BannedFarmID = farms[CentreFarm]->LocalFarmsID[n];
#ifndef NOFARMBAN
farms[BannedFarmID]->MovementBanned = true;
farms[BannedFarmID]->FreeArea = false;
#endif
}
#ifdef RESTRICTIONZONES
for(int k = 0; k<N; k++){
if( DistSqBetweenFarms(k,CentreFarm) <= PZRadius*PZRadius){
farms[k]->ProtectionZone = true;
farms[k]->FreeArea = false;
}
if( DistSqBetweenFarms(k,CentreFarm) > PZRadius*PZRadius && DistSqBetweenFarms(k,CentreFarm) <= SZRadius*SZRadius ){
farms[k]->SurveillanceZone = true;
farms[k]->FreeArea = false;
}
}
#endif
//If there is a county ban then ban movement of all farms in same county
#ifdef COUNTYBAN
double CN = farms[CentreFarm]->CountyNumber;
for(int k = 0; k<N ; k++){
if(farms[k]->CountyNumber == CN){
farms[k]->MovementBanned = true;
farms[k]->FreeArea = false;
}
}
#endif
//If there is a total ban policy
#ifdef TOTALBAN
for(int k = 0; k<N ; k++){
farms[k]->MovementBanned = true;
farms[k]->FreeArea = false;
}
#endif
}
//Set up standard extra controls : Protection zone and Surveillance zone
void SetUpRestrictionZone(int FirstDetectedFarmID, double R, double R2){
double SurvRadius = 15000;
for(int k = 0; k<N; k++){
if( DistSqBetweenFarms(k,FirstDetectedFarmID) <= R*R){
farms[k]->ProtectionZone = true;
farms[k]->FreeArea = false;
}
if( DistSqBetweenFarms(k,FirstDetectedFarmID) > R*R && DistSqBetweenFarms(k,FirstDetectedFarmID) <= R2*R2 ){
farms[k]->SurveillanceZone = true;
farms[k]->FreeArea = false;
}
//Add farms for local active surveillance
if( DistSqBetweenFarms(k,FirstDetectedFarmID) <= SurvRadius*SurvRadius){
ActiveSurveillanceFarms.push_back(k);
}
}
RestrictionZonesImplemented = true;
}
//Function for perform active surveillance
void PerformActiveSurveillance(){
int FarmID;
NumberOfFarmsChecked += ActiveSurveillanceFarms.size();
for(int k = 0; k< ActiveSurveillanceFarms.size(); k++){
FarmID = ActiveSurveillanceFarms[k];
NumberOfTests += int(farms[FarmID]->NumOfCattle() + farms[FarmID]->NumOfSheep());
if((farms[FarmID]->NumOfInfCattle() + farms[FarmID]->NumOfInfSheep()) > 0){
farms[FarmID]->Detected = true;
NumberOfPosTests += int(farms[FarmID]->NumOfInfCattle() + farms[FarmID]->NumOfInfSheep() + farms[FarmID]->R_sheep + farms[FarmID]->R_cattle);
}
}
ActiveSurveillanceFarms.clear();
ActiveSurveillancePerformed = true;
}
//Cancel restrictions on movements
void CancelRestrictions(){
BTVObserved = false;
ActiveSurveillancePerformed = false;
RestrictionZonesImplemented = false;
for(int k = 0; k<N; k++){
farms[k]->MovementBanned = false;
farms[k]->ProtectionZone = false;
farms[k]->SurveillanceZone = false;
farms[k]->Detected = false;
farms[k]->MovementBanned = false;
farms[k]->FreeArea = true;
}
}
#endif