-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSubflow.java
More file actions
106 lines (70 loc) · 1.58 KB
/
Subflow.java
File metadata and controls
106 lines (70 loc) · 1.58 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
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
package src;
import umontreal.iro.lecuyer.randvar.NormalGen;
import umontreal.iro.lecuyer.randvar.PoissonGen;
import umontreal.iro.lecuyer.rng.MRG31k3p;
import umontreal.iro.lecuyer.rng.RandomStream;
import java.util.ArrayList;
public class Subflow {
int flowId;
int ttl;
double request_queue;
double debet_queue;
ArrayList<EV> evList;
double x; //charing power from outside at current slot;
double w;// wind power at current slot
double y; // total charing power at current slot
double q; //total unfulfilled energy request
int time;
int V;
double gamma;
public Subflow(int id, int r, int v){
flowId = id;
ttl=r;
request_queue=0;
debet_queue=0;
evList = new ArrayList<EV>();
V =v;
gamma=0.01;
x=0;
w=0;
y=0;
q=0;
}
public void schedule(double wind, double g){
w=wind;
gamma = g;
x=0;
double thr = V*gamma+w-q;
// if(q>20)
// System.out.println("q is "+q);
if(thr<=0){
for(EV e: evList){
double p = min(e.p_max,(q-w)/(double)evList.size());
e.charging(p,1,time);
x =x+ e.current_cp-w/evList.size() ;
}
}else
{
for(EV e: evList){
double p = -e.p_max;
p=0; //p
e.charging(p, 1,time);
x =x+ e.current_cp-w/evList.size() ;
}
}
y = x+wind;
double tmp = q;
for(EV e: evList)
e.updateTtl();
if(ttl>0)
ttl = ttl-1;
}
public void rqEnvolve(){
}
public double min(double x, double y){
if( x<y)
return x;
else
return y;
}
}