Skip to content

Commit cd206c2

Browse files
committed
updated Electric Car
1 parent 9bc49b6 commit cd206c2

File tree

1 file changed

+21
-17
lines changed

1 file changed

+21
-17
lines changed

js/domains/ElectricCar.js

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ var domain = {
3333
{
3434
"name": "Sample Count",
3535
"description": "Specify how many trajectories to generate",
36-
"current_value": 10,
37-
"max": 1000,
36+
"current_value": 40,
37+
"max": 200,
3838
"min": 1,
3939
"step": 10,
4040
"units": "#"
@@ -43,7 +43,7 @@ var domain = {
4343
"name": "Seed",
4444
"description": "The random seed used for simulations",
4545
"current_value": 0,
46-
"max": 100000,
46+
"max": 100,
4747
"min": 1,
4848
"step": 1,
4949
"units": "NA"
@@ -110,8 +110,8 @@ var domain = {
110110
{
111111
"name": "Database Trajectory Count",
112112
"description": "Specify how many trajectories to sample into the database",
113-
"current_value": 10,
114-
"max": 1000,
113+
"current_value": 40,
114+
"max": 200,
115115
"min": 1,
116116
"step": 10,
117117
"units": "NA"
@@ -127,7 +127,7 @@ var domain = {
127127
},
128128
{
129129
"name": "Database Policy",
130-
"description": "Probabilities for charging: (0) distance_remaining/starting_distance, (1) opposite of policy 1, (2) if charge < .5, (3) opposite of policy 2, (4) if traffic > .5, (5) opposite of policy 4.",
130+
"description": "Probabilities for charging: (0) distance_remaining/starting_distance, (1) opposite of policy 1, (2) if charge < .5, (3) opposite of policy 2, (4) if exogenous1 > .5, (5) opposite of policy 4.",
131131
"current_value": 0,
132132
"max": 5,
133133
"min": 0,
@@ -152,7 +152,7 @@ var domain = {
152152
"quantitative": [
153153
{
154154
"name": "Evaluation Policy",
155-
"description": "Probabilities for charging: (0) distance_remaining/starting_distance, (1) opposite of policy 1, (2) if charge < .5, (3) opposite of policy 2, (4) if traffic > .5, (5) opposite of policy 4.",
155+
"description": "Probabilities for charging: (0) distance_remaining/starting_distance, (1) opposite of policy 1, (2) if charge < .5, (3) opposite of policy 2, (4) if exogenous 1 > .5, (5) opposite of policy 4.",
156156
"current_value": 0,
157157
"max": 5,
158158
"min": 0,
@@ -174,7 +174,6 @@ var domain = {
174174
return {
175175
"reward": 0,
176176
"charge level": prng(),
177-
"distance to next charger": domain.parameters.distanceBetweenChargers,
178177
"total distance remaining": domain.parameters.distanceAcrossContent,
179178
"Stitched Distance": 0
180179
};
@@ -237,15 +236,21 @@ var domain = {
237236
}
238237
}
239238
} else if( policyIdentifier === 4 ) {
240-
// todo, implement this
241239
policyFunction = function(state) {
242-
goToFail();
240+
if( state["exogenous 1"] > .5 ) {
241+
return 1;
242+
} else {
243+
return 0;
244+
}
243245
}
244246
} else if( policyIdentifier === 5 ) {
245-
// todo, implement this
246-
policyFunction = function(state) {
247-
goToFail();
247+
if( state["exogenous 1"] > .5 ) {
248+
return 0;
249+
} else {
250+
return 1;
248251
}
252+
} else {
253+
alert("you selected an invalid policy");
249254
}
250255
return policyFunction;
251256
},
@@ -309,16 +314,15 @@ var domain = {
309314
chargeAtStart = 1;
310315
chargingCost = domain.parameters.chargingFixedCost;
311316
}
312-
var chargeDepletion = (rn * currentState["distance to next charger"])/domain.parameters.distanceBetweenChargers;
317+
var chargeDepletion = rn;
313318
if( chargeDepletion > chargeAtStart ) {
314319
resultState["reward"] = domain.parameters.depletionPenalty + chargingCost;
315320
resultState["charge level"] = 0;
316321
} else {
317-
resultState["reward"] = currentState["distance to next charger"] + chargingCost;
322+
resultState["reward"] = chargingCost;
318323
resultState["charge level"] = chargeAtStart - chargeDepletion;
319324
}
320-
resultState["distance to next charger"] = domain.parameters.distanceBetweenChargers;
321-
resultState["total distance remaining"] = currentState["total distance remaining"] - currentState["distance to next charger"];
325+
resultState["total distance remaining"] = currentState["total distance remaining"] - domain.parameters.distanceBetweenChargers;
322326
resultState["Stitched Distance"] = 0;
323327
domain._addExogenousState(prng, exogenousCount, resultState);
324328
return resultState;

0 commit comments

Comments
 (0)