-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakeNOXPredictionBehavior.java
More file actions
77 lines (64 loc) · 2.15 KB
/
MakeNOXPredictionBehavior.java
File metadata and controls
77 lines (64 loc) · 2.15 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
76
77
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 MakeNOXPredictionBehavior extends TickerBehaviour{
Agent _agnt;
int nbrOfMsg=0;
double hu;
double temp;
double ws;
MakeNOXPredictionBehavior(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++;
//.add(((ParamInfo)paramsInfoMsg.getContentObject()).getValue());
} catch (Exception e) {
e.printStackTrace();
}
if(nbrOfMsg==3){
nbrOfMsg=0;
int t= SimulationFramework.getCurrentEnv().T;
double currentValOfPM10=SimulationFramework.getCurrentEnv().NOx_V.getData().get(t);
double[] input={hu,temp,ws,currentValOfPM10};
double d=MachineLearningUtls.interrogateModel(
SimulationFramework.getCurrentEnv().NOxMODEL,
input);
SimulationFramework.getCurrentEnv().T=SimulationFramework.getCurrentEnv().T+1;
SimulationFramework.getCurrentEnv().sim_NOx.addData(d);
msg="\n"+_agnt.getName()+" : <NOX Concentration is> : "+d;
msg=" ["+ msg+hu+" | "+temp+" | "+ws+"]";
// Console.logMSG(msg);
}
}
}
}
}