pomdp
observables
	sched, k, t, packet1, packet2, packet3, priority1, priority2, priority3 
endobservables
const int K; 
const int T; 
const double p1 = 0.8; 
const double r1 = 0.2; 
const double p2 = 0.6; 
const double r2 = 0.4; 
const double p3 = 0.7; 
const double r3 = 0.3; 
module scheduler
	k : [0..K-1]; 
	t : [0..T-1]; 
	sched : [0..1]; 
	
	
	[slot] sched=0 & t<T-1 -> (sched'=1) & (t'=t+1);
	[slot] sched=0 & t=T-1 & k<K-1 -> (sched'=1) & (t'=0) & (k'=k+1);
	
	[idle]  sched=1 -> (sched'=0);
	[send1] sched=1 -> (sched'=0);
	[send2] sched=1 -> (sched'=0);
	[send3] sched=1 -> (sched'=0);
	
	[] sched=0 & t=T-1 & k=K-1 -> true;	
endmodule
module packet1
	packet1 : [0..1]; 
	
	[slot] t=0 -> (packet1'=1); 
	[slot] t>0 -> true;
	
	[send1]	packet1=1 & chan1=1 -> (packet1'=0); 
	[send1]	packet1=1 & chan1=0 -> true; 
endmodule
module packet2=packet1[packet1=packet2,send1=send2,chan1=chan2] endmodule
module packet3=packet1[packet1=packet3,send1=send3,chan1=chan3] endmodule
module priority1
	priority1 : [0..3];
	
	
	[slot] t=0 -> 0.1 : (priority1'=1) + 0.3 : (priority1'=2) + 0.6 : (priority1'=3);
	
	[slot] t>0 -> true;
	
	
	[send1] chan1=0 -> true;
	[send1] chan1=1 -> (priority1'=0);
	
endmodule
module priority2 = priority1[priority1=priority2,chan1=chan2,send1=send2] endmodule
module priority3 = priority1[priority1=priority3,chan1=chan3,send1=send3] endmodule
module channel1
	chan1 : [0..1]; 
	
	[slot] t=0 & k=0 -> 0.5 : (chan1'=0) + 0.5 : (chan1'=1);
	
	[slot] chan1=0 & !(t=0 & k=0) -> 1 - r1 : (chan1'=0) + r1 : (chan1'=1);
	[slot] chan1=1 & !(t=0 & k=0) -> 1 - p1 : (chan1'=0) + p1 : (chan1'=1);
endmodule
module channel2=channel1[chan1=chan2,p1=p2,r1=r2] endmodule
module channel3=channel1[chan1=chan3,p1=p3,r1=r3] endmodule
rewards "dropped_packets"
	[slot] t=0 & k>0 : ((packet1=0)?0:1) + ((packet2=0)?0:1) + ((packet3=0)?0:1);
	[idle] t=T-1 & k=K-1 : ((packet1=0)?0:1) + ((packet2=0)?0:1) + ((packet3=0)?0:1);
	[send1] t=T-1 & k=K-1 & chan1=0 : ((packet1=0)?0:1) + ((packet2=0)?0:1) + ((packet3=0)?0:1);
	[send2] t=T-1 & k=K-1 & chan2=0 : ((packet1=0)?0:1) + ((packet2=0)?0:1) + ((packet3=0)?0:1);
	[send3] t=T-1 & k=K-1 & chan3=0 : ((packet1=0)?0:1) + ((packet2=0)?0:1) + ((packet3=0)?0:1);
	[send1] t=T-1 & k=K-1 & chan1=1 : ((packet2=0)?0:1) + ((packet3=0)?0:1);
	[send2] t=T-1 & k=K-1 & chan2=1 : ((packet1=0)?0:1) + ((packet3=0)?0:1);
	[send3] t=T-1 & k=K-1 & chan3=1 : ((packet1=0)?0:1) + ((packet2=0)?0:1);
endrewards
rewards "packets_sent"
	[send1] chan1=1 : 1;
	[send2] chan2=1 : 1;
	[send3] chan3=1 : 1;
endrewards
const double beta=1; 
rewards "priority"
	[send1] chan1=1 & priority1=1 : 1 * pow(beta,t + k*T);
	[send2] chan2=1 & priority2=1 : 1 * pow(beta,t + k*T);
	[send3] chan3=1 & priority3=1 : 1 * pow(beta,t + k*T);
	[send1] chan1=1 & priority1=2 : 10 * pow(beta,t + k*T);
	[send2] chan2=1 & priority2=2 : 10 * pow(beta,t + k*T);
	[send3] chan3=1 & priority3=2 : 10 * pow(beta,t + k*T);
	[send1] chan1=1 & priority1=3 : 20 * pow(beta,t + k*T);
	[send2] chan2=1 & priority2=3 : 20 * pow(beta,t + k*T);
	[send3] chan3=1 & priority3=3 : 20 * pow(beta,t + k*T);
endrewards