Merge pull request 'ID3' (#3) from ID3 into master

Reviewed-on: #3
This commit is contained in:
Mateusz Szlachetka 2023-05-30 16:22:24 +02:00
commit dbee7b09a7
21 changed files with 485 additions and 122 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/__pycache__

3
.idea/.gitignore vendored
View File

@ -1,3 +0,0 @@
# Default ignored files
/shelf/
/workspace.xml

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -36,26 +36,3 @@ def astar(istate, goalx, goaly, passedFields):
element.priority = value.priority
return False
# def bfs(istate, goalx, goaly, passedFields):
# fringe = [istate]
# explored = []
# steps = []
# while fringe:
# state = fringe.pop(0)
# if state.xpos == goalx and state.ypos == goaly:
# steps.insert(0, state)
# while (state.parent != None):
# state = state.parent
# steps.insert(0, state)
# return steps
# element = successors(state, passedFields)
# explored.append((state.xpos, state.ypos, state.orientation))
# for value in element:
# val = (value.xpos, value.ypos, value.orientation)
# if val not in explored and value not in fringe:
# fringe.append(value)
# return False

105
collect Normal file
View File

@ -0,0 +1,105 @@
digraph Tree {
node [shape=box, fontname="helvetica"] ;
edge [fontname="helvetica"] ;
0 [label="distance <= 14.5\ngini = 0.484\nsamples = 200\nvalue = [118, 82]\nclass = collect"] ;
1 [label="paid_on_time <= 0.5\ngini = 0.437\nsamples = 93\nvalue = [30, 63]\nclass = no-collect"] ;
0 -> 1 [labeldistance=2.5, labelangle=45, headlabel="True"] ;
2 [label="gini = 0.0\nsamples = 9\nvalue = [9, 0]\nclass = collect"] ;
1 -> 2 ;
3 [label="fuel <= 1508.0\ngini = 0.375\nsamples = 84\nvalue = [21, 63]\nclass = no-collect"] ;
1 -> 3 ;
4 [label="gini = 0.0\nsamples = 7\nvalue = [7, 0]\nclass = collect"] ;
3 -> 4 ;
5 [label="space_occupied <= 0.856\ngini = 0.298\nsamples = 77\nvalue = [14, 63]\nclass = no-collect"] ;
3 -> 5 ;
6 [label="days_since_last_collection <= 4.5\ngini = 0.187\nsamples = 67\nvalue = [7, 60]\nclass = no-collect"] ;
5 -> 6 ;
7 [label="fuel <= 11519.5\ngini = 0.48\nsamples = 5\nvalue = [3, 2]\nclass = collect"] ;
6 -> 7 ;
8 [label="gini = 0.0\nsamples = 3\nvalue = [3, 0]\nclass = collect"] ;
7 -> 8 ;
9 [label="gini = 0.0\nsamples = 2\nvalue = [0, 2]\nclass = no-collect"] ;
7 -> 9 ;
10 [label="fuel <= 16955.0\ngini = 0.121\nsamples = 62\nvalue = [4, 58]\nclass = no-collect"] ;
6 -> 10 ;
11 [label="garbage_weight <= 0.612\ngini = 0.094\nsamples = 61\nvalue = [3, 58]\nclass = no-collect"] ;
10 -> 11 ;
12 [label="distance <= 10.5\ngini = 0.5\nsamples = 2\nvalue = [1, 1]\nclass = collect"] ;
11 -> 12 ;
13 [label="gini = 0.0\nsamples = 1\nvalue = [1, 0]\nclass = collect"] ;
12 -> 13 ;
14 [label="gini = 0.0\nsamples = 1\nvalue = [0, 1]\nclass = no-collect"] ;
12 -> 14 ;
15 [label="garbage_type <= 2.5\ngini = 0.065\nsamples = 59\nvalue = [2, 57]\nclass = no-collect"] ;
11 -> 15 ;
16 [label="gini = 0.0\nsamples = 46\nvalue = [0, 46]\nclass = no-collect"] ;
15 -> 16 ;
17 [label="garbage_weight <= 15.925\ngini = 0.26\nsamples = 13\nvalue = [2, 11]\nclass = no-collect"] ;
15 -> 17 ;
18 [label="odour_intensity <= 5.724\ngini = 0.444\nsamples = 3\nvalue = [2, 1]\nclass = collect"] ;
17 -> 18 ;
19 [label="gini = 0.0\nsamples = 2\nvalue = [2, 0]\nclass = collect"] ;
18 -> 19 ;
20 [label="gini = 0.0\nsamples = 1\nvalue = [0, 1]\nclass = no-collect"] ;
18 -> 20 ;
21 [label="gini = 0.0\nsamples = 10\nvalue = [0, 10]\nclass = no-collect"] ;
17 -> 21 ;
22 [label="gini = 0.0\nsamples = 1\nvalue = [1, 0]\nclass = collect"] ;
10 -> 22 ;
23 [label="garbage_type <= 1.0\ngini = 0.42\nsamples = 10\nvalue = [7, 3]\nclass = collect"] ;
5 -> 23 ;
24 [label="gini = 0.0\nsamples = 2\nvalue = [0, 2]\nclass = no-collect"] ;
23 -> 24 ;
25 [label="odour_intensity <= 8.841\ngini = 0.219\nsamples = 8\nvalue = [7, 1]\nclass = collect"] ;
23 -> 25 ;
26 [label="gini = 0.0\nsamples = 6\nvalue = [6, 0]\nclass = collect"] ;
25 -> 26 ;
27 [label="space_occupied <= 0.936\ngini = 0.5\nsamples = 2\nvalue = [1, 1]\nclass = collect"] ;
25 -> 27 ;
28 [label="gini = 0.0\nsamples = 1\nvalue = [0, 1]\nclass = no-collect"] ;
27 -> 28 ;
29 [label="gini = 0.0\nsamples = 1\nvalue = [1, 0]\nclass = collect"] ;
27 -> 29 ;
30 [label="odour_intensity <= 7.156\ngini = 0.292\nsamples = 107\nvalue = [88, 19]\nclass = collect"] ;
0 -> 30 [labeldistance=2.5, labelangle=-45, headlabel="False"] ;
31 [label="garbage_weight <= 49.659\ngini = 0.116\nsamples = 81\nvalue = [76, 5]\nclass = collect"] ;
30 -> 31 ;
32 [label="days_since_last_collection <= 24.5\ngini = 0.095\nsamples = 80\nvalue = [76, 4]\nclass = collect"] ;
31 -> 32 ;
33 [label="gini = 0.0\nsamples = 65\nvalue = [65, 0]\nclass = collect"] ;
32 -> 33 ;
34 [label="distance <= 19.0\ngini = 0.391\nsamples = 15\nvalue = [11, 4]\nclass = collect"] ;
32 -> 34 ;
35 [label="fuel <= 6122.0\ngini = 0.444\nsamples = 6\nvalue = [2, 4]\nclass = no-collect"] ;
34 -> 35 ;
36 [label="gini = 0.0\nsamples = 2\nvalue = [2, 0]\nclass = collect"] ;
35 -> 36 ;
37 [label="gini = 0.0\nsamples = 4\nvalue = [0, 4]\nclass = no-collect"] ;
35 -> 37 ;
38 [label="gini = 0.0\nsamples = 9\nvalue = [9, 0]\nclass = collect"] ;
34 -> 38 ;
39 [label="gini = 0.0\nsamples = 1\nvalue = [0, 1]\nclass = no-collect"] ;
31 -> 39 ;
40 [label="days_since_last_collection <= 13.5\ngini = 0.497\nsamples = 26\nvalue = [12, 14]\nclass = no-collect"] ;
30 -> 40 ;
41 [label="gini = 0.0\nsamples = 8\nvalue = [8, 0]\nclass = collect"] ;
40 -> 41 ;
42 [label="distance <= 20.0\ngini = 0.346\nsamples = 18\nvalue = [4, 14]\nclass = no-collect"] ;
40 -> 42 ;
43 [label="gini = 0.0\nsamples = 8\nvalue = [0, 8]\nclass = no-collect"] ;
42 -> 43 ;
44 [label="days_since_last_collection <= 20.0\ngini = 0.48\nsamples = 10\nvalue = [4, 6]\nclass = no-collect"] ;
42 -> 44 ;
45 [label="gini = 0.0\nsamples = 2\nvalue = [2, 0]\nclass = collect"] ;
44 -> 45 ;
46 [label="paid_on_time <= 0.5\ngini = 0.375\nsamples = 8\nvalue = [2, 6]\nclass = no-collect"] ;
44 -> 46 ;
47 [label="gini = 0.0\nsamples = 1\nvalue = [1, 0]\nclass = collect"] ;
46 -> 47 ;
48 [label="space_occupied <= 0.243\ngini = 0.245\nsamples = 7\nvalue = [1, 6]\nclass = no-collect"] ;
46 -> 48 ;
49 [label="gini = 0.0\nsamples = 1\nvalue = [1, 0]\nclass = collect"] ;
48 -> 49 ;
50 [label="gini = 0.0\nsamples = 6\nvalue = [0, 6]\nclass = no-collect"] ;
48 -> 50 ;
}

BIN
collect.pdf Normal file

Binary file not shown.

201
data_set.csv Normal file
View File

@ -0,0 +1,201 @@
garbage_type,fuel,distance,space_occupied,days_since_last_collection,paid_on_time,odour_intensity,garbage_weight,collect
recyclable,6858,1,0.38943502197015845,29,True,6.28805984614285,31.096305244645166,True
bio,8383,21,0.9783983457146607,14,True,6.707753087002224,20.60776725387002,False
mixed,16767,15,0.41993855549014525,4,False,5.463860044558358,30.805902479603375,False
mixed,4618,8,0.025718378803866293,7,True,7.861619200083265,14.1759921868727,True
mixed,3749,29,0.6874398304046323,27,True,4.716734486018472,47.37291145202405,False
mixed,6893,2,0.3001510840581795,8,True,3.878888089004194,19.996360389397914,True
electronics,14924,1,0.7997366072420831,24,True,5.973094339762372,2.1960136215621597,True
bio,7970,13,0.31037944811473195,26,True,5.391145637081767,39.14660991818736,True
electronics,7566,7,0.044065498651120305,4,True,2.52686741420688,3.783918766707756,False
recyclable,13581,11,0.3029291371776017,15,True,7.985626019620043,5.327771280989707,True
mixed,16818,8,0.878067948875321,13,True,4.014134116482834,1.7349754412586627,False
bio,16881,30,0.8470777393096841,14,True,0.1508008943936856,9.66913380182971,False
mixed,6990,10,0.7003280893926476,12,True,8.128384270607079,4.676920620947417,True
electronics,14086,30,0.2182437464175937,3,True,1.766466032409443,49.43307520335931,False
recyclable,3389,10,0.8579499065505017,19,True,3.247657682340906,45.78622737374704,False
electronics,6057,16,0.589008682632531,27,True,5.010436042547771,23.589036188265304,False
electronics,10251,7,0.11552896376668076,15,True,3.380450749316256,22.243992634560716,True
mixed,16614,14,0.2444832090788266,16,True,6.015757811660775,12.110210730052446,True
mixed,8603,25,0.16671039135639254,12,True,2.0426316125825617,47.053226873037204,False
electronics,2343,16,0.0019177537789323296,4,True,2.353885718716456,4.0522152593080785,False
mixed,9279,3,0.46016405802400917,12,True,6.9289984673929452,24.15422401013634,True
bio,15621,10,0.3233247817672673,5,True,8.466791831736632,23.608920139906314,True
bio,11780,15,0.003124570102083446,16,True,7.747913539805339,49.29577415013314,True
recyclable,15224,4,0.03393311087464668,11,True,5.780151215389308,42.38594368650846,True
recyclable,535,14,0.4776940289436078,0,True,8.494877610224057,23.248207177875784,False
electronics,15007,23,0.7631342797146662,10,True,0.1793546216957731,41.32221567095075,False
electronics,13535,9,0.7002708517558823,29,True,4.543146377877752,0.3812690587078782,False
mixed,12460,7,0.6532804013948539,22,True,8.852004069677973,34.19708152289112,True
recyclable,17025,10,0.2111830840475586,11,True,0.8139222112362365,14.761273939229502,False
mixed,16885,3,0.0975949844763121,27,True,1.5388814313627621,9.501289389032975,True
mixed,14821,25,0.5231352723059987,13,True,3.6950211926323115,19.618546801578105,False
recyclable,6723,24,0.08341759172764396,4,True,4.292133714797208,5.9636773580797,False
bio,13344,28,0.4054966875913566,7,True,8.155300248287965,2.6431453529897175,False
electronics,7067,4,0.18735850162710033,1,True,2.735687662737821,42.52061030278156,False
mixed,14883,28,0.8809908906796138,17,True,7.13642752409897,28.984329544863023,False
electronics,15327,16,0.8653586203448479,10,True,3.8134989189454647,43.44212224831813,False
recyclable,1852,3,0.29161758342646915,27,True,1.845882845057485,37.95248266834494,True
mixed,14063,10,0.88735326349903,25,True,9.625440487741033,21.41966124312023,True
electronics,4735,18,0.1252510557255211,13,False,8.809939106819362,17.200057730092645,False
bio,4092,19,0.7556427499119933,4,True,3.610989402681027,32.038861874477554,False
electronics,12823,1,0.7375871558645424,14,True,3.12238343732133,16.67997617867717,True
bio,12360,3,0.3865979303090342,13,True,4.448309991392886,9.896631997968996,True
recyclable,9995,9,0.6800124218236376,28,True,2.0962119840774807,45.05860783045714,True
bio,857,20,0.36392075025020776,25,True,4.4895067182730166,9.406278983853117,False
recyclable,10139,26,0.9066040779286622,20,False,0.7309817001963181,14.912659873544886,False
mixed,11367,30,0.7257029480054457,12,True,8.296118143388021,30.120689961002995,False
bio,2004,22,0.7384839037490499,20,True,1.6610395917967113,37.12329587330876,False
bio,13718,9,0.06421815231705275,9,False,8.9060063296501186,32.86630823851767,False
mixed,14594,17,0.24593434160148464,1,True,5.507095860755648,21.410155232517504,False
mixed,12592,8,0.47050946446896347,17,True,2.4322073604255134,12.82067348792581,True
mixed,16059,28,0.7995568646748424,1,True,5.556787942194185,8.789906454780377,False
mixed,1210,16,0.9461663853861345,0,True,2.5620254206135806,39.92136033622557,False
mixed,12953,18,0.0598916012395212,27,True,2.810396268707139,25.886625456241696,True
electronics,17774,25,0.26581024512537343,23,True,2.955583055546205,33.351645476151084,False
mixed,13595,23,0.3713870997608135,11,True,1.6069501479828574,43.79700923082427,False
mixed,3118,7,0.6936408840161455,28,False,8.669795911175331,49.7583760134488,False
recyclable,12193,26,0.969969668681659,3,True,3.756475032068799,41.73283262204557,False
electronics,13374,1,0.7678121182374196,7,True,4.95820018411122,9.476031948059054,True
mixed,7457,17,0.21293177387216733,26,True,8.202412261856102,0.3829029481382584,True
mixed,7398,16,0.49410144025444536,16,True,7.698928135887976,33.24640393208706,True
mixed,11939,18,0.04797159785003968,13,False,5.492245453793608,37.36873260877674,False
electronics,4744,29,0.05115067774462534,24,True,7.631570324488663,30.754951936967018,False
bio,13219,29,0.8591801844097859,28,True,8.850869168838038,37.690349688214006,True
mixed,11622,25,0.5067305325569674,7,True,4.6346103758999755,4.704504516207297,False
mixed,11692,12,0.17347617422332506,22,True,5.114145437118437,24.395276804323178,True
bio,12296,24,0.5799754812241465,14,True,5.929568201554035,20.04153646842107,False
mixed,12430,9,0.7943934891555092,2,True,8.688396325515924,12.860980097196428,True
mixed,16648,30,0.1354303765809669,22,True,4.446396215536957,24.06405240646432,False
mixed,10871,29,0.43478843148386526,27,True,8.90718082268031,35.461520882501006,True
recyclable,13541,9,0.45405615353057316,7,True,3.4615446151786844,11.532681978881138,False
mixed,9494,14,0.004782166130939736,5,True,9.258834218622681,43.761301608448555,True
mixed,7626,18,0.027106139170503862,8,False,6.746581921499086,5.586416737760485,False
recyclable,17511,2,0.1687883078260003,2,True,3.533163673996471,9.580063428681257,True
mixed,9610,7,0.695059583332655,25,True,2.3401557803901185,2.3705609534927454,True
mixed,3040,15,0.1574864696817655,2,True,6.825464319706567,6.814407869306499,False
bio,9841,2,0.1895252320742898,26,False,9.889708159437411,44.94835767750827,False
bio,6885,10,0.7629703662996873,10,False,4.850662639613831,33.02584201142315,False
bio,3487,25,0.4059023944818234,26,True,0.5487554506182057,26.482581038110297,False
bio,13124,18,0.3208609348871274,14,True,7.714846611937395,5.336809899885014,True
mixed,11532,4,0.9839866498612999,19,True,9.782297099352132,36.47452307128158,False
bio,13629,25,0.9255282254327359,18,True,4.768952675438898,21.220696047775256,False
electronics,4218,26,0.643899092841499,13,True,6.252405819718647,1.0382261772403756,False
bio,10119,27,0.33713760854710817,2,True,8.871634154885593,5.427123034736042,False
mixed,14237,18,0.2515135349860018,17,True,2.63435728911785,26.348605217474137,False
electronics,12316,23,0.13513972842597843,14,True,3.435826288771592,49.21215054667067,False
bio,16469,1,0.9100349749865474,14,True,5.183443706926657,43.99603946668627,True
mixed,2254,24,0.22321781629342174,7,True,3.758392411693926,32.078459445867466,False
bio,5184,25,0.3726201549710213,12,False,2.3258260841300693,28.930776464888712,False
mixed,11992,5,0.37136935114748215,12,False,7.944810878729637,15.764730161260648,False
recyclable,14852,17,0.9669504391513694,11,True,4.3814601810147344,42.5325985730309,False
mixed,14788,18,0.15747540939044535,23,True,0.8202398859201865,34.287976972812764,False
mixed,4127,12,0.5705532308529626,22,True,4.34197948257461475,13.21045335312487,True
recyclable,1781,27,0.6119028273203277,27,True,3.832758551729495,20.419268022539832,False
recyclable,1961,8,0.050683227336650094,18,True,4.944070899462293,20.316554868079322,True
mixed,4065,2,0.2777985173757125,17,True,1.88190772834955,38.44905744099713,True
mixed,4028,7,0.08768360859117563,13,True,4.596363030469549,25.390975629302094,True
mixed,12667,23,0.7263372730324396,3,True,6.983673440089592,6.3271012844971946,False
electronics,902,10,0.0972446120759014,7,True,1.7007332471135728,2.4875140164366094,False
mixed,4133,25,0.8863142047204092,26,True,8.86434876905877,23.146736584299048,True
mixed,16907,19,0.6413162554313889,14,True,3.931847480053995,21.564811955711722,False
electronics,12129,17,0.3255998096481383,21,False,5.834549250003657,24.404139636994316,False
recyclable,9388,7,0.18480810633503664,8,True,3.307342994428133,29.47279722274338,True
electronics,12282,19,0.787940768129883,3,True,1.9425612340575626,44.338448409498895,False
recyclable,16843,18,0.3006615497630535,4,True,0.306619782743337,0.10183018082673412,False
mixed,14387,13,0.9070926514128955,3,True,2.42929766024208,11.249774077666292,False
electronics,15436,27,0.06941730562384307,26,True,4.5631172094766175,27.34477833807143,False
mixed,15465,13,0.08353207908213156,16,False,6.820610862001022,28.32262519003446,False
electronics,14811,2,0.3949179382540411,23,True,0.381962545476181,41.11931445912492,True
bio,2151,3,0.9129936622264005,22,True,9.17371100015908136,33.74134732997111,True
mixed,237,11,0.9964787642547496,25,True,5.211086288207052,16.330679822388745,False
mixed,111,22,0.4711301611274815,18,True,8.30571757605114,48.73704630000289,False
electronics,4463,18,0.5607936953252097,9,True,5.340209435107365,10.017097722357493,False
electronics,15244,3,0.3869275687952053,18,True,3.652817201742993,37.26534729300576,True
mixed,11816,29,0.04079719450519703,18,True,7.2327475650423647,11.744528538216914,False
mixed,7419,13,0.03779749101113905,15,True,7.672313681492664,5.861975978144901,True
electronics,9401,14,0.3103153528084557,26,True,5.2103976136388175,38.08987567003111,True
mixed,16276,3,0.479034009007552,27,True,4.651924221072261,10.953743088081447,True
mixed,4532,2,0.747513820128898,29,True,0.2586713125686746,19.881947016208546,True
mixed,11549,8,0.49394575237900273,6,True,2.5440665374161995,32.4915857099389873,True
recyclable,3813,4,0.22880151196725018,6,True,7.220713613387959,46.890649430682544,True
bio,17962,18,0.624644549751732,11,False,8.475303217255203,5.3631616817744865,False
bio,3940,25,0.8584303157289703,30,True,7.295573469672193,19.75062441304104,True
bio,3540,1,0.16268575368033733,13,True,5.880093986834379,13.761791968844527,True
recyclable,5461,20,0.9720273624310242,9,True,7.150632586077218,22.90010680963285,False
bio,11821,19,0.4890954252362738,5,True,5.243707979141446,34.04257151648786,False
bio,4151,13,0.7741603691526736,24,True,8.797747697546043,23.594349450180914,True
recyclable,9015,12,0.06465113909613351,16,True,6.820701685767977,0.20513555254460525,True
mixed,6611,16,0.6367050551717114,9,True,1.1168941403754773,22.01478968287895,False
bio,5523,14,0.7903120332698462,13,True,5.584457456040392,49.05459466627317,True
mixed,5789,27,0.9382743640127215,15,True,6.322173697254331,47.602736117018026,False
bio,3441,20,0.2704566556023139,9,True,6.034883457792668,5.934602634889502,False
bio,12771,17,0.9036479407267245,6,True,4.983318099275128,4.7884656590729495,False
mixed,14202,21,0.1829947029669602,19,True,6.351850543526715,49.88486222532098,True
electronics,5853,7,0.25211596914266365,19,False,6.04880922544101,44.15037893145479,False
bio,1013,28,0.2328958888157674,10,True,5.722313037134815,44.5605489804229,False
mixed,4382,25,0.9629592705464354,15,True,0.7262561290537561,49.22062156968296,False
electronics,303,15,0.1935869262999148,28,True,4.825010078601935,32.304918866098134,False
mixed,11291,3,0.4987501399891241,19,True,7.593017186381552,17.60598885484067,True
mixed,228,11,0.7482870715914006,15,True,4.99089814924729,10.43107633070246,False
bio,1164,11,0.5377166416978679,22,True,5.107421661337108,14.616108271654959,False
mixed,16153,28,0.10319171233491664,9,False,4.403420968891197,2.0814455890390384,False
mixed,5727,8,0.6742508678514485,12,True,5.806819175818928,40.39841656773793,True
mixed,8684,28,0.28952554683233755,4,True,3.6507840151179174,14.380642477352534,False
bio,15036,25,0.3013529193213179,28,True,2.8003869601469213,1.7050484121073906,False
electronics,9081,15,0.552743466291092,2,True,3.64259133151227,46.66783990228206,False
bio,9195,11,0.39260282046107997,24,True,9.000375724293816,9.358015869334334,True
recyclable,8258,17,0.9173355631818932,24,True,5.696271382671787,11.838799672256089,False
mixed,5203,16,0.20853652624054675,7,False,7.218874544155853,3.3802787098178633,False
mixed,10353,4,0.6612627593282159,12,True,0.8160458268763704,48.21072530277851,True
mixed,1801,26,0.1724747032914301,5,True,9.767546930194213,48.306921765049395,False
mixed,9787,3,0.12733427196255642,6,True,2.878806668582902,19.141664339310555,True
recyclable,3968,8,0.13408211860863806,19,True,7.004806522643715,21.695728722138725,True
mixed,14638,26,0.6610180396198244,25,True,5.004704839665123,8.611752981253796,False
mixed,8548,17,0.6919756512026707,26,True,8.7096013024813113,47.49247425366768,True
mixed,1491,18,0.9820986051525684,9,True,9.258025774670367,15.98094975265509,False
recyclable,3668,17,0.7640578172220626,14,True,3.3725194345302,20.997519420207006,False
mixed,9787,4,0.4690947509402401,17,True,0.5513818386579639,35.515442456358294,True
mixed,11328,16,0.05659862491548939,28,True,6.580525503234329,40.057728572365605,True
mixed,4016,27,0.7672970359948862,1,True,0.6970633008301563,45.40712539668869,False
bio,235,8,0.1340953149733236,18,True,8.0577551256497664,24.750364306492106,False
mixed,4125,11,0.32068177017369326,24,True,2.0819986305961913,30.206075317324398,True
mixed,7794,5,0.7237994849277903,20,True,1.182186279436862,15.700974509225196,True
electronics,5395,16,0.8055586819904074,24,True,4.031003133386356,23.875466510639743,False
mixed,15505,18,0.45203522304151467,17,True,7.160642286283462,45.612740804260326,True
electronics,1348,21,0.9644616372108747,25,True,6.634919820603092,46.44550586828582,False
mixed,13686,1,0.8528583962138082,5,True,0.6350681726528817,0.8430687396440373,True
electronics,13873,30,0.294532542273514,12,True,4.044317910413886,29.99919461949812,False
mixed,930,14,0.46484946768172597,23,True,7.293222367859043,17.888778031470803,False
recyclable,6370,7,0.3266741326325917,9,True,6.774166929984485,28.671638946376447,True
recyclable,13159,18,0.5742087586584416,3,True,2.8310145159793643,40.38310972219153,False
recyclable,8149,23,0.4840066004404705,10,True,6.860051045888277,29.211740461959135,False
recyclable,396,16,0.504161153047322,22,True,1.1809202381636141,21.642509975194923,False
mixed,17012,15,0.36468655494367364,17,True,9.146259705631856,30.88331825323704,True
bio,8100,30,0.454702411813268,22,True,9.779578763490457,11.101202564362856,True
mixed,8726,9,0.5227832599121376,18,False,8.2472402461143006,23.712317819323303,False
mixed,5613,27,0.6288843449715512,13,True,0.48282122404645356,14.460408589324647,False
recyclable,13042,1,0.99875193495793,28,True,8.056286187944535,19.768446255164413,False
electronics,1873,23,0.7266911060409714,26,True,6.289322618112965,25.655151095201717,False
mixed,13898,3,0.6023654342268365,21,False,4.18436411688805,30.68913330956739,False
mixed,8500,16,0.3132189683797034,20,True,9.665381836688276,26.531016057140715,True
mixed,10609,12,0.7957280975350293,3,True,5.967088403839806,30.980907594987215,False
mixed,14060,9,0.8533975340326421,26,True,5.081066967675499,3.5703010248585523,True
bio,10428,9,0.12952527618075171,16,True,8.409694306302747,38.25806756331836,True
mixed,12129,10,0.16679000401714317,8,True,3.4722510171543055,39.07152515129634,True
recyclable,6077,6,0.9688896707567596,1,True,2.2628928125079515,25.143203629333183,False
electronics,17942,30,0.9333715534636539,16,True,0.8192317565547003,6.090205324669523,False
mixed,12312,1,0.7589005664492561,5,True,5.319612963692009,48.574652948536254,True
mixed,10378,25,0.525947228730475,22,True,8.650164549728183,37.47486500747239,True
bio,10538,17,0.24441031022066229,25,True,4.9354317996121857,10.573213306548123,True
recyclable,6187,16,0.48862304056788397,26,True,2.3657930824249473,37.65868384027124,True
mixed,13968,13,0.9178321609964433,0,True,2.9607729258033775,7.084392850555182,False
electronics,9805,15,0.17688249183631466,13,True,3.655335256007239,20.687030526697665,False
recyclable,8650,11,0.5509231139255383,18,True,4.995396641282026,29.262501847653766,True
recyclable,9498,14,0.24820888510715444,16,True,2.752760360379596,3.736430768304949,False
mixed,11052,23,0.5825446526885096,13,True,2.625836401148206,19.3834716160646,False
bio,16212,23,0.9097101570818567,26,False,9.766445054530736,11.374414855314813,False
mixed,8855,6,0.11681132733819222,28,True,7.162264591925456,1.4784965471126454,True
mixed,16243,14,0.3066015436426298,11,True,7.527387665529669,27.536003398124848,True
mixed,12805,27,0.2980093260554303,12,True,1.2954787682496038,26.763165725254694,False
recyclable,8656,28,0.06481336166041907,19,True,7.13282912045492,38.64738564701376,False
1 garbage_type fuel distance space_occupied days_since_last_collection paid_on_time odour_intensity garbage_weight collect
2 recyclable 6858 1 0.38943502197015845 29 True 6.28805984614285 31.096305244645166 True
3 bio 8383 21 0.9783983457146607 14 True 6.707753087002224 20.60776725387002 False
4 mixed 16767 15 0.41993855549014525 4 False 5.463860044558358 30.805902479603375 False
5 mixed 4618 8 0.025718378803866293 7 True 7.861619200083265 14.1759921868727 True
6 mixed 3749 29 0.6874398304046323 27 True 4.716734486018472 47.37291145202405 False
7 mixed 6893 2 0.3001510840581795 8 True 3.878888089004194 19.996360389397914 True
8 electronics 14924 1 0.7997366072420831 24 True 5.973094339762372 2.1960136215621597 True
9 bio 7970 13 0.31037944811473195 26 True 5.391145637081767 39.14660991818736 True
10 electronics 7566 7 0.044065498651120305 4 True 2.52686741420688 3.783918766707756 False
11 recyclable 13581 11 0.3029291371776017 15 True 7.985626019620043 5.327771280989707 True
12 mixed 16818 8 0.878067948875321 13 True 4.014134116482834 1.7349754412586627 False
13 bio 16881 30 0.8470777393096841 14 True 0.1508008943936856 9.66913380182971 False
14 mixed 6990 10 0.7003280893926476 12 True 8.128384270607079 4.676920620947417 True
15 electronics 14086 30 0.2182437464175937 3 True 1.766466032409443 49.43307520335931 False
16 recyclable 3389 10 0.8579499065505017 19 True 3.247657682340906 45.78622737374704 False
17 electronics 6057 16 0.589008682632531 27 True 5.010436042547771 23.589036188265304 False
18 electronics 10251 7 0.11552896376668076 15 True 3.380450749316256 22.243992634560716 True
19 mixed 16614 14 0.2444832090788266 16 True 6.015757811660775 12.110210730052446 True
20 mixed 8603 25 0.16671039135639254 12 True 2.0426316125825617 47.053226873037204 False
21 electronics 2343 16 0.0019177537789323296 4 True 2.353885718716456 4.0522152593080785 False
22 mixed 9279 3 0.46016405802400917 12 True 6.9289984673929452 24.15422401013634 True
23 bio 15621 10 0.3233247817672673 5 True 8.466791831736632 23.608920139906314 True
24 bio 11780 15 0.003124570102083446 16 True 7.747913539805339 49.29577415013314 True
25 recyclable 15224 4 0.03393311087464668 11 True 5.780151215389308 42.38594368650846 True
26 recyclable 535 14 0.4776940289436078 0 True 8.494877610224057 23.248207177875784 False
27 electronics 15007 23 0.7631342797146662 10 True 0.1793546216957731 41.32221567095075 False
28 electronics 13535 9 0.7002708517558823 29 True 4.543146377877752 0.3812690587078782 False
29 mixed 12460 7 0.6532804013948539 22 True 8.852004069677973 34.19708152289112 True
30 recyclable 17025 10 0.2111830840475586 11 True 0.8139222112362365 14.761273939229502 False
31 mixed 16885 3 0.0975949844763121 27 True 1.5388814313627621 9.501289389032975 True
32 mixed 14821 25 0.5231352723059987 13 True 3.6950211926323115 19.618546801578105 False
33 recyclable 6723 24 0.08341759172764396 4 True 4.292133714797208 5.9636773580797 False
34 bio 13344 28 0.4054966875913566 7 True 8.155300248287965 2.6431453529897175 False
35 electronics 7067 4 0.18735850162710033 1 True 2.735687662737821 42.52061030278156 False
36 mixed 14883 28 0.8809908906796138 17 True 7.13642752409897 28.984329544863023 False
37 electronics 15327 16 0.8653586203448479 10 True 3.8134989189454647 43.44212224831813 False
38 recyclable 1852 3 0.29161758342646915 27 True 1.845882845057485 37.95248266834494 True
39 mixed 14063 10 0.88735326349903 25 True 9.625440487741033 21.41966124312023 True
40 electronics 4735 18 0.1252510557255211 13 False 8.809939106819362 17.200057730092645 False
41 bio 4092 19 0.7556427499119933 4 True 3.610989402681027 32.038861874477554 False
42 electronics 12823 1 0.7375871558645424 14 True 3.12238343732133 16.67997617867717 True
43 bio 12360 3 0.3865979303090342 13 True 4.448309991392886 9.896631997968996 True
44 recyclable 9995 9 0.6800124218236376 28 True 2.0962119840774807 45.05860783045714 True
45 bio 857 20 0.36392075025020776 25 True 4.4895067182730166 9.406278983853117 False
46 recyclable 10139 26 0.9066040779286622 20 False 0.7309817001963181 14.912659873544886 False
47 mixed 11367 30 0.7257029480054457 12 True 8.296118143388021 30.120689961002995 False
48 bio 2004 22 0.7384839037490499 20 True 1.6610395917967113 37.12329587330876 False
49 bio 13718 9 0.06421815231705275 9 False 8.9060063296501186 32.86630823851767 False
50 mixed 14594 17 0.24593434160148464 1 True 5.507095860755648 21.410155232517504 False
51 mixed 12592 8 0.47050946446896347 17 True 2.4322073604255134 12.82067348792581 True
52 mixed 16059 28 0.7995568646748424 1 True 5.556787942194185 8.789906454780377 False
53 mixed 1210 16 0.9461663853861345 0 True 2.5620254206135806 39.92136033622557 False
54 mixed 12953 18 0.0598916012395212 27 True 2.810396268707139 25.886625456241696 True
55 electronics 17774 25 0.26581024512537343 23 True 2.955583055546205 33.351645476151084 False
56 mixed 13595 23 0.3713870997608135 11 True 1.6069501479828574 43.79700923082427 False
57 mixed 3118 7 0.6936408840161455 28 False 8.669795911175331 49.7583760134488 False
58 recyclable 12193 26 0.969969668681659 3 True 3.756475032068799 41.73283262204557 False
59 electronics 13374 1 0.7678121182374196 7 True 4.95820018411122 9.476031948059054 True
60 mixed 7457 17 0.21293177387216733 26 True 8.202412261856102 0.3829029481382584 True
61 mixed 7398 16 0.49410144025444536 16 True 7.698928135887976 33.24640393208706 True
62 mixed 11939 18 0.04797159785003968 13 False 5.492245453793608 37.36873260877674 False
63 electronics 4744 29 0.05115067774462534 24 True 7.631570324488663 30.754951936967018 False
64 bio 13219 29 0.8591801844097859 28 True 8.850869168838038 37.690349688214006 True
65 mixed 11622 25 0.5067305325569674 7 True 4.6346103758999755 4.704504516207297 False
66 mixed 11692 12 0.17347617422332506 22 True 5.114145437118437 24.395276804323178 True
67 bio 12296 24 0.5799754812241465 14 True 5.929568201554035 20.04153646842107 False
68 mixed 12430 9 0.7943934891555092 2 True 8.688396325515924 12.860980097196428 True
69 mixed 16648 30 0.1354303765809669 22 True 4.446396215536957 24.06405240646432 False
70 mixed 10871 29 0.43478843148386526 27 True 8.90718082268031 35.461520882501006 True
71 recyclable 13541 9 0.45405615353057316 7 True 3.4615446151786844 11.532681978881138 False
72 mixed 9494 14 0.004782166130939736 5 True 9.258834218622681 43.761301608448555 True
73 mixed 7626 18 0.027106139170503862 8 False 6.746581921499086 5.586416737760485 False
74 recyclable 17511 2 0.1687883078260003 2 True 3.533163673996471 9.580063428681257 True
75 mixed 9610 7 0.695059583332655 25 True 2.3401557803901185 2.3705609534927454 True
76 mixed 3040 15 0.1574864696817655 2 True 6.825464319706567 6.814407869306499 False
77 bio 9841 2 0.1895252320742898 26 False 9.889708159437411 44.94835767750827 False
78 bio 6885 10 0.7629703662996873 10 False 4.850662639613831 33.02584201142315 False
79 bio 3487 25 0.4059023944818234 26 True 0.5487554506182057 26.482581038110297 False
80 bio 13124 18 0.3208609348871274 14 True 7.714846611937395 5.336809899885014 True
81 mixed 11532 4 0.9839866498612999 19 True 9.782297099352132 36.47452307128158 False
82 bio 13629 25 0.9255282254327359 18 True 4.768952675438898 21.220696047775256 False
83 electronics 4218 26 0.643899092841499 13 True 6.252405819718647 1.0382261772403756 False
84 bio 10119 27 0.33713760854710817 2 True 8.871634154885593 5.427123034736042 False
85 mixed 14237 18 0.2515135349860018 17 True 2.63435728911785 26.348605217474137 False
86 electronics 12316 23 0.13513972842597843 14 True 3.435826288771592 49.21215054667067 False
87 bio 16469 1 0.9100349749865474 14 True 5.183443706926657 43.99603946668627 True
88 mixed 2254 24 0.22321781629342174 7 True 3.758392411693926 32.078459445867466 False
89 bio 5184 25 0.3726201549710213 12 False 2.3258260841300693 28.930776464888712 False
90 mixed 11992 5 0.37136935114748215 12 False 7.944810878729637 15.764730161260648 False
91 recyclable 14852 17 0.9669504391513694 11 True 4.3814601810147344 42.5325985730309 False
92 mixed 14788 18 0.15747540939044535 23 True 0.8202398859201865 34.287976972812764 False
93 mixed 4127 12 0.5705532308529626 22 True 4.34197948257461475 13.21045335312487 True
94 recyclable 1781 27 0.6119028273203277 27 True 3.832758551729495 20.419268022539832 False
95 recyclable 1961 8 0.050683227336650094 18 True 4.944070899462293 20.316554868079322 True
96 mixed 4065 2 0.2777985173757125 17 True 1.88190772834955 38.44905744099713 True
97 mixed 4028 7 0.08768360859117563 13 True 4.596363030469549 25.390975629302094 True
98 mixed 12667 23 0.7263372730324396 3 True 6.983673440089592 6.3271012844971946 False
99 electronics 902 10 0.0972446120759014 7 True 1.7007332471135728 2.4875140164366094 False
100 mixed 4133 25 0.8863142047204092 26 True 8.86434876905877 23.146736584299048 True
101 mixed 16907 19 0.6413162554313889 14 True 3.931847480053995 21.564811955711722 False
102 electronics 12129 17 0.3255998096481383 21 False 5.834549250003657 24.404139636994316 False
103 recyclable 9388 7 0.18480810633503664 8 True 3.307342994428133 29.47279722274338 True
104 electronics 12282 19 0.787940768129883 3 True 1.9425612340575626 44.338448409498895 False
105 recyclable 16843 18 0.3006615497630535 4 True 0.306619782743337 0.10183018082673412 False
106 mixed 14387 13 0.9070926514128955 3 True 2.42929766024208 11.249774077666292 False
107 electronics 15436 27 0.06941730562384307 26 True 4.5631172094766175 27.34477833807143 False
108 mixed 15465 13 0.08353207908213156 16 False 6.820610862001022 28.32262519003446 False
109 electronics 14811 2 0.3949179382540411 23 True 0.381962545476181 41.11931445912492 True
110 bio 2151 3 0.9129936622264005 22 True 9.17371100015908136 33.74134732997111 True
111 mixed 237 11 0.9964787642547496 25 True 5.211086288207052 16.330679822388745 False
112 mixed 111 22 0.4711301611274815 18 True 8.30571757605114 48.73704630000289 False
113 electronics 4463 18 0.5607936953252097 9 True 5.340209435107365 10.017097722357493 False
114 electronics 15244 3 0.3869275687952053 18 True 3.652817201742993 37.26534729300576 True
115 mixed 11816 29 0.04079719450519703 18 True 7.2327475650423647 11.744528538216914 False
116 mixed 7419 13 0.03779749101113905 15 True 7.672313681492664 5.861975978144901 True
117 electronics 9401 14 0.3103153528084557 26 True 5.2103976136388175 38.08987567003111 True
118 mixed 16276 3 0.479034009007552 27 True 4.651924221072261 10.953743088081447 True
119 mixed 4532 2 0.747513820128898 29 True 0.2586713125686746 19.881947016208546 True
120 mixed 11549 8 0.49394575237900273 6 True 2.5440665374161995 32.4915857099389873 True
121 recyclable 3813 4 0.22880151196725018 6 True 7.220713613387959 46.890649430682544 True
122 bio 17962 18 0.624644549751732 11 False 8.475303217255203 5.3631616817744865 False
123 bio 3940 25 0.8584303157289703 30 True 7.295573469672193 19.75062441304104 True
124 bio 3540 1 0.16268575368033733 13 True 5.880093986834379 13.761791968844527 True
125 recyclable 5461 20 0.9720273624310242 9 True 7.150632586077218 22.90010680963285 False
126 bio 11821 19 0.4890954252362738 5 True 5.243707979141446 34.04257151648786 False
127 bio 4151 13 0.7741603691526736 24 True 8.797747697546043 23.594349450180914 True
128 recyclable 9015 12 0.06465113909613351 16 True 6.820701685767977 0.20513555254460525 True
129 mixed 6611 16 0.6367050551717114 9 True 1.1168941403754773 22.01478968287895 False
130 bio 5523 14 0.7903120332698462 13 True 5.584457456040392 49.05459466627317 True
131 mixed 5789 27 0.9382743640127215 15 True 6.322173697254331 47.602736117018026 False
132 bio 3441 20 0.2704566556023139 9 True 6.034883457792668 5.934602634889502 False
133 bio 12771 17 0.9036479407267245 6 True 4.983318099275128 4.7884656590729495 False
134 mixed 14202 21 0.1829947029669602 19 True 6.351850543526715 49.88486222532098 True
135 electronics 5853 7 0.25211596914266365 19 False 6.04880922544101 44.15037893145479 False
136 bio 1013 28 0.2328958888157674 10 True 5.722313037134815 44.5605489804229 False
137 mixed 4382 25 0.9629592705464354 15 True 0.7262561290537561 49.22062156968296 False
138 electronics 303 15 0.1935869262999148 28 True 4.825010078601935 32.304918866098134 False
139 mixed 11291 3 0.4987501399891241 19 True 7.593017186381552 17.60598885484067 True
140 mixed 228 11 0.7482870715914006 15 True 4.99089814924729 10.43107633070246 False
141 bio 1164 11 0.5377166416978679 22 True 5.107421661337108 14.616108271654959 False
142 mixed 16153 28 0.10319171233491664 9 False 4.403420968891197 2.0814455890390384 False
143 mixed 5727 8 0.6742508678514485 12 True 5.806819175818928 40.39841656773793 True
144 mixed 8684 28 0.28952554683233755 4 True 3.6507840151179174 14.380642477352534 False
145 bio 15036 25 0.3013529193213179 28 True 2.8003869601469213 1.7050484121073906 False
146 electronics 9081 15 0.552743466291092 2 True 3.64259133151227 46.66783990228206 False
147 bio 9195 11 0.39260282046107997 24 True 9.000375724293816 9.358015869334334 True
148 recyclable 8258 17 0.9173355631818932 24 True 5.696271382671787 11.838799672256089 False
149 mixed 5203 16 0.20853652624054675 7 False 7.218874544155853 3.3802787098178633 False
150 mixed 10353 4 0.6612627593282159 12 True 0.8160458268763704 48.21072530277851 True
151 mixed 1801 26 0.1724747032914301 5 True 9.767546930194213 48.306921765049395 False
152 mixed 9787 3 0.12733427196255642 6 True 2.878806668582902 19.141664339310555 True
153 recyclable 3968 8 0.13408211860863806 19 True 7.004806522643715 21.695728722138725 True
154 mixed 14638 26 0.6610180396198244 25 True 5.004704839665123 8.611752981253796 False
155 mixed 8548 17 0.6919756512026707 26 True 8.7096013024813113 47.49247425366768 True
156 mixed 1491 18 0.9820986051525684 9 True 9.258025774670367 15.98094975265509 False
157 recyclable 3668 17 0.7640578172220626 14 True 3.3725194345302 20.997519420207006 False
158 mixed 9787 4 0.4690947509402401 17 True 0.5513818386579639 35.515442456358294 True
159 mixed 11328 16 0.05659862491548939 28 True 6.580525503234329 40.057728572365605 True
160 mixed 4016 27 0.7672970359948862 1 True 0.6970633008301563 45.40712539668869 False
161 bio 235 8 0.1340953149733236 18 True 8.0577551256497664 24.750364306492106 False
162 mixed 4125 11 0.32068177017369326 24 True 2.0819986305961913 30.206075317324398 True
163 mixed 7794 5 0.7237994849277903 20 True 1.182186279436862 15.700974509225196 True
164 electronics 5395 16 0.8055586819904074 24 True 4.031003133386356 23.875466510639743 False
165 mixed 15505 18 0.45203522304151467 17 True 7.160642286283462 45.612740804260326 True
166 electronics 1348 21 0.9644616372108747 25 True 6.634919820603092 46.44550586828582 False
167 mixed 13686 1 0.8528583962138082 5 True 0.6350681726528817 0.8430687396440373 True
168 electronics 13873 30 0.294532542273514 12 True 4.044317910413886 29.99919461949812 False
169 mixed 930 14 0.46484946768172597 23 True 7.293222367859043 17.888778031470803 False
170 recyclable 6370 7 0.3266741326325917 9 True 6.774166929984485 28.671638946376447 True
171 recyclable 13159 18 0.5742087586584416 3 True 2.8310145159793643 40.38310972219153 False
172 recyclable 8149 23 0.4840066004404705 10 True 6.860051045888277 29.211740461959135 False
173 recyclable 396 16 0.504161153047322 22 True 1.1809202381636141 21.642509975194923 False
174 mixed 17012 15 0.36468655494367364 17 True 9.146259705631856 30.88331825323704 True
175 bio 8100 30 0.454702411813268 22 True 9.779578763490457 11.101202564362856 True
176 mixed 8726 9 0.5227832599121376 18 False 8.2472402461143006 23.712317819323303 False
177 mixed 5613 27 0.6288843449715512 13 True 0.48282122404645356 14.460408589324647 False
178 recyclable 13042 1 0.99875193495793 28 True 8.056286187944535 19.768446255164413 False
179 electronics 1873 23 0.7266911060409714 26 True 6.289322618112965 25.655151095201717 False
180 mixed 13898 3 0.6023654342268365 21 False 4.18436411688805 30.68913330956739 False
181 mixed 8500 16 0.3132189683797034 20 True 9.665381836688276 26.531016057140715 True
182 mixed 10609 12 0.7957280975350293 3 True 5.967088403839806 30.980907594987215 False
183 mixed 14060 9 0.8533975340326421 26 True 5.081066967675499 3.5703010248585523 True
184 bio 10428 9 0.12952527618075171 16 True 8.409694306302747 38.25806756331836 True
185 mixed 12129 10 0.16679000401714317 8 True 3.4722510171543055 39.07152515129634 True
186 recyclable 6077 6 0.9688896707567596 1 True 2.2628928125079515 25.143203629333183 False
187 electronics 17942 30 0.9333715534636539 16 True 0.8192317565547003 6.090205324669523 False
188 mixed 12312 1 0.7589005664492561 5 True 5.319612963692009 48.574652948536254 True
189 mixed 10378 25 0.525947228730475 22 True 8.650164549728183 37.47486500747239 True
190 bio 10538 17 0.24441031022066229 25 True 4.9354317996121857 10.573213306548123 True
191 recyclable 6187 16 0.48862304056788397 26 True 2.3657930824249473 37.65868384027124 True
192 mixed 13968 13 0.9178321609964433 0 True 2.9607729258033775 7.084392850555182 False
193 electronics 9805 15 0.17688249183631466 13 True 3.655335256007239 20.687030526697665 False
194 recyclable 8650 11 0.5509231139255383 18 True 4.995396641282026 29.262501847653766 True
195 recyclable 9498 14 0.24820888510715444 16 True 2.752760360379596 3.736430768304949 False
196 mixed 11052 23 0.5825446526885096 13 True 2.625836401148206 19.3834716160646 False
197 bio 16212 23 0.9097101570818567 26 False 9.766445054530736 11.374414855314813 False
198 mixed 8855 6 0.11681132733819222 28 True 7.162264591925456 1.4784965471126454 True
199 mixed 16243 14 0.3066015436426298 11 True 7.527387665529669 27.536003398124848 True
200 mixed 12805 27 0.2980093260554303 12 True 1.2954787682496038 26.763165725254694 False
201 recyclable 8656 28 0.06481336166041907 19 True 7.13282912045492 38.64738564701376 False

View File

@ -1,31 +1,38 @@
from heuristicfn import heuristicfn
FIELDWIDTH = 50
TURN_FUEL_COST = 10
MOVE_FUEL_COST = 200
MAX_FUEL = 20000
MAX_SPACE = 5
MAX_WEIGHT = 200
class GarbageTank:
def __init__(self, volume_capacity, mass_capacity):
self.vcapacity = volume_capacity #m^3
self.mcapacity = mass_capacity #kg
class Engine:
def __init__(self, power):
self.power = power #HP
class GarbageTruck:
def __init__(self, dump_location, fuel_capacity, rect, orientation):
self.dump_location = dump_location
self.tank = GarbageTank(15, 18000)
self.engine = Engine(400)
self.fuel = fuel_capacity
garbage_types = {'bio': 0, 'electronics': 1, 'mixed': 2, 'recyclable': 3}
def __init__(self, dump_x, dump_y, rect, orientation, request_list: list, clf):
self.dump_x = dump_x
self.dump_y = dump_y
self.fuel = MAX_FUEL
self.free_space = MAX_SPACE
self.weight_capacity = MAX_WEIGHT
self.rect = rect
self.orientation = orientation
self.houses = [] #lista domów do odwiedzenia
self.request_list = request_list #lista domów do odwiedzenia
self.clf = clf
def turn_left(self):
self.orientation = (self.orientation - 1) % 4
self.fuel -= TURN_FUEL_COST
def turn_right(self):
self.orientation = (self.orientation + 1) % 4
self.fuel -= TURN_FUEL_COST
def forward(self):
self.fuel -= MOVE_FUEL_COST
if self.orientation == 0:
self.rect.x += FIELDWIDTH
elif self.orientation == 1:
@ -33,4 +40,48 @@ class GarbageTruck:
elif self.orientation == 2:
self.rect.x -= FIELDWIDTH
else:
self.rect.y -= FIELDWIDTH
self.rect.y -= FIELDWIDTH
def next_destination(self):
for i in range(len(self.request_list)):
request = self.request_list[i]
#nie ma miejsca w zbiorniku lub za ciężkie śmieci
if request.volume > self.free_space or request.weight > self.weight_capacity:
continue
#nie straczy paliwa na dojechanie i powrót na wysypisko
if heuristicfn(request.x_pos, request.y_pos, self.dump_x, self.dump_y) // 50 * 200 > self.fuel:
continue
distance = heuristicfn(self.rect.x, self.rect.y, request.x_pos, request.y_pos) // 50
r = [
self.fuel,
distance,
request.volume,
request.last_collection,
request.is_paid,
request.odour_intensity,
request.weight,
request.type
]
if self.clf.predict([r]) == True:
self.request_list.pop(i)
self.free_space -= request.volume
self.weight_capacity -= request.weight
return request.x_pos, request.y_pos
return self.dump_x, self.dump_y
def collect(self):
if self.rect.x == self.dump_x and self.rect.y == self.dump_y:
self.fuel = MAX_FUEL
self.free_space = MAX_SPACE
self.weight_capacity = MAX_WEIGHT
print(f'agent at ({self.rect.x}, {self.rect.y}); fuel: {self.fuel}; free space: {self.free_space}; weight capacity: {self.weight_capacity}')
pass

View File

@ -1,4 +0,0 @@
class Home:
def __init__(self, coord):
self.coord = coord
self.collect_request = False

View File

@ -1,8 +0,0 @@
class Litter:
types = ['PAPER', 'GLASS', 'PLASTIC', 'METAL', 'BIO', 'MUNICIPAL', 'ELECTRONICS']
def __init__(self, type, volume, mass):
self.type = type
self.volume = volume
self.mass = mass

72
main.py
View File

@ -1,10 +1,13 @@
import pygame
import random
from treelearn import treelearn
from astar import astar
from state import State
import time
from garbage_truck import GarbageTruck
from heuristicfn import heuristicfn
from map import randomize_map
pygame.init()
WIDTH, HEIGHT = 800, 800
@ -12,52 +15,12 @@ window = pygame.display.set_mode((WIDTH, HEIGHT))
pygame.display.set_caption("Intelligent Garbage Collector")
AGENT_IMG = pygame.image.load("garbage-truck-nbg.png")
AGENT = pygame.transform.scale(AGENT_IMG, (50, 50))
DIRT_IMG = pygame.image.load("dirt.jpg")
DIRT = pygame.transform.scale(DIRT_IMG, (50, 50))
GRASS_IMG = pygame.image.load("grass.png")
GRASS = pygame.transform.scale(GRASS_IMG, (50, 50))
SAND_IMG = pygame.image.load("sand.jpeg")
SAND = pygame.transform.scale(SAND_IMG, (50, 50))
COBBLE_IMG = pygame.image.load("cobble.jpeg")
COBBLE = pygame.transform.scale(COBBLE_IMG, (50, 50))
FPS = 10
FIELDCOUNT = 16
FIELDWIDTH = 50
class Agent:
def __init__(self, rect, direction):
self.rect = rect
self.direction = direction
def randomize_map(): # tworzenie mapy z losowymi polami
field_array_1 = []
field_array_2 = []
field_priority = []
for i in range(16):
temp_priority = []
for j in range(16):
if i in (0, 1) and j in (0, 1):
field_array_2.append(GRASS)
temp_priority.append(1)
else:
prob = random.uniform(0, 100)
if 0 <= prob <= 12:
field_array_2.append(COBBLE)
temp_priority.append(3)
elif 12 < prob <= 24:
field_array_2.append(SAND)
temp_priority.append(2)
else:
field_array_2.append(GRASS)
temp_priority.append(1)
field_array_1.append(field_array_2)
field_array_2 = []
field_priority.append(temp_priority)
return field_array_1, field_priority
GRASS_IMG = pygame.image.load("grass.png")
GRASS = pygame.transform.scale(GRASS_IMG, (50, 50))
def draw_window(agent, fields, flip):
if flip:
direction = pygame.transform.flip(AGENT, True, False)
@ -71,21 +34,22 @@ def draw_window(agent, fields, flip):
def main():
clf = treelearn()
clock = pygame.time.Clock()
run = True
x, y = [0, 0]
agent = GarbageTruck(0, 0, pygame.Rect(x, y, 50, 50), 0) # tworzenie pola dla agenta
fields, priority_array = randomize_map()
print(priority_array)
final_x, final_y = [100, 300]
fields, priority_array, request_list = randomize_map()
agent = GarbageTruck(0, 0, pygame.Rect(0, 0, 50, 50), 0, request_list, clf) # tworzenie pola dla agenta
while run:
clock.tick(FPS)
for event in pygame.event.get():
if event.type == pygame.QUIT:
run = False
# keys_pressed = pygame.key.get_pressed()
draw_window(agent, fields, False) # false = kierunek east (domyslny), true = west
steps = astar(State(None, None, x, y, 'E', priority_array[0][0], heuristicfn(x, y, final_x, final_y)), final_x, final_y, priority_array)
x, y = agent.next_destination()
if x == agent.rect.x and y == agent.rect.y:
print('out of jobs')
break
steps = astar(State(None, None, agent.rect.x, agent.rect.y, agent.orientation, priority_array[agent.rect.x//50][agent.rect.y//50], heuristicfn(agent.rect.x, agent.rect.y, x, y)), x, y, priority_array)
for interm in steps:
if interm.action == 'LEFT':
agent.turn_left()
@ -101,10 +65,12 @@ def main():
draw_window(agent, fields, True)
else:
draw_window(agent, fields, False)
time.sleep(0.5)
time.sleep(0.3)
agent.collect()
fields[agent.rect.x//50][agent.rect.y//50] = GRASS
priority_array[agent.rect.x//50][agent.rect.y//50] = 1
time.sleep(0.5)
while True:
pass
pygame.quit()

44
map.py Normal file
View File

@ -0,0 +1,44 @@
import pygame, random
from request import Request
DIRT_IMG = pygame.image.load("dirt.jpg")
DIRT = pygame.transform.scale(DIRT_IMG, (50, 50))
GRASS_IMG = pygame.image.load("grass.png")
GRASS = pygame.transform.scale(GRASS_IMG, (50, 50))
SAND_IMG = pygame.image.load("sand.jpeg")
SAND = pygame.transform.scale(SAND_IMG, (50, 50))
COBBLE_IMG = pygame.image.load("cobble.jpeg")
COBBLE = pygame.transform.scale(COBBLE_IMG, (50, 50))
def randomize_map(): # tworzenie mapy z losowymi polami
request_list = []
field_array_1 = []
field_array_2 = []
field_priority = []
for i in range(16):
temp_priority = []
for j in range(16):
if i in (0, 1) and j in (0, 1):
field_array_2.append(GRASS)
temp_priority.append(1)
else:
prob = random.uniform(0, 100)
if 0 <= prob <= 12:
field_array_2.append(COBBLE)
temp_priority.append(100)
request_list.append(Request(
i*50,j*50, #lokacja
random.randint(0,3), #typ śmieci
random.random(), #objętość śmieci
random.randint(0,30), #ostatni odbiór
random.randint(0,1), #czy opłacone w terminie
random.random() * 10, #intensywność odoru
random.random() * 50 #waga śmieci
))
else:
field_array_2.append(GRASS)
temp_priority.append(1)
field_array_1.append(field_array_2)
field_array_2 = []
field_priority.append(temp_priority)
return field_array_1, field_priority, request_list

13
request.py Normal file
View File

@ -0,0 +1,13 @@
from dataclasses import dataclass
@dataclass
class Request:
def __init__(self, x_pos, y_pos, type, volume, last_collection, is_paid, odour_intensity, weight):
self.x_pos = x_pos
self.y_pos = y_pos
self.type = type
self.volume = volume
self.last_collection = last_collection
self.is_paid = is_paid
self.odour_intensity = odour_intensity
self.weight = weight

32
succ.py
View File

@ -5,27 +5,27 @@ FIELDWIDTH, FIELDCOUNT = 50, 16
def succ(st: State, passedPriorities, goalx, goaly):
successors = []
if st.orientation == 'N':
successors.append(State(st, 'LEFT', st.xpos, st.ypos, 'W', passedPriorities[st.xpos//50][st.ypos//50], heuristicfn(st.xpos, st.ypos, goalx, goaly)))
successors.append(State(st, 'RIGHT', st.xpos, st.ypos, 'E', passedPriorities[st.xpos//50][st.ypos//50], heuristicfn(st.xpos, st.ypos, goalx, goaly)))
if st.orientation == 3:
successors.append(State(st, 'LEFT', st.xpos, st.ypos, 2, passedPriorities[st.xpos//50][st.ypos//50], heuristicfn(st.xpos, st.ypos, goalx, goaly)))
successors.append(State(st, 'RIGHT', st.xpos, st.ypos, 0, passedPriorities[st.xpos//50][st.ypos//50], heuristicfn(st.xpos, st.ypos, goalx, goaly)))
if st.ypos > 0:
successors.append(State(st, 'FORWARD', st.xpos, st.ypos - FIELDWIDTH , 'N', passedPriorities[st.xpos//50][st.ypos//50], heuristicfn(st.xpos, st.ypos, goalx, goaly)))
successors.append(State(st, 'FORWARD', st.xpos, st.ypos - FIELDWIDTH , 3, passedPriorities[st.xpos//50][st.ypos//50 - 1], heuristicfn(st.xpos, st.ypos - 50, goalx, goaly)))
if st.orientation == 'S':
successors.append(State(st, 'LEFT', st.xpos, st.ypos, 'E', passedPriorities[st.xpos//50][st.ypos//50], heuristicfn(st.xpos, st.ypos, goalx, goaly)))
successors.append(State(st,'RIGHT', st.xpos, st.ypos, 'W', passedPriorities[st.xpos//50][st.ypos//50], heuristicfn(st.xpos, st.ypos, goalx, goaly)))
if st.orientation == 1:
successors.append(State(st, 'LEFT', st.xpos, st.ypos, 0, passedPriorities[st.xpos//50][st.ypos//50], heuristicfn(st.xpos, st.ypos, goalx, goaly)))
successors.append(State(st,'RIGHT', st.xpos, st.ypos, 2, passedPriorities[st.xpos//50][st.ypos//50], heuristicfn(st.xpos, st.ypos, goalx, goaly)))
if st.ypos < FIELDWIDTH * (FIELDCOUNT - 1):
successors.append(State(st, 'FORWARD', st.xpos, st.ypos + FIELDWIDTH , 'S', passedPriorities[st.xpos//50][st.ypos//50], heuristicfn(st.xpos, st.ypos, goalx, goaly)))
successors.append(State(st, 'FORWARD', st.xpos, st.ypos + FIELDWIDTH , 1, passedPriorities[st.xpos//50][st.ypos//50 + 1], heuristicfn(st.xpos, st.ypos + 50, goalx, goaly)))
if st.orientation == 'W':
successors.append(State(st, 'LEFT', st.xpos, st.ypos, 'S', passedPriorities[st.xpos//50][st.ypos//50], heuristicfn(st.xpos, st.ypos, goalx, goaly)))
successors.append(State(st,'RIGHT', st.xpos, st.ypos, 'N', passedPriorities[st.xpos//50][st.ypos//50], heuristicfn(st.xpos, st.ypos, goalx, goaly)))
if st.orientation == 2:
successors.append(State(st, 'LEFT', st.xpos, st.ypos, 1, passedPriorities[st.xpos//50][st.ypos//50], heuristicfn(st.xpos, st.ypos, goalx, goaly)))
successors.append(State(st,'RIGHT', st.xpos, st.ypos, 3, passedPriorities[st.xpos//50][st.ypos//50], heuristicfn(st.xpos, st.ypos, goalx, goaly)))
if st.xpos > 0:
successors.append(State(st, 'FORWARD', st.xpos - FIELDWIDTH , st.ypos, 'W', passedPriorities[st.xpos//50][st.ypos//50], heuristicfn(st.xpos, st.ypos, goalx, goaly)))
successors.append(State(st, 'FORWARD', st.xpos - FIELDWIDTH , st.ypos, 2, passedPriorities[st.xpos//50 - 1][st.ypos//50], heuristicfn(st.xpos - 50, st.ypos, goalx, goaly)))
if st.orientation == 'E':
successors.append(State(st, 'LEFT', st.xpos, st.ypos, 'N', passedPriorities[st.xpos//50][st.ypos//50], heuristicfn(st.xpos, st.ypos, goalx, goaly)))
successors.append(State(st, 'RIGHT', st.xpos, st.ypos, 'S', passedPriorities[st.xpos//50][st.ypos//50], heuristicfn(st.xpos, st.ypos, goalx, goaly)))
if st.orientation == 0:
successors.append(State(st, 'LEFT', st.xpos, st.ypos, 3, passedPriorities[st.xpos//50][st.ypos//50], heuristicfn(st.xpos, st.ypos, goalx, goaly)))
successors.append(State(st, 'RIGHT', st.xpos, st.ypos, 1, passedPriorities[st.xpos//50][st.ypos//50], heuristicfn(st.xpos, st.ypos, goalx, goaly)))
if st.xpos < FIELDWIDTH * (FIELDCOUNT - 1):
successors.append(State(st, 'FORWARD', st.xpos + FIELDWIDTH , st.ypos, 'E', passedPriorities[st.xpos//50][st.ypos//50], heuristicfn(st.xpos, st.ypos, goalx, goaly)))
successors.append(State(st, 'FORWARD', st.xpos + FIELDWIDTH , st.ypos, 0, passedPriorities[st.xpos//50 + 1][st.ypos//50], heuristicfn(st.xpos + 50, st.ypos, goalx, goaly)))
return successors

20
treelearn.py Normal file
View File

@ -0,0 +1,20 @@
import pandas as pd
from sklearn import tree
from sklearn.preprocessing import LabelEncoder
import graphviz
def treelearn():
train_data = pd.read_csv('./data_set.csv')
attributes = train_data.drop('collect', axis='columns')
e_type = LabelEncoder()
attributes['type_num'] = e_type.fit_transform(attributes['garbage_type'])
attr_encoded = attributes.drop(['garbage_type'], axis='columns')
attr_names = ['fuel','distance','space_occupied','days_since_last_collection','paid_on_time','odour_intensity','garbage_weight', 'garbage_type']
label_names = ['collect', 'no-collect']
label = train_data['collect']
classifier = tree.DecisionTreeClassifier()
classifier.fit(attr_encoded.values, label)
dot_data = tree.export_graphviz(classifier, out_file=None, feature_names=attr_names, class_names=label_names)
graph = graphviz.Source(dot_data)
graph.render('collect')
return classifier