CS计算机代考程序代写 ////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////
// TRAFFIC MODEL (WITH MERGE, DIVERGE AND CONTROL SIGNAL)
//
// @author Tan Nguyen (tan1889@gmail.com)
// @version 6-May-11
//
// Define miscellaneous traffic model instances:
// – is_simple
// – is_roundabout
// – is_intersection
// – is_grid
////////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////////
// SIMPLE ONE WAY ROADS, ONE MERGE, ONE DIVERGE
////////////////////////////////////////////////////////////////////

non-fluents simple {

domain = traffic;

// r_5_0 = row 5 col 0 direction RIGHT
objects {
cell : {
r_0_3, r_1_3, r_2_3, r_3_3, r_4_3, r_5_3, r_6_3, //line 1
r_0_5, r_1_5, r_2_5, r_3_5, r_4_5, r_5_5, r_6_5, //line 2
//line 1+2 merged
r_7_4, r_8_4, r_9_4, r_10_4,
//diverge to line 3, 4
d_11_5, d_11_6, d_11_7, d_11_8, d_11_9, //line 3
r_11_3, r_12_3, u_13_3, u_13_2, u_13_1 //line 4
};
intersection : {
none
};
};

non-fluents {
FIRST(r_0_3);
NEXT(r_0_3,r_1_3);
NEXT(r_1_3,r_2_3);
NEXT(r_2_3,r_3_3);
NEXT(r_3_3,r_4_3);
NEXT(r_4_3,r_5_3);
NEXT(r_5_3,r_6_3);
NEXT(r_6_3,r_7_4);

FIRST(r_0_5);
NEXT(r_0_5,r_1_5);
NEXT(r_1_5,r_2_5);
NEXT(r_2_5,r_3_5);
NEXT(r_3_5,r_4_5);
NEXT(r_4_5,r_5_5);
NEXT(r_5_5,r_6_5);
NEXT(r_6_5,r_7_4);

MERGE-CELL(r_7_4);
p(r_6_3, r_7_4) = 1.0;
p(r_6_5, r_7_4) = 0.0;

NEXT(r_7_4,r_8_4);
NEXT(r_8_4,r_9_4);
NEXT(r_9_4,r_10_4);

DIVERGE-CELL(r_10_4);
p(r_10_4, r_11_3) = 0.5;
p(r_10_4, d_11_5) = 0.5;

NEXT(r_10_4,d_11_5);
NEXT(d_11_5,d_11_6);
NEXT(d_11_6,d_11_7);
NEXT(d_11_7,d_11_8);
NEXT(d_11_8,d_11_9);
LAST(d_11_9);

NEXT(r_10_4,r_11_3);
NEXT(r_11_3,r_12_3);
NEXT(r_12_3,u_13_3);
NEXT(u_13_3,u_13_2);
NEXT(u_13_2,u_13_1);
LAST(u_13_1);

k(r_0_3) = 999.0;
k(r_1_3) = 0.2;
k(r_0_5) = 999.0;
k(r_1_5) = 0.2;
k(d_11_9) = 999.0;
k(u_13_1) = 999.0;
k(r_7_4) = 0.3;
k(r_8_4) = 0.8;
k(r_9_4) = 0.8;
k(r_10_4) = 0.8;

};
}

instance is_simple {

domain = traffic;
non-fluents = simple;
init-state {
n(r_0_3) = 10000.0;
n(r_0_5) = 10000.0;
};

max-nondef-actions = 1;
horizon = 100;
discount = 1.0;
}

///////////////////////////////////////////////////////////////////
// TWO WAYS, ROUNDABOUT
////////////////////////////////////////////////////////////////////

non-fluents roundabout {
domain = traffic;
objects {
cell : {
R_0_9, L_0_10, R_1_9, L_1_10, R_2_9, L_2_10, R_3_9, L_3_10, R_4_9,
L_4_10, R_5_9, L_5_10, R_6_9, L_6_10, U_7_8, U_7_9, U_7_10, U_7_11,
R_8_7, L_8_12, U_9_0, U_9_1, U_9_2, U_9_3, U_9_4, U_9_5, U_9_6,
R_9_7, L_9_12, U_9_13, U_9_14, U_9_15, U_9_16, U_9_17, U_9_18,
U_9_19, D_10_0, D_10_1, D_10_2, D_10_3, D_10_4, D_10_5, D_10_6,
R_10_7, L_10_12, D_10_13, D_10_14, D_10_15, D_10_16, D_10_17,
D_10_18, D_10_19, R_11_7, L_11_12, D_12_8, D_12_9, D_12_10, D_12_11,
R_13_9, L_13_10, R_14_9, L_14_10, R_15_9, L_15_10, R_16_9, L_16_10,
R_17_9, L_17_10, R_18_9, L_18_10, R_19_9, L_19_10
};
intersection : {
none
};
};

non-fluents {
FIRST(R_0_9);
k(R_0_9) = 10000.0;
NEXT(R_0_9, R_1_9);
k(R_1_9) = 0.15;
LAST(L_0_10);
k(L_0_10) = 9999.0;
NEXT(R_1_9, R_2_9);
NEXT(L_1_10, L_0_10);
NEXT(R_2_9, R_3_9);
NEXT(L_2_10, L_1_10);
NEXT(R_3_9, R_4_9);
NEXT(L_3_10, L_2_10);
NEXT(R_4_9, R_5_9);
NEXT(L_4_10, L_3_10);
NEXT(R_5_9, R_6_9);
NEXT(L_5_10, L_4_10);
NEXT(R_6_9, U_7_8);
p(R_6_9, U_7_8) = 0.3;
NEXT(L_6_10, L_5_10);
MERGE-CELL(U_7_8);
NEXT(U_7_8, R_8_7);
NEXT(U_7_9, U_7_8);
p(U_7_9, U_7_8) = 0.7;
NEXT(U_7_10, U_7_9);
DIVERGE-CELL(U_7_11);
NEXT(U_7_11, L_6_10);
p(U_7_11, L_6_10) = 0.7;
NEXT(U_7_11, U_7_10);
p(U_7_11, U_7_10) = 0.3;
DIVERGE-CELL(R_8_7);
NEXT(R_8_7, U_9_6);
p(R_8_7, U_9_6) = 0.7;
NEXT(R_8_7, R_9_7);
p(R_8_7, R_9_7) = 0.3;
MERGE-CELL(L_8_12);
NEXT(L_8_12, U_7_11);
LAST(U_9_0);
k(U_9_0) = 9999.0;
NEXT(U_9_1, U_9_0);
NEXT(U_9_2, U_9_1);
NEXT(U_9_3, U_9_2);
NEXT(U_9_4, U_9_3);
NEXT(U_9_5, U_9_4);
NEXT(U_9_6, U_9_5);
NEXT(R_9_7, R_10_7);
NEXT(L_9_12, L_8_12);
p(L_9_12, L_8_12) = 0.7;
NEXT(U_9_13, L_8_12);
p(U_9_13, L_8_12) = 0.3;
NEXT(U_9_14, U_9_13);
NEXT(U_9_15, U_9_14);
NEXT(U_9_16, U_9_15);
NEXT(U_9_17, U_9_16);
NEXT(U_9_18, U_9_17);
FIRST(U_9_19);
k(U_9_19) = 10000.0;
NEXT(U_9_19, U_9_18);
k(U_9_18) = 0.15;
FIRST(D_10_0);
k(D_10_0) = 10000.0;
NEXT(D_10_0, D_10_1);
k(D_10_1) = 0.15;
NEXT(D_10_1, D_10_2);
NEXT(D_10_2, D_10_3);
NEXT(D_10_3, D_10_4);
NEXT(D_10_4, D_10_5);
NEXT(D_10_5, D_10_6);
NEXT(D_10_6, R_11_7);
p(D_10_6, R_11_7) = 0.3;
NEXT(R_10_7, R_11_7);
p(R_10_7, R_11_7) = 0.7;
NEXT(L_10_12, L_9_12);
NEXT(D_10_13, D_10_14);
NEXT(D_10_14, D_10_15);
NEXT(D_10_15, D_10_16);
NEXT(D_10_16, D_10_17);
NEXT(D_10_17, D_10_18);
NEXT(D_10_18, D_10_19);
LAST(D_10_19);
k(D_10_19) = 9999.0;
MERGE-CELL(R_11_7);
NEXT(R_11_7, D_12_8);
DIVERGE-CELL(L_11_12);
NEXT(L_11_12, L_10_12);
p(L_11_12, L_10_12) = 0.3;
NEXT(L_11_12, D_10_13);
p(L_11_12, D_10_13) = 0.7;
DIVERGE-CELL(D_12_8);
NEXT(D_12_8, D_12_9);
p(D_12_8, D_12_9) = 0.3;
NEXT(D_12_8, R_13_9);
p(D_12_8, R_13_9) = 0.7;
NEXT(D_12_9, D_12_10);
NEXT(D_12_10, D_12_11);
p(D_12_10, D_12_11) = 0.7;
MERGE-CELL(D_12_11);
NEXT(D_12_11, L_11_12);
NEXT(R_13_9, R_14_9);
NEXT(L_13_10, D_12_11);
p(L_13_10, D_12_11) = 0.3;
NEXT(R_14_9, R_15_9);
NEXT(L_14_10, L_13_10);
NEXT(R_15_9, R_16_9);
NEXT(L_15_10, L_14_10);
NEXT(R_16_9, R_17_9);
NEXT(L_16_10, L_15_10);
NEXT(R_17_9, R_18_9);
NEXT(L_17_10, L_16_10);
NEXT(R_18_9, R_19_9);
NEXT(L_18_10, L_17_10);
LAST(R_19_9);
k(R_19_9) = 9999.0;
FIRST(L_19_10);
k(L_19_10) = 10000.0;
NEXT(L_19_10, L_18_10);
k(L_18_10) = 0.15;
};
}

instance is_roundabout {

domain = traffic;
non-fluents = roundabout;
init-state {
n(R_0_9) = 10000.0;
n(D_10_0) = 10000.0;
n(L_19_10) = 10000.0;
n(U_9_19) = 10000.0;
};

max-nondef-actions = 1;
horizon = 500;
discount = 1.0;
}

///////////////////////////////////////////////////////////////////
// TWO WAYS, INTERSECTION
////////////////////////////////////////////////////////////////////

non-fluents intersection {
domain = traffic;
objects {
cell : {
R_0_7, L_0_8, R_1_7, L_1_8, R_2_7, L_2_8, R_3_7, L_3_8, R_4_7,
L_4_8, R_5_7, L_5_8, R_6_7, L_6_8, U_7_0, U_7_1, U_7_2, U_7_3,
U_7_4, U_7_5, U_7_6, U_7_9, U_7_10, U_7_11, U_7_12, U_7_13, U_7_14,
U_7_15, D_8_0, D_8_1, D_8_2, D_8_3, D_8_4, D_8_5, D_8_6, D_8_9,
D_8_10, D_8_11, D_8_12, D_8_13, D_8_14, D_8_15, R_9_7, L_9_8,
R_10_7, L_10_8, R_11_7, L_11_8, R_12_7, L_12_8, R_13_7, L_13_8,
R_14_7, L_14_8, R_15_7, L_15_8
};
intersection : {
none
};
};

non-fluents {
FIRST(R_0_7);
k(R_0_7) = 10000.0;
NEXT(R_0_7, R_1_7);
k(R_1_7) = 0.15;
LAST(L_0_8);
k(L_0_8) = 9999.0;
NEXT(R_1_7, R_2_7);
NEXT(L_1_8, L_0_8);
NEXT(R_2_7, R_3_7);
NEXT(L_2_8, L_1_8);
NEXT(R_3_7, R_4_7);
NEXT(L_3_8, L_2_8);
NEXT(R_4_7, R_5_7);
NEXT(L_4_8, L_3_8);
NEXT(R_5_7, R_6_7);
NEXT(L_5_8, L_4_8);
DIVERGE-CELL(R_6_7);
NEXT(R_6_7, U_7_6);
p(R_6_7, U_7_6) = 0.3;
NEXT(R_6_7, R_9_7);
p(R_6_7, R_9_7) = 0.7;
MERGE-CELL(L_6_8);
NEXT(L_6_8, L_5_8);
LAST(U_7_0);
k(U_7_0) = 9999.0;
NEXT(U_7_1, U_7_0);
NEXT(U_7_2, U_7_1);
NEXT(U_7_3, U_7_2);
NEXT(U_7_4, U_7_3);
NEXT(U_7_5, U_7_4);
MERGE-CELL(U_7_6);
NEXT(U_7_6, U_7_5);
DIVERGE-CELL(U_7_9);
NEXT(U_7_9, L_6_8);
p(U_7_9, L_6_8) = 0.3;
NEXT(U_7_9, U_7_6);
p(U_7_9, U_7_6) = 0.7;
NEXT(U_7_10, U_7_9);
NEXT(U_7_11, U_7_10);
NEXT(U_7_12, U_7_11);
NEXT(U_7_13, U_7_12);
NEXT(U_7_14, U_7_13);
FIRST(U_7_15);
k(U_7_15) = 10000.0;
NEXT(U_7_15, U_7_14);
k(U_7_14) = 0.15;
FIRST(D_8_0);
k(D_8_0) = 10000.0;
NEXT(D_8_0, D_8_1);
k(D_8_1) = 0.15;
NEXT(D_8_1, D_8_2);
NEXT(D_8_2, D_8_3);
NEXT(D_8_3, D_8_4);
NEXT(D_8_4, D_8_5);
NEXT(D_8_5, D_8_6);
DIVERGE-CELL(D_8_6);
NEXT(D_8_6, D_8_9);
p(D_8_6, D_8_9) = 0.7;
NEXT(D_8_6, R_9_7);
p(D_8_6, R_9_7) = 0.3;
MERGE-CELL(D_8_9);
NEXT(D_8_9, D_8_10);
NEXT(D_8_10, D_8_11);
NEXT(D_8_11, D_8_12);
NEXT(D_8_12, D_8_13);
NEXT(D_8_13, D_8_14);
NEXT(D_8_14, D_8_15);
LAST(D_8_15);
k(D_8_15) = 9999.0;
MERGE-CELL(R_9_7);
NEXT(R_9_7, R_10_7);
DIVERGE-CELL(L_9_8);
NEXT(L_9_8, L_6_8);
p(L_9_8, L_6_8) = 0.7;
NEXT(L_9_8, D_8_9);
p(L_9_8, D_8_9) = 0.3;
NEXT(R_10_7, R_11_7);
NEXT(L_10_8, L_9_8);
NEXT(R_11_7, R_12_7);
NEXT(L_11_8, L_10_8);
NEXT(R_12_7, R_13_7);
NEXT(L_12_8, L_11_8);
NEXT(R_13_7, R_14_7);
NEXT(L_13_8, L_12_8);
NEXT(R_14_7, R_15_7);
NEXT(L_14_8, L_13_8);
LAST(R_15_7);
k(R_15_7) = 9999.0;
FIRST(L_15_8);
k(L_15_8) = 10000.0;
NEXT(L_15_8, L_14_8);
k(L_14_8) = 0.15;
};
}

instance is_intersection {

domain = traffic;
non-fluents = intersection;
init-state {
n(R_0_7) = 10000.0;
n(D_8_0) = 10000.0;
n(L_15_8) = 10000.0;
n(U_7_15) = 10000.0;
};

max-nondef-actions = 1;
horizon = 100;
discount = 1.0;
}

///////////////////////////////////////////////////////////////////
// ONE WAY GRID OF 3×3 INTERSECTIONS
///////////////////////////////////////////////////////////////////

non-fluents grid {
domain = traffic;
objects {
cell : {
R_0_5, R_0_11, R_0_17, R_1_5, R_1_11, R_1_17, R_2_5, R_2_11,
R_2_17, R_3_5, R_3_11, R_3_17, R_4_5, R_4_11, R_4_17, D_5_0,
D_5_1, D_5_2, D_5_3, D_5_4, D_5_6, D_5_7, D_5_8, D_5_9, D_5_10,
D_5_12, D_5_13, D_5_14, D_5_15, D_5_16, D_5_18, D_5_19, D_5_20,
D_5_21, D_5_22, R_6_5, R_6_11, R_6_17, R_7_5, R_7_11, R_7_17,
R_8_5, R_8_11, R_8_17, R_9_5, R_9_11, R_9_17, R_10_5, R_10_11,
R_10_17, D_11_0, D_11_1, D_11_2, D_11_3, D_11_4, D_11_6, D_11_7,
D_11_8, D_11_9, D_11_10, D_11_12, D_11_13, D_11_14, D_11_15,
D_11_16, D_11_18, D_11_19, D_11_20, D_11_21, D_11_22, R_12_5,
R_12_11, R_12_17, R_13_5, R_13_11, R_13_17, R_14_5, R_14_11,
R_14_17, R_15_5, R_15_11, R_15_17, R_16_5, R_16_11, R_16_17,
D_17_0, D_17_1, D_17_2, D_17_3, D_17_4, D_17_6, D_17_7, D_17_8,
D_17_9, D_17_10, D_17_12, D_17_13, D_17_14, D_17_15, D_17_16,
D_17_18, D_17_19, D_17_20, D_17_21, D_17_22, R_18_5, R_18_11,
R_18_17, R_19_5, R_19_11, R_19_17, R_20_5, R_20_11, R_20_17,
R_21_5, R_21_11, R_21_17, R_22_5, R_22_11, R_22_17
};
intersection : {
I_5_5, I_11_11
};
};

non-fluents {
FIRST(R_0_5);
k(R_0_5) = 10000.0;
NEXT(R_0_5, R_1_5);
k(R_1_5) = 0.15;
FIRST(R_0_11);
k(R_0_11) = 10000.0;
NEXT(R_0_11, R_1_11);
k(R_1_11) = 0.15;
FIRST(R_0_17);
k(R_0_17) = 10000.0;
NEXT(R_0_17, R_1_17);
k(R_1_17) = 0.15;
NEXT(R_1_5, R_2_5);
NEXT(R_1_11, R_2_11);
NEXT(R_1_17, R_2_17);
NEXT(R_2_5, R_3_5);
NEXT(R_2_11, R_3_11);
NEXT(R_2_17, R_3_17);
NEXT(R_3_5, R_4_5);
NEXT(R_3_11, R_4_11);
NEXT(R_3_17, R_4_17);
NEXT(R_4_5, R_6_5);
NEXT(R_4_11, R_6_11);
NEXT(R_4_17, R_6_17);
FIRST(D_5_0);
k(D_5_0) = 10000.0;
NEXT(D_5_0, D_5_1);
k(D_5_1) = 0.15;
NEXT(D_5_1, D_5_2);
NEXT(D_5_2, D_5_3);
NEXT(D_5_3, D_5_4);
NEXT(D_5_4, D_5_6);
NEXT(D_5_6, D_5_7);
NEXT(D_5_7, D_5_8);
NEXT(D_5_8, D_5_9);
NEXT(D_5_9, D_5_10);
NEXT(D_5_10, D_5_12);
NEXT(D_5_12, D_5_13);
NEXT(D_5_13, D_5_14);
NEXT(D_5_14, D_5_15);
NEXT(D_5_15, D_5_16);
NEXT(D_5_16, D_5_18);
NEXT(D_5_18, D_5_19);
NEXT(D_5_19, D_5_20);
NEXT(D_5_20, D_5_21);
NEXT(D_5_21, D_5_22);
LAST(D_5_22);
k(D_5_22) = 9999.0;
NEXT(R_6_5, R_7_5);
NEXT(R_6_11, R_7_11);
NEXT(R_6_17, R_7_17);
NEXT(R_7_5, R_8_5);
NEXT(R_7_11, R_8_11);
NEXT(R_7_17, R_8_17);
NEXT(R_8_5, R_9_5);
NEXT(R_8_11, R_9_11);
NEXT(R_8_17, R_9_17);
NEXT(R_9_5, R_10_5);
NEXT(R_9_11, R_10_11);
NEXT(R_9_17, R_10_17);
NEXT(R_10_5, R_12_5);
NEXT(R_10_11, R_12_11);
NEXT(R_10_17, R_12_17);
FIRST(D_11_0);
k(D_11_0) = 10000.0;
NEXT(D_11_0, D_11_1);
k(D_11_1) = 0.15;
NEXT(D_11_1, D_11_2);
NEXT(D_11_2, D_11_3);
NEXT(D_11_3, D_11_4);
NEXT(D_11_4, D_11_6);
NEXT(D_11_6, D_11_7);
NEXT(D_11_7, D_11_8);
NEXT(D_11_8, D_11_9);
NEXT(D_11_9, D_11_10);
NEXT(D_11_10, D_11_12);
NEXT(D_11_12, D_11_13);
NEXT(D_11_13, D_11_14);
NEXT(D_11_14, D_11_15);
NEXT(D_11_15, D_11_16);
NEXT(D_11_16, D_11_18);
NEXT(D_11_18, D_11_19);
NEXT(D_11_19, D_11_20);
NEXT(D_11_20, D_11_21);
NEXT(D_11_21, D_11_22);
LAST(D_11_22);
k(D_11_22) = 9999.0;
NEXT(R_12_5, R_13_5);
NEXT(R_12_11, R_13_11);
NEXT(R_12_17, R_13_17);
NEXT(R_13_5, R_14_5);
NEXT(R_13_11, R_14_11);
NEXT(R_13_17, R_14_17);
NEXT(R_14_5, R_15_5);
NEXT(R_14_11, R_15_11);
NEXT(R_14_17, R_15_17);
NEXT(R_15_5, R_16_5);
NEXT(R_15_11, R_16_11);
NEXT(R_15_17, R_16_17);
NEXT(R_16_5, R_18_5);
NEXT(R_16_11, R_18_11);
NEXT(R_16_17, R_18_17);
FIRST(D_17_0);
k(D_17_0) = 10000.0;
NEXT(D_17_0, D_17_1);
k(D_17_1) = 0.15;
NEXT(D_17_1, D_17_2);
NEXT(D_17_2, D_17_3);
NEXT(D_17_3, D_17_4);
NEXT(D_17_4, D_17_6);
NEXT(D_17_6, D_17_7);
NEXT(D_17_7, D_17_8);
NEXT(D_17_8, D_17_9);
NEXT(D_17_9, D_17_10);
NEXT(D_17_10, D_17_12);
NEXT(D_17_12, D_17_13);
NEXT(D_17_13, D_17_14);
NEXT(D_17_14, D_17_15);
NEXT(D_17_15, D_17_16);
NEXT(D_17_16, D_17_18);
NEXT(D_17_18, D_17_19);
NEXT(D_17_19, D_17_20);
NEXT(D_17_20, D_17_21);
NEXT(D_17_21, D_17_22);
LAST(D_17_22);
k(D_17_22) = 9999.0;
NEXT(R_18_5, R_19_5);
NEXT(R_18_11, R_19_11);
NEXT(R_18_17, R_19_17);
NEXT(R_19_5, R_20_5);
NEXT(R_19_11, R_20_11);
NEXT(R_19_17, R_20_17);
NEXT(R_20_5, R_21_5);
NEXT(R_20_11, R_21_11);
NEXT(R_20_17, R_21_17);
NEXT(R_21_5, R_22_5);
NEXT(R_21_11, R_22_11);
NEXT(R_21_17, R_22_17);
LAST(R_22_5);
k(R_22_5) = 9999.0;
LAST(R_22_11);
k(R_22_11) = 9999.0;
LAST(R_22_17);
k(R_22_17) = 9999.0;
FLOWS-TO-INTERSECTION (R_4_5, I_5_5, @WEST-EAST);
FLOWS-TO-INTERSECTION (D_5_4, I_5_5, @NORHT-SOUTH);
FLOWS-TO-INTERSECTION (R_10_11, I_11_11, @WEST-EAST);
FLOWS-TO-INTERSECTION (D_11_10, I_11_11, @NORHT-SOUTH);
//signal(I_5_5) = @WEST-EAST;
//signal(I_11_11) = @NORHT-SOUTH;
};
}

instance is_grid {

domain = traffic;
non-fluents = grid;
init-state {
n(R_0_5) = 10000.0;
n(R_0_11) = 10000.0;
n(R_0_17) = 10000.0;
n(D_5_0) = 10000.0;
n(D_11_0) = 10000.0;
n(D_17_0) = 10000.0;
};

max-nondef-actions = 2;
horizon = 100;
discount = 1.0;
}