-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakeO3PredictionBehavior.java
More file actions
75 lines (63 loc) · 2.07 KB
/
MakeO3PredictionBehavior.java
File metadata and controls
75 lines (63 loc) · 2.07 KB
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
package com.masim.predictionAgents;
import jade.core.Agent;
import jade.core.behaviours.TickerBehaviour;
import jade.lang.acl.ACLMessage;
import com.masim.core.MachineLearningUtls;
import com.masim.core.ParamInfo;
import com.masim.ui.Console;
import com.masim.utils.SimProcessState;
import com.masim.utils.SimulationFramework;
public class MakeO3PredictionBehavior extends TickerBehaviour{
Agent _agnt;
int nbrOfMsg=0;
double hu;
double temp;
double ws;
MakeO3PredictionBehavior(Agent agnt){
super(agnt,10);
_agnt=agnt;
}
@Override
protected void onTick() {
if(SimulationFramework.getCurrentSimProcessState()== SimProcessState.Started){
ACLMessage paramsInfoMsg=_agnt.receive();
if(paramsInfoMsg!=null){
ACLMessage reply= new ACLMessage(ACLMessage.INFORM);
reply.setContent("Confirms");
reply.addReceiver(paramsInfoMsg.getSender());
_agnt.send(reply);
String msg;
try {
ParamInfo pi= ((ParamInfo) paramsInfoMsg.getContentObject());
if(pi.getName().equalsIgnoreCase("Hu"))
hu=pi.getValue();
else if(pi.getName().equalsIgnoreCase("Temp"))
temp=pi.getValue();
else ws=pi.getValue();
msg = _agnt.getName()+
": <ParamRecived> :"+
paramsInfoMsg.getSender().getName()+" :"
+pi.getValue();
Console.logMSG(msg);
nbrOfMsg++;
} catch (Exception e) {
e.printStackTrace();
}
if(nbrOfMsg==3){
nbrOfMsg=0;
int t= SimulationFramework.getCurrentEnv().T;
double currentValOfPM10=SimulationFramework.getCurrentEnv().O3.getData().get(t);
double[] input={hu,temp,ws,currentValOfPM10};
double d=MachineLearningUtls.interrogateModel(
SimulationFramework.getCurrentEnv().O3MODEL,
input);
SimulationFramework.getCurrentEnv().T=SimulationFramework.getCurrentEnv().T+1;
SimulationFramework.getCurrentEnv().sim_O3.addData(d);
msg="\n"+_agnt.getName()+" : <O3 Concentration is> : "+d;
msg=" ["+ msg+hu+" | "+temp+" | "+ws+"]";
//Console.logMSG(msg);
}
}
}
}
}