├── .gitignore
├── 50种群500代
├── 65
│ ├── Figure_1.png
│ ├── Result.txt
│ └── Result
│ │ ├── Chrom.csv
│ │ ├── Encoding.txt
│ │ ├── Field.csv
│ │ ├── FitnV.csv
│ │ ├── ObjV.csv
│ │ └── Phen.csv
├── 130
│ ├── Figure_1.png
│ ├── Result.txt
│ └── Result
│ │ ├── Chrom.csv
│ │ ├── Encoding.txt
│ │ ├── Field.csv
│ │ ├── FitnV.csv
│ │ ├── ObjV.csv
│ │ └── Phen.csv
└── 180
│ ├── Figure_1.png
│ ├── Result.txt
│ └── Result
│ ├── Chrom.csv
│ ├── Encoding.txt
│ ├── Field.csv
│ ├── FitnV.csv
│ ├── ObjV.csv
│ └── Phen.csv
├── LICENSE
├── MyProblem.py
├── README.md
├── Reference
├── User-Equilibrium-Solution-master
│ ├── LICENSE
│ ├── README.md
│ ├── __pycache__
│ │ ├── data.cpython-36.pyc
│ │ ├── graph.cpython-36.pyc
│ │ └── model.cpython-36.pyc
│ ├── data.py
│ ├── graph.py
│ ├── main.py
│ ├── model.py
│ └── static
│ │ ├── NETWORK.png
│ │ └── user-equilibrium-solution.pdf
└── t-f-algorithm
│ ├── LICENSE
│ ├── README.md
│ ├── __pycache__
│ ├── data.cpython-36.pyc
│ ├── data.cpython-37.pyc
│ ├── graph.cpython-36.pyc
│ ├── graph.cpython-37.pyc
│ ├── model.cpython-36.pyc
│ └── model.cpython-37.pyc
│ ├── data.py
│ ├── graph.py
│ ├── main.py
│ ├── model.py
│ └── static
│ ├── NETWORK.png
│ └── user-equilibrium-solution.pdf
├── __pycache__
├── MyProblem.cpython-37.pyc
├── graph.cpython-37.pyc
└── model.cpython-37.pyc
├── graph.py
├── main.py
├── model.py
├── new-2019-2020(2)拥挤网络管理与设计课程报告评分标准.pdf
├── 拥挤网络课程报告.assets
├── Figure_130.png
├── Figure_180.png
├── Figure_65.png
├── image-20200627232335128.png
├── image-20200701234939688.png
├── image-20200701235619548.png
└── image-20200702003840303.png
├── 拥挤网络课程报告.md
└── 拥挤网络课程报告.pdf
/.gitignore:
--------------------------------------------------------------------------------
1 | __pycache__
2 | referenceObjV
3 | result\ of\ job\ *
--------------------------------------------------------------------------------
/50种群500代/130/Figure_1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/qizidog/Traffic-Network-Design/958dd68126647056adf2933cf2328c326088e14b/50种群500代/130/Figure_1.png
--------------------------------------------------------------------------------
/50种群500代/130/Result.txt:
--------------------------------------------------------------------------------
1 | 最优的目标函数值为:1979.5645854751467
2 | 最优的决策变量值为:
3 | 变量x1: 2.89969985502791
4 | 变量x2: 2.6063993428865064
5 | 变量x3: 7.603945408667285e-05
6 | 变量x4: 2.1251041382878366
7 | 变量x5: 2.4298952032718164
8 | 有效进化代数:500
9 | 最优的一代是第 483 代
10 | 评价次数:25000
11 | 时间已过 9817.870633363724 秒
--------------------------------------------------------------------------------
/50种群500代/130/Result/Chrom.csv:
--------------------------------------------------------------------------------
1 | 2.899729311464934511e+00,2.606447157095935996e+00,1.149595749673382075e-04,2.125147759109290657e+00,2.430017254756538847e+00
2 | 2.899702918188468814e+00,2.606424960019241510e+00,3.052053879030986556e-05,2.125133739943704470e+00,2.429989132225781390e+00
3 | 2.899732606447472882e+00,2.606483346115154198e+00,6.206363148976757368e-05,2.125082423687524980e+00,2.429948301004442257e+00
4 | 2.899757693251471924e+00,2.606410084167704699e+00,4.216175209528140347e-05,2.125044780960192004e+00,2.429745350526526515e+00
5 | 2.899752365560182010e+00,2.606442385725051381e+00,1.461963995973817893e-04,2.125170670000779527e+00,2.429983246078122328e+00
6 | 2.899691061596632480e+00,2.606395144545823772e+00,8.795829780484434315e-05,2.125231130406980196e+00,2.430117396557322174e+00
7 | 2.899642844608126158e+00,2.606364703562206842e+00,8.322307322294284502e-05,2.125073528464886508e+00,2.429841399707876270e+00
8 | 2.899737695562609296e+00,2.606469227424883073e+00,1.040079603803343222e-05,2.125132575889929321e+00,2.430013900617189471e+00
9 | 2.899768598676166320e+00,2.606450256817841815e+00,9.645182197202961400e-05,2.125080082295342621e+00,2.429812581030583729e+00
10 | 2.899671231148301054e+00,2.606368037211875155e+00,1.450361090961837455e-04,2.125115636711337519e+00,2.429909486608320179e+00
11 | 2.899746379686192199e+00,2.606446256589619814e+00,1.439983346313862393e-04,2.125110726113827120e+00,2.429891962452305876e+00
12 | 2.899644360788253827e+00,2.606370050536527039e+00,1.512387981071979968e-05,2.125114513730881782e+00,2.429981167326236591e+00
13 | 2.899748025978446719e+00,2.606462720805127198e+00,1.374691168228320151e-04,2.125133532397238234e+00,2.429904749957184418e+00
14 | 2.899681133857570536e+00,2.606416331597537273e+00,0.000000000000000000e+00,2.125089995900843576e+00,2.429880564899091766e+00
15 | 2.899765609336308891e+00,2.606467311774963491e+00,3.800496530184661848e-05,2.125177366760540032e+00,2.429959349112175815e+00
16 | 2.899637469033880421e+00,2.606379476176254428e+00,4.799005863934818501e-06,2.125073506301851545e+00,2.429845345017416669e+00
17 | 2.899701238939549341e+00,2.606449063692426904e+00,1.178728652279376489e-04,2.125102216632129171e+00,2.429874264210540424e+00
18 | 2.899674171313607829e+00,2.606402155658365416e+00,1.759165956096886863e-04,2.125198370640638323e+00,2.430124581864447908e+00
19 | 2.899611779064019679e+00,2.606342153350133195e+00,1.313717337975594179e-04,2.125088368257196159e+00,2.429860700412093788e+00
20 | 2.899695213997413923e+00,2.606396841315386403e+00,1.007501337971377666e-04,2.125129859453319892e+00,2.429974865010128937e+00
21 | 2.899678792380808723e+00,2.606415066975956041e+00,1.521733258736262823e-04,2.125143727449819941e+00,2.430040632585401816e+00
22 | 2.899786826987696298e+00,2.606499358834099667e+00,4.271578737707750568e-05,2.125095261924242696e+00,2.430139275325056580e+00
23 | 2.899611435264106696e+00,2.606340144854448315e+00,7.904831110666005244e-05,2.125048263887167277e+00,2.429896938739999790e+00
24 | 2.899730683232582429e+00,2.606477433898754192e+00,1.587004843948080731e-04,2.125131891354028912e+00,2.429993679798847062e+00
25 | 2.899699855027909834e+00,2.606399342886506432e+00,7.603945408667285317e-05,2.125104138287836619e+00,2.429895203271816406e+00
26 | 2.899728550064536670e+00,2.606449963819877702e+00,1.098416290658401842e-04,2.125086716312812651e+00,2.429912868539089388e+00
27 | 2.899700390413795237e+00,2.606477789235780218e+00,1.366955031568459862e-04,2.125124995444725773e+00,2.430050044961273858e+00
28 | 2.899679100169412660e+00,2.606396248106450653e+00,1.423616704086091891e-04,2.125120611841626594e+00,2.429927586436485765e+00
29 | 2.899736464462026486e+00,2.606432702922645284e+00,1.725372402770559337e-04,2.125024908639811194e+00,2.429788007477804879e+00
30 | 2.899747948294846278e+00,2.606456427855815328e+00,0.000000000000000000e+00,2.125146787398918491e+00,2.429978684637814190e+00
31 | 2.899734778697627746e+00,2.606433989043686505e+00,1.878188879242941186e-04,2.125129329658514976e+00,2.429995005963321741e+00
32 | 2.899667847461756764e+00,2.606443890666356289e+00,0.000000000000000000e+00,2.125110299902852162e+00,2.430068247405116288e+00
33 | 2.899592649442271242e+00,2.606312981230178405e+00,1.363343536634989580e-04,2.125091303243944907e+00,2.429951665463028210e+00
34 | 2.899698860488935992e+00,2.606417034150962042e+00,3.907076611755417911e-05,2.125048730373652717e+00,2.429817881021064885e+00
35 | 2.899737426086042902e+00,2.606461429277434849e+00,1.908104142277895722e-04,2.125012431181428685e+00,2.429817190359557344e+00
36 | 2.899790822120583922e+00,2.606505095780746295e+00,1.102009511220076185e-04,2.125189094057910122e+00,2.430091497282308666e+00
37 | 2.899698706594634245e+00,2.606392937982585423e+00,2.040567765266189523e-04,2.125014724646995035e+00,2.429836588821526533e+00
38 | 2.899620949799266878e+00,2.606383289020038685e+00,1.201647609358072813e-04,2.125144005939753278e+00,2.430034207950211300e+00
39 | 2.899773979698452298e+00,2.606415867078337723e+00,5.120894578188625416e-05,2.125050715918533228e+00,2.429951591574075032e+00
40 | 2.899721987967518011e+00,2.606434843953019609e+00,4.573725912323116550e-05,2.125152069258694709e+00,2.429987452292484917e+00
41 | 2.899730490615090694e+00,2.606472186128684587e+00,1.222088474276770823e-04,2.125121812376812080e+00,2.429944307546851867e+00
42 | 2.899738916758591412e+00,2.606454126291398943e+00,4.433126238133994147e-05,2.125141574445690296e+00,2.430042402675616664e+00
43 | 2.899724396539707705e+00,2.606448178705480068e+00,1.078803701196115309e-04,2.125079027479025662e+00,2.429974109430505624e+00
44 | 2.899778488438287560e+00,2.606489196486805326e+00,2.558835533148410172e-05,2.125180844842594396e+00,2.430074064403697331e+00
45 | 2.899704188904214774e+00,2.606432770611971428e+00,0.000000000000000000e+00,2.125104896293617429e+00,2.429923934530535234e+00
46 | 2.899744461814465879e+00,2.606435559833984783e+00,1.925746447518276549e-04,2.125152926874851467e+00,2.429964651586356439e+00
47 | 2.899788998404739360e+00,2.606494197564262372e+00,0.000000000000000000e+00,2.125200615379417179e+00,2.430094183643672245e+00
48 | 2.899705069275968938e+00,2.606416283432650083e+00,5.869850065387993872e-05,2.125080354799790072e+00,2.429934795547735948e+00
49 | 2.899822663533254463e+00,2.606529079175230024e+00,8.866252476267988294e-05,2.125210641481968477e+00,2.430109940341104391e+00
50 | 2.899725620284540728e+00,2.606410156114809418e+00,1.418091477903028470e-04,2.125203650340402817e+00,2.429989407968034421e+00
51 |
--------------------------------------------------------------------------------
/50种群500代/130/Result/Encoding.txt:
--------------------------------------------------------------------------------
1 | RI
--------------------------------------------------------------------------------
/50种群500代/130/Result/Field.csv:
--------------------------------------------------------------------------------
1 | 0.000000000000000000e+00,0.000000000000000000e+00,0.000000000000000000e+00,0.000000000000000000e+00,0.000000000000000000e+00
2 | 8.000000000000000000e+00,8.000000000000000000e+00,8.000000000000000000e+00,8.000000000000000000e+00,8.000000000000000000e+00
3 | 0.000000000000000000e+00,0.000000000000000000e+00,0.000000000000000000e+00,0.000000000000000000e+00,0.000000000000000000e+00
4 |
--------------------------------------------------------------------------------
/50种群500代/130/Result/FitnV.csv:
--------------------------------------------------------------------------------
1 | 3.444851472522714175e-06
2 | 3.534113830028218217e-06
3 | 3.534355528245214373e-06
4 | 3.576084964151959866e-06
5 | 3.128264552287873812e-06
6 | 3.307614633740740828e-06
7 | 3.877634753735037521e-06
8 | 3.261720621594577096e-06
9 | 3.448588131504948251e-06
10 | 4.015548029201454483e-06
11 | 3.705961717059835792e-06
12 | 3.567016392480581999e-06
13 | 3.393845418031560257e-06
14 | 3.864137170239700936e-06
15 | 3.501771971059497446e-06
16 | 3.767815996980061755e-06
17 | 3.570926992324530147e-06
18 | 3.572567038645502180e-06
19 | 3.240339992771623656e-06
20 | 3.072895196964964271e-06
21 | 3.312823992018820718e-06
22 | 3.748974677364458330e-06
23 | 3.657254637801088393e-06
24 | 3.803560503001790494e-06
25 | 4.348257334640948102e-06
26 | 3.228074319849838503e-06
27 | 3.359866241225972772e-06
28 | 3.353534111738554202e-06
29 | 3.506886287141242065e-06
30 | 3.437577561271609738e-06
31 | 3.517766344884876162e-06
32 | 3.544310857250820845e-06
33 | 3.176837026330758817e-06
34 | 3.386493972357129678e-06
35 | 3.542441845638677478e-06
36 | 3.138898819088353775e-06
37 | 3.633441792771918699e-06
38 | 3.410336375964106992e-06
39 | 4.323085931901005097e-06
40 | 3.228029299862100743e-06
41 | 3.583147872632252984e-06
42 | 3.563655354810180143e-06
43 | 3.622980557338451035e-06
44 | 3.320434416309581138e-06
45 | 3.070452521569677629e-06
46 | 3.468918521321029402e-06
47 | 3.632760808613966219e-06
48 | 3.395453859411645681e-06
49 | 3.455254045547917485e-06
50 | 3.467873511908692308e-06
51 |
--------------------------------------------------------------------------------
/50种群500代/130/Result/ObjV.csv:
--------------------------------------------------------------------------------
1 | 1.979564586378552576e+03
2 | 1.979564586289290219e+03
3 | 1.979564586289048520e+03
4 | 1.979564586247319085e+03
5 | 1.979564586695139496e+03
6 | 1.979564586515789415e+03
7 | 1.979564585945769295e+03
8 | 1.979564586561683427e+03
9 | 1.979564586374815917e+03
10 | 1.979564585807856020e+03
11 | 1.979564586117442332e+03
12 | 1.979564586256387656e+03
13 | 1.979564586429558631e+03
14 | 1.979564585959266878e+03
15 | 1.979564586321632078e+03
16 | 1.979564586055588052e+03
17 | 1.979564586252477056e+03
18 | 1.979564586250837010e+03
19 | 1.979564586583064056e+03
20 | 1.979564586750508852e+03
21 | 1.979564586510580057e+03
22 | 1.979564586074429371e+03
23 | 1.979564586166149411e+03
24 | 1.979564586019843546e+03
25 | 1.979564585475146714e+03
26 | 1.979564586595329729e+03
27 | 1.979564586463537808e+03
28 | 1.979564586469869937e+03
29 | 1.979564586316517762e+03
30 | 1.979564586385826487e+03
31 | 1.979564586305637704e+03
32 | 1.979564586279093191e+03
33 | 1.979564586646567022e+03
34 | 1.979564586436910076e+03
35 | 1.979564586280962203e+03
36 | 1.979564586684505230e+03
37 | 1.979564586189962256e+03
38 | 1.979564586413067673e+03
39 | 1.979564585500318117e+03
40 | 1.979564586595374749e+03
41 | 1.979564586240256176e+03
42 | 1.979564586259748694e+03
43 | 1.979564586200423491e+03
44 | 1.979564586502969632e+03
45 | 1.979564586752951527e+03
46 | 1.979564586354485527e+03
47 | 1.979564586190643240e+03
48 | 1.979564586427950189e+03
49 | 1.979564586368150003e+03
50 | 1.979564586355530537e+03
51 |
--------------------------------------------------------------------------------
/50种群500代/130/Result/Phen.csv:
--------------------------------------------------------------------------------
1 | 2.899729311464934511e+00,2.606447157095935996e+00,1.149595749673382075e-04,2.125147759109290657e+00,2.430017254756538847e+00
2 | 2.899702918188468814e+00,2.606424960019241510e+00,3.052053879030986556e-05,2.125133739943704470e+00,2.429989132225781390e+00
3 | 2.899732606447472882e+00,2.606483346115154198e+00,6.206363148976757368e-05,2.125082423687524980e+00,2.429948301004442257e+00
4 | 2.899757693251471924e+00,2.606410084167704699e+00,4.216175209528140347e-05,2.125044780960192004e+00,2.429745350526526515e+00
5 | 2.899752365560182010e+00,2.606442385725051381e+00,1.461963995973817893e-04,2.125170670000779527e+00,2.429983246078122328e+00
6 | 2.899691061596632480e+00,2.606395144545823772e+00,8.795829780484434315e-05,2.125231130406980196e+00,2.430117396557322174e+00
7 | 2.899642844608126158e+00,2.606364703562206842e+00,8.322307322294284502e-05,2.125073528464886508e+00,2.429841399707876270e+00
8 | 2.899737695562609296e+00,2.606469227424883073e+00,1.040079603803343222e-05,2.125132575889929321e+00,2.430013900617189471e+00
9 | 2.899768598676166320e+00,2.606450256817841815e+00,9.645182197202961400e-05,2.125080082295342621e+00,2.429812581030583729e+00
10 | 2.899671231148301054e+00,2.606368037211875155e+00,1.450361090961837455e-04,2.125115636711337519e+00,2.429909486608320179e+00
11 | 2.899746379686192199e+00,2.606446256589619814e+00,1.439983346313862393e-04,2.125110726113827120e+00,2.429891962452305876e+00
12 | 2.899644360788253827e+00,2.606370050536527039e+00,1.512387981071979968e-05,2.125114513730881782e+00,2.429981167326236591e+00
13 | 2.899748025978446719e+00,2.606462720805127198e+00,1.374691168228320151e-04,2.125133532397238234e+00,2.429904749957184418e+00
14 | 2.899681133857570536e+00,2.606416331597537273e+00,0.000000000000000000e+00,2.125089995900843576e+00,2.429880564899091766e+00
15 | 2.899765609336308891e+00,2.606467311774963491e+00,3.800496530184661848e-05,2.125177366760540032e+00,2.429959349112175815e+00
16 | 2.899637469033880421e+00,2.606379476176254428e+00,4.799005863934818501e-06,2.125073506301851545e+00,2.429845345017416669e+00
17 | 2.899701238939549341e+00,2.606449063692426904e+00,1.178728652279376489e-04,2.125102216632129171e+00,2.429874264210540424e+00
18 | 2.899674171313607829e+00,2.606402155658365416e+00,1.759165956096886863e-04,2.125198370640638323e+00,2.430124581864447908e+00
19 | 2.899611779064019679e+00,2.606342153350133195e+00,1.313717337975594179e-04,2.125088368257196159e+00,2.429860700412093788e+00
20 | 2.899695213997413923e+00,2.606396841315386403e+00,1.007501337971377666e-04,2.125129859453319892e+00,2.429974865010128937e+00
21 | 2.899678792380808723e+00,2.606415066975956041e+00,1.521733258736262823e-04,2.125143727449819941e+00,2.430040632585401816e+00
22 | 2.899786826987696298e+00,2.606499358834099667e+00,4.271578737707750568e-05,2.125095261924242696e+00,2.430139275325056580e+00
23 | 2.899611435264106696e+00,2.606340144854448315e+00,7.904831110666005244e-05,2.125048263887167277e+00,2.429896938739999790e+00
24 | 2.899730683232582429e+00,2.606477433898754192e+00,1.587004843948080731e-04,2.125131891354028912e+00,2.429993679798847062e+00
25 | 2.899699855027909834e+00,2.606399342886506432e+00,7.603945408667285317e-05,2.125104138287836619e+00,2.429895203271816406e+00
26 | 2.899728550064536670e+00,2.606449963819877702e+00,1.098416290658401842e-04,2.125086716312812651e+00,2.429912868539089388e+00
27 | 2.899700390413795237e+00,2.606477789235780218e+00,1.366955031568459862e-04,2.125124995444725773e+00,2.430050044961273858e+00
28 | 2.899679100169412660e+00,2.606396248106450653e+00,1.423616704086091891e-04,2.125120611841626594e+00,2.429927586436485765e+00
29 | 2.899736464462026486e+00,2.606432702922645284e+00,1.725372402770559337e-04,2.125024908639811194e+00,2.429788007477804879e+00
30 | 2.899747948294846278e+00,2.606456427855815328e+00,0.000000000000000000e+00,2.125146787398918491e+00,2.429978684637814190e+00
31 | 2.899734778697627746e+00,2.606433989043686505e+00,1.878188879242941186e-04,2.125129329658514976e+00,2.429995005963321741e+00
32 | 2.899667847461756764e+00,2.606443890666356289e+00,0.000000000000000000e+00,2.125110299902852162e+00,2.430068247405116288e+00
33 | 2.899592649442271242e+00,2.606312981230178405e+00,1.363343536634989580e-04,2.125091303243944907e+00,2.429951665463028210e+00
34 | 2.899698860488935992e+00,2.606417034150962042e+00,3.907076611755417911e-05,2.125048730373652717e+00,2.429817881021064885e+00
35 | 2.899737426086042902e+00,2.606461429277434849e+00,1.908104142277895722e-04,2.125012431181428685e+00,2.429817190359557344e+00
36 | 2.899790822120583922e+00,2.606505095780746295e+00,1.102009511220076185e-04,2.125189094057910122e+00,2.430091497282308666e+00
37 | 2.899698706594634245e+00,2.606392937982585423e+00,2.040567765266189523e-04,2.125014724646995035e+00,2.429836588821526533e+00
38 | 2.899620949799266878e+00,2.606383289020038685e+00,1.201647609358072813e-04,2.125144005939753278e+00,2.430034207950211300e+00
39 | 2.899773979698452298e+00,2.606415867078337723e+00,5.120894578188625416e-05,2.125050715918533228e+00,2.429951591574075032e+00
40 | 2.899721987967518011e+00,2.606434843953019609e+00,4.573725912323116550e-05,2.125152069258694709e+00,2.429987452292484917e+00
41 | 2.899730490615090694e+00,2.606472186128684587e+00,1.222088474276770823e-04,2.125121812376812080e+00,2.429944307546851867e+00
42 | 2.899738916758591412e+00,2.606454126291398943e+00,4.433126238133994147e-05,2.125141574445690296e+00,2.430042402675616664e+00
43 | 2.899724396539707705e+00,2.606448178705480068e+00,1.078803701196115309e-04,2.125079027479025662e+00,2.429974109430505624e+00
44 | 2.899778488438287560e+00,2.606489196486805326e+00,2.558835533148410172e-05,2.125180844842594396e+00,2.430074064403697331e+00
45 | 2.899704188904214774e+00,2.606432770611971428e+00,0.000000000000000000e+00,2.125104896293617429e+00,2.429923934530535234e+00
46 | 2.899744461814465879e+00,2.606435559833984783e+00,1.925746447518276549e-04,2.125152926874851467e+00,2.429964651586356439e+00
47 | 2.899788998404739360e+00,2.606494197564262372e+00,0.000000000000000000e+00,2.125200615379417179e+00,2.430094183643672245e+00
48 | 2.899705069275968938e+00,2.606416283432650083e+00,5.869850065387993872e-05,2.125080354799790072e+00,2.429934795547735948e+00
49 | 2.899822663533254463e+00,2.606529079175230024e+00,8.866252476267988294e-05,2.125210641481968477e+00,2.430109940341104391e+00
50 | 2.899725620284540728e+00,2.606410156114809418e+00,1.418091477903028470e-04,2.125203650340402817e+00,2.429989407968034421e+00
51 |
--------------------------------------------------------------------------------
/50种群500代/180/Figure_1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/qizidog/Traffic-Network-Design/958dd68126647056adf2933cf2328c326088e14b/50种群500代/180/Figure_1.png
--------------------------------------------------------------------------------
/50种群500代/180/Result.txt:
--------------------------------------------------------------------------------
1 | 当前迭代代数:499
2 | 种群信息导出完毕。
3 | 最优的目标函数值为:4775.4702271634505
4 | 最优的决策变量值为:
5 | 变量x1: 7.999999814961814
6 | 变量x2: 7.780701214656795
7 | 变量x3: 7.71030167934683e-05
8 | 变量x4: 6.563680846852126
9 | 变量x5: 7.462764028436347
10 | 有效进化代数:500
11 | 最优的一代是第 410 代
12 | 评价次数:25000
13 | 时间已过 12480.885017633438 秒
14 |
15 |
16 | # 这是新的
17 | 最优的目标函数值为:4774.570046155357
18 | 最优的决策变量值为:
19 | 变量x1: 8.482834437795695
20 | 变量x2: 7.624617126325166
21 | 变量x3: 0.00018984020303833803
22 | 变量x4: 6.543248508110582
23 | 变量x5: 7.479983772261874
24 | 有效进化代数:500
25 | 最优的一代是第 121 代
26 | 评价次数:25000
27 | 时间已过 9936.628125190735 秒
--------------------------------------------------------------------------------
/50种群500代/180/Result/Chrom.csv:
--------------------------------------------------------------------------------
1 | 8.000000000000000000e+00,7.780808117235956445e+00,2.337798208829572973e-04,6.563934779843224376e+00,7.463148602895704364e+00
2 | 8.000000000000000000e+00,7.780854321885429137e+00,6.293931080296429666e-04,6.563657357768917677e+00,7.462873382715090820e+00
3 | 7.999999865918281827e+00,7.780729670544559440e+00,2.938004478616564920e-04,6.563708004093557591e+00,7.462777949799162869e+00
4 | 7.999999928384715631e+00,7.780710817263747359e+00,5.603353688051252411e-05,6.563942694475857209e+00,7.463002444704123661e+00
5 | 7.999999916647670517e+00,7.780749822661327642e+00,1.307946661290148986e-04,6.563595041707787736e+00,7.462638736592115407e+00
6 | 8.000000000000000000e+00,7.780818406885646965e+00,5.405619998047597654e-04,6.563665319826037958e+00,7.462837010688314621e+00
7 | 7.999999968561251507e+00,7.780833198776079485e+00,4.056305581631581940e-04,6.563684526538105857e+00,7.462858859619155183e+00
8 | 7.999999935523394612e+00,7.780763951922427424e+00,1.878529847522071225e-04,6.563697504358012580e+00,7.462814943269403756e+00
9 | 7.999999959700620167e+00,7.780790569989724403e+00,2.920332661132653490e-04,6.563669646975512251e+00,7.462762960174635474e+00
10 | 7.999999951192153347e+00,7.780759660261537647e+00,3.130571109644398340e-04,6.564128479492117307e+00,7.463333913309164735e+00
11 | 8.000000000000000000e+00,7.780709790582680085e+00,8.080184976882881249e-04,6.564306486031230570e+00,7.463467514420054627e+00
12 | 8.000000000000000000e+00,7.780659773376017441e+00,3.165297517145478860e-04,6.564231485674154598e+00,7.463330183976442100e+00
13 | 7.999999885095883556e+00,7.780772294339691086e+00,0.000000000000000000e+00,6.563969751236291117e+00,7.463160263079624990e+00
14 | 8.000000000000000000e+00,7.780817188140980889e+00,3.124610738794190100e-04,6.563576525293170150e+00,7.462715572541540610e+00
15 | 7.999999964412380038e+00,7.780736419951943539e+00,4.131812287266318053e-04,6.563920472028651254e+00,7.463056595875088739e+00
16 | 8.000000000000000000e+00,7.780734446660918735e+00,3.393623905869503775e-04,6.563698897999977078e+00,7.462758703720959730e+00
17 | 7.999999892403813817e+00,7.780722754847240630e+00,2.436134722252154741e-04,6.563686353883996460e+00,7.462748168781891067e+00
18 | 7.999999975596076673e+00,7.780843847272157277e+00,2.356325140143091402e-04,6.563690332160964758e+00,7.462869558549231286e+00
19 | 7.999999993191824643e+00,7.780831361979023697e+00,4.847917345175988576e-04,6.563780874996993475e+00,7.463011947883995134e+00
20 | 7.999999983805778925e+00,7.780789786141031783e+00,1.341139352884953824e-04,6.563665254340836697e+00,7.462779943504944669e+00
21 | 8.000000000000000000e+00,7.780719396366995610e+00,3.742688708284853060e-04,6.563837400138611500e+00,7.462935425047180438e+00
22 | 8.000000000000000000e+00,7.780787720201342239e+00,5.868723414621168297e-04,6.563680049677989459e+00,7.462807761426725861e+00
23 | 7.999999880726990753e+00,7.780751276151408824e+00,0.000000000000000000e+00,6.563963738112709834e+00,7.463131117118098956e+00
24 | 8.000000000000000000e+00,7.780744154772279764e+00,4.339285937291622805e-04,6.563872701096048701e+00,7.462978429107543832e+00
25 | 7.999999875151604378e+00,7.780877437542359942e+00,1.706017505877639956e-04,6.563694483039464345e+00,7.462927706246357040e+00
26 | 7.999999988710941423e+00,7.780725799296366318e+00,3.891144330464516997e-04,6.563860162285212851e+00,7.462984964079208083e+00
27 | 8.000000000000000000e+00,7.780748149007661318e+00,2.160955414228969099e-04,6.563668752546662155e+00,7.462747257153962366e+00
28 | 7.999999936657052224e+00,7.780677318027722222e+00,3.891144330464516997e-04,6.563831502383330019e+00,7.462898784479265579e+00
29 | 7.999999978292830605e+00,7.780699170739431736e+00,1.097465007950380639e-04,6.563982681085585469e+00,7.463095574840957980e+00
30 | 7.999999834677716137e+00,7.780784117796181398e+00,2.590414904493302931e-04,6.563655152787600144e+00,7.462786956467672539e+00
31 | 7.999999937575802633e+00,7.780819278827971530e+00,7.885292101800535358e-04,6.563685390673463793e+00,7.462851214917465725e+00
32 | 7.999999907548493994e+00,7.780675826804547057e+00,2.865053829107704151e-04,6.563935880562161707e+00,7.462992173820897079e+00
33 | 7.999999951192153347e+00,7.780808571353601266e+00,1.891324062844238060e-04,6.564011532359907974e+00,7.463221349767970025e+00
34 | 7.999999833295341034e+00,7.780789087255751468e+00,0.000000000000000000e+00,6.563712519095465936e+00,7.462855321800914155e+00
35 | 7.999999953774246997e+00,7.780700563672560577e+00,4.579492454702066909e-04,6.563833162555322787e+00,7.462914095639890277e+00
36 | 7.999999948291422136e+00,7.780812360060279431e+00,3.591121081272630839e-04,6.563935182982666205e+00,7.463172906569337961e+00
37 | 7.999999988710941423e+00,7.780805137111676650e+00,4.292951204000007353e-04,6.563699152050338270e+00,7.462856731392316867e+00
38 | 8.000000000000000000e+00,7.780871617835539489e+00,4.546302455355833772e-04,6.563515379668863226e+00,7.462678959673398005e+00
39 | 8.000000000000000000e+00,7.780773795651411362e+00,7.024796548956153790e-04,6.563749273933281003e+00,7.462904086755787425e+00
40 | 8.000000000000000000e+00,7.780722502363911275e+00,0.000000000000000000e+00,6.563588231160043307e+00,7.462590427552138195e+00
41 | 8.000000000000000000e+00,7.780966231837778579e+00,1.367079346179429517e-04,6.563544521957582312e+00,7.462835923429226526e+00
42 | 8.000000000000000000e+00,7.780864747461558650e+00,9.052712942757208973e-05,6.563823099109876935e+00,7.463080176885712902e+00
43 | 7.999999951192153347e+00,7.780886049793040549e+00,0.000000000000000000e+00,6.563769838899231601e+00,7.463027681000799163e+00
44 | 7.999999942662072705e+00,7.780804190820787447e+00,4.640938222984219573e-04,6.563768410083850036e+00,7.462945725163805832e+00
45 | 7.999999814961814337e+00,7.780701214656795095e+00,7.710301679346830551e-05,6.563680846852125939e+00,7.462764028436346564e+00
46 | 8.000000000000000000e+00,7.780750176111055794e+00,4.753956274717221347e-04,6.563677461940000235e+00,7.462747813975260769e+00
47 | 7.999999986162688259e+00,7.780668649083099631e+00,3.622686351548416533e-04,6.564072533973452472e+00,7.463167466586371646e+00
48 | 7.999999950962833672e+00,7.780719565887703304e+00,1.804562476728674664e-04,6.563573664035524224e+00,7.462615470705407539e+00
49 | 7.999999814961814337e+00,7.780959308396202090e+00,1.585702935896198679e-04,6.563731315175540537e+00,7.463078446796089338e+00
50 | 7.999999924575597277e+00,7.780831265612451197e+00,3.591121081272630839e-04,6.563809573474044257e+00,7.463035008910745560e+00
51 |
--------------------------------------------------------------------------------
/50种群500代/180/Result/Encoding.txt:
--------------------------------------------------------------------------------
1 | RI
--------------------------------------------------------------------------------
/50种群500代/180/Result/Field.csv:
--------------------------------------------------------------------------------
1 | 0.000000000000000000e+00,0.000000000000000000e+00,0.000000000000000000e+00,0.000000000000000000e+00,0.000000000000000000e+00
2 | 8.000000000000000000e+00,8.000000000000000000e+00,8.000000000000000000e+00,8.000000000000000000e+00,8.000000000000000000e+00
3 | 0.000000000000000000e+00,0.000000000000000000e+00,0.000000000000000000e+00,0.000000000000000000e+00,0.000000000000000000e+00
4 |
--------------------------------------------------------------------------------
/50种群500代/180/Result/FitnV.csv:
--------------------------------------------------------------------------------
1 | 2.318352771362697240e-02
2 | 2.318405799178435700e-02
3 | 2.318317688877868932e-02
4 | 2.317920605673862156e-02
5 | 2.317996108104125597e-02
6 | 2.318567196380172390e-02
7 | 2.318273804212367395e-02
8 | 2.318339943485625554e-02
9 | 2.318204692528524902e-02
10 | 2.318086177001532633e-02
11 | 2.317682657940167701e-02
12 | 2.318228992680815281e-02
13 | 2.318366163490281906e-02
14 | 2.318282650867331540e-02
15 | 2.318519472919433611e-02
16 | 2.318371804631169653e-02
17 | 2.318136540361592779e-02
18 | 2.318244753041653894e-02
19 | 2.318602582727180561e-02
20 | 2.318287571051769191e-02
21 | 2.318273225864686538e-02
22 | 2.318322033079311950e-02
23 | 2.318108440795185743e-02
24 | 2.318413871307711815e-02
25 | 2.318119821029540617e-02
26 | 2.318178232144418871e-02
27 | 2.318017083598533645e-02
28 | 2.318640333760413341e-02
29 | 2.318290057337435428e-02
30 | 2.318307060613733483e-02
31 | 2.318290771563624730e-02
32 | 2.318249106701841811e-02
33 | 2.318187731543730479e-02
34 | 2.318257142815127736e-02
35 | 2.318481035035802051e-02
36 | 2.318356848354596877e-02
37 | 2.318240951444749953e-02
38 | 2.317892405153543223e-02
39 | 2.318660751825518673e-02
40 | 2.318375062441191403e-02
41 | 2.318155598004523199e-02
42 | 2.318206596464733593e-02
43 | 2.318225368617277127e-02
44 | 2.318579571056034183e-02
45 | 2.318867072699504206e-02
46 | 2.318297685542347608e-02
47 | 2.318415928311878815e-02
48 | 2.318439619375567418e-02
49 | 2.318160658523993334e-02
50 | 2.318333300445374334e-02
51 |
--------------------------------------------------------------------------------
/50种群500代/180/Result/ObjV.csv:
--------------------------------------------------------------------------------
1 | 4.775470232306463913e+03
2 | 4.775470231776185756e+03
3 | 4.775470232657288761e+03
4 | 4.775470236628120801e+03
5 | 4.775470235873096499e+03
6 | 4.775470230162213738e+03
7 | 4.775470233096135416e+03
8 | 4.775470232434742684e+03
9 | 4.775470233787252255e+03
10 | 4.775470234972407525e+03
11 | 4.775470239007598138e+03
12 | 4.775470233544250732e+03
13 | 4.775470232172542637e+03
14 | 4.775470233007668867e+03
15 | 4.775470230639448346e+03
16 | 4.775470232116131228e+03
17 | 4.775470234468773924e+03
18 | 4.775470233386647124e+03
19 | 4.775470229808350268e+03
20 | 4.775470232958467022e+03
21 | 4.775470233101918893e+03
22 | 4.775470232613846747e+03
23 | 4.775470234749769588e+03
24 | 4.775470231695464463e+03
25 | 4.775470234635967245e+03
26 | 4.775470234051856096e+03
27 | 4.775470235663341555e+03
28 | 4.775470229430839936e+03
29 | 4.775470232933604166e+03
30 | 4.775470232763571403e+03
31 | 4.775470232926461904e+03
32 | 4.775470233343110522e+03
33 | 4.775470233956862103e+03
34 | 4.775470233262749389e+03
35 | 4.775470231023827182e+03
36 | 4.775470232265693994e+03
37 | 4.775470233424663093e+03
38 | 4.775470236910126005e+03
39 | 4.775470229226659285e+03
40 | 4.775470232083553128e+03
41 | 4.775470234278197495e+03
42 | 4.775470233768212893e+03
43 | 4.775470233580491367e+03
44 | 4.775470230038466980e+03
45 | 4.775470227163450545e+03
46 | 4.775470232857322117e+03
47 | 4.775470231674894421e+03
48 | 4.775470231437983784e+03
49 | 4.775470234227592300e+03
50 | 4.775470232501173086e+03
51 |
--------------------------------------------------------------------------------
/50种群500代/180/Result/Phen.csv:
--------------------------------------------------------------------------------
1 | 8.000000000000000000e+00,7.780808117235956445e+00,2.337798208829572973e-04,6.563934779843224376e+00,7.463148602895704364e+00
2 | 8.000000000000000000e+00,7.780854321885429137e+00,6.293931080296429666e-04,6.563657357768917677e+00,7.462873382715090820e+00
3 | 7.999999865918281827e+00,7.780729670544559440e+00,2.938004478616564920e-04,6.563708004093557591e+00,7.462777949799162869e+00
4 | 7.999999928384715631e+00,7.780710817263747359e+00,5.603353688051252411e-05,6.563942694475857209e+00,7.463002444704123661e+00
5 | 7.999999916647670517e+00,7.780749822661327642e+00,1.307946661290148986e-04,6.563595041707787736e+00,7.462638736592115407e+00
6 | 8.000000000000000000e+00,7.780818406885646965e+00,5.405619998047597654e-04,6.563665319826037958e+00,7.462837010688314621e+00
7 | 7.999999968561251507e+00,7.780833198776079485e+00,4.056305581631581940e-04,6.563684526538105857e+00,7.462858859619155183e+00
8 | 7.999999935523394612e+00,7.780763951922427424e+00,1.878529847522071225e-04,6.563697504358012580e+00,7.462814943269403756e+00
9 | 7.999999959700620167e+00,7.780790569989724403e+00,2.920332661132653490e-04,6.563669646975512251e+00,7.462762960174635474e+00
10 | 7.999999951192153347e+00,7.780759660261537647e+00,3.130571109644398340e-04,6.564128479492117307e+00,7.463333913309164735e+00
11 | 8.000000000000000000e+00,7.780709790582680085e+00,8.080184976882881249e-04,6.564306486031230570e+00,7.463467514420054627e+00
12 | 8.000000000000000000e+00,7.780659773376017441e+00,3.165297517145478860e-04,6.564231485674154598e+00,7.463330183976442100e+00
13 | 7.999999885095883556e+00,7.780772294339691086e+00,0.000000000000000000e+00,6.563969751236291117e+00,7.463160263079624990e+00
14 | 8.000000000000000000e+00,7.780817188140980889e+00,3.124610738794190100e-04,6.563576525293170150e+00,7.462715572541540610e+00
15 | 7.999999964412380038e+00,7.780736419951943539e+00,4.131812287266318053e-04,6.563920472028651254e+00,7.463056595875088739e+00
16 | 8.000000000000000000e+00,7.780734446660918735e+00,3.393623905869503775e-04,6.563698897999977078e+00,7.462758703720959730e+00
17 | 7.999999892403813817e+00,7.780722754847240630e+00,2.436134722252154741e-04,6.563686353883996460e+00,7.462748168781891067e+00
18 | 7.999999975596076673e+00,7.780843847272157277e+00,2.356325140143091402e-04,6.563690332160964758e+00,7.462869558549231286e+00
19 | 7.999999993191824643e+00,7.780831361979023697e+00,4.847917345175988576e-04,6.563780874996993475e+00,7.463011947883995134e+00
20 | 7.999999983805778925e+00,7.780789786141031783e+00,1.341139352884953824e-04,6.563665254340836697e+00,7.462779943504944669e+00
21 | 8.000000000000000000e+00,7.780719396366995610e+00,3.742688708284853060e-04,6.563837400138611500e+00,7.462935425047180438e+00
22 | 8.000000000000000000e+00,7.780787720201342239e+00,5.868723414621168297e-04,6.563680049677989459e+00,7.462807761426725861e+00
23 | 7.999999880726990753e+00,7.780751276151408824e+00,0.000000000000000000e+00,6.563963738112709834e+00,7.463131117118098956e+00
24 | 8.000000000000000000e+00,7.780744154772279764e+00,4.339285937291622805e-04,6.563872701096048701e+00,7.462978429107543832e+00
25 | 7.999999875151604378e+00,7.780877437542359942e+00,1.706017505877639956e-04,6.563694483039464345e+00,7.462927706246357040e+00
26 | 7.999999988710941423e+00,7.780725799296366318e+00,3.891144330464516997e-04,6.563860162285212851e+00,7.462984964079208083e+00
27 | 8.000000000000000000e+00,7.780748149007661318e+00,2.160955414228969099e-04,6.563668752546662155e+00,7.462747257153962366e+00
28 | 7.999999936657052224e+00,7.780677318027722222e+00,3.891144330464516997e-04,6.563831502383330019e+00,7.462898784479265579e+00
29 | 7.999999978292830605e+00,7.780699170739431736e+00,1.097465007950380639e-04,6.563982681085585469e+00,7.463095574840957980e+00
30 | 7.999999834677716137e+00,7.780784117796181398e+00,2.590414904493302931e-04,6.563655152787600144e+00,7.462786956467672539e+00
31 | 7.999999937575802633e+00,7.780819278827971530e+00,7.885292101800535358e-04,6.563685390673463793e+00,7.462851214917465725e+00
32 | 7.999999907548493994e+00,7.780675826804547057e+00,2.865053829107704151e-04,6.563935880562161707e+00,7.462992173820897079e+00
33 | 7.999999951192153347e+00,7.780808571353601266e+00,1.891324062844238060e-04,6.564011532359907974e+00,7.463221349767970025e+00
34 | 7.999999833295341034e+00,7.780789087255751468e+00,0.000000000000000000e+00,6.563712519095465936e+00,7.462855321800914155e+00
35 | 7.999999953774246997e+00,7.780700563672560577e+00,4.579492454702066909e-04,6.563833162555322787e+00,7.462914095639890277e+00
36 | 7.999999948291422136e+00,7.780812360060279431e+00,3.591121081272630839e-04,6.563935182982666205e+00,7.463172906569337961e+00
37 | 7.999999988710941423e+00,7.780805137111676650e+00,4.292951204000007353e-04,6.563699152050338270e+00,7.462856731392316867e+00
38 | 8.000000000000000000e+00,7.780871617835539489e+00,4.546302455355833772e-04,6.563515379668863226e+00,7.462678959673398005e+00
39 | 8.000000000000000000e+00,7.780773795651411362e+00,7.024796548956153790e-04,6.563749273933281003e+00,7.462904086755787425e+00
40 | 8.000000000000000000e+00,7.780722502363911275e+00,0.000000000000000000e+00,6.563588231160043307e+00,7.462590427552138195e+00
41 | 8.000000000000000000e+00,7.780966231837778579e+00,1.367079346179429517e-04,6.563544521957582312e+00,7.462835923429226526e+00
42 | 8.000000000000000000e+00,7.780864747461558650e+00,9.052712942757208973e-05,6.563823099109876935e+00,7.463080176885712902e+00
43 | 7.999999951192153347e+00,7.780886049793040549e+00,0.000000000000000000e+00,6.563769838899231601e+00,7.463027681000799163e+00
44 | 7.999999942662072705e+00,7.780804190820787447e+00,4.640938222984219573e-04,6.563768410083850036e+00,7.462945725163805832e+00
45 | 7.999999814961814337e+00,7.780701214656795095e+00,7.710301679346830551e-05,6.563680846852125939e+00,7.462764028436346564e+00
46 | 8.000000000000000000e+00,7.780750176111055794e+00,4.753956274717221347e-04,6.563677461940000235e+00,7.462747813975260769e+00
47 | 7.999999986162688259e+00,7.780668649083099631e+00,3.622686351548416533e-04,6.564072533973452472e+00,7.463167466586371646e+00
48 | 7.999999950962833672e+00,7.780719565887703304e+00,1.804562476728674664e-04,6.563573664035524224e+00,7.462615470705407539e+00
49 | 7.999999814961814337e+00,7.780959308396202090e+00,1.585702935896198679e-04,6.563731315175540537e+00,7.463078446796089338e+00
50 | 7.999999924575597277e+00,7.780831265612451197e+00,3.591121081272630839e-04,6.563809573474044257e+00,7.463035008910745560e+00
51 |
--------------------------------------------------------------------------------
/50种群500代/65/Figure_1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/qizidog/Traffic-Network-Design/958dd68126647056adf2933cf2328c326088e14b/50种群500代/65/Figure_1.png
--------------------------------------------------------------------------------
/50种群500代/65/Result.txt:
--------------------------------------------------------------------------------
1 | 当前迭代代数:499
2 | 种群信息导出完毕。
3 | 最优的目标函数值为:613.5390838061007
4 | 最优的决策变量值为:
5 | 变量x1: 0.1223626243275437
6 | 变量x2: 0.10995821309357649
7 | 变量x3: 6.3080000370324494e-06
8 | 变量x4: 0.08526965717186341
9 | 变量x5: 0.09756646717669061
10 | 有效进化代数:500
11 | 最优的一代是第 285 代
12 | 评价次数:25000
13 | 时间已过 12235.839149475098 秒
--------------------------------------------------------------------------------
/50种群500代/65/Result/Chrom.csv:
--------------------------------------------------------------------------------
1 | 1.223605750665543584e-01,1.099987307292495942e-01,2.136134478533880648e-05,8.536567771085240564e-02,9.762629535663377989e-02
2 | 1.223557204905843243e-01,1.099768942850336828e-01,2.819719964675712525e-05,8.525223462047117062e-02,9.756223239686670490e-02
3 | 1.223898117706373051e-01,1.099211555869868961e-01,5.709931593111394890e-05,8.516913394199092380e-02,9.751980980404117982e-02
4 | 1.223784459183415996e-01,1.099198324155376827e-01,4.993627805180886315e-05,8.522254139484586322e-02,9.757400592270962236e-02
5 | 1.224112262037556076e-01,1.099623239387581969e-01,0.000000000000000000e+00,8.524287528244919865e-02,9.759717319014218906e-02
6 | 1.223210852898331813e-01,1.099123718021798451e-01,0.000000000000000000e+00,8.538977280462378694e-02,9.757502591713998474e-02
7 | 1.223724153844839568e-01,1.099921273323881260e-01,7.746002939833712469e-05,8.524859642063986609e-02,9.758592574686567045e-02
8 | 1.223848724649096165e-01,1.099776928096504458e-01,9.117171274264176356e-06,8.528135552486773574e-02,9.758628523281030753e-02
9 | 1.223580037255744546e-01,1.098578472965394681e-01,4.322134796865259506e-05,8.526100084384730105e-02,9.754433694821751377e-02
10 | 1.223380764032502704e-01,1.098707577246223616e-01,1.440181839505797330e-06,8.529145611783181535e-02,9.752262343771569975e-02
11 | 1.223956369734821858e-01,1.099082732888313346e-01,1.393337747817593140e-05,8.526467662356607136e-02,9.756810812245056419e-02
12 | 1.223983432176249941e-01,1.098750609299531805e-01,1.393337747817593140e-05,8.525253411828725980e-02,9.757696695557037392e-02
13 | 1.223632580535147507e-01,1.099270265865456842e-01,0.000000000000000000e+00,8.529707465990707393e-02,9.757190500497073260e-02
14 | 1.223430259001314080e-01,1.099858050369959678e-01,2.020356449029474770e-05,8.532032378146486851e-02,9.760192951371496339e-02
15 | 1.223550537400932559e-01,1.099443360192595975e-01,1.087778951560101947e-05,8.520111451226293486e-02,9.759803468004858706e-02
16 | 1.222894782683279780e-01,1.100005923860789409e-01,0.000000000000000000e+00,8.530815667320079676e-02,9.755632800416877415e-02
17 | 1.223492833068726138e-01,1.098945090580520090e-01,0.000000000000000000e+00,8.523103593426575864e-02,9.758343977038980155e-02
18 | 1.223880544192844644e-01,1.099474008381033652e-01,1.450903979656293583e-05,8.527355524184185298e-02,9.756422812091983254e-02
19 | 1.224027956509924214e-01,1.098703551878409679e-01,4.724908788302618163e-06,8.526015873093126252e-02,9.759387259019539074e-02
20 | 1.223822145981900977e-01,1.100280308782057292e-01,0.000000000000000000e+00,8.534321459858321135e-02,9.759279185618380259e-02
21 | 1.223399889939892349e-01,1.098668481229277127e-01,0.000000000000000000e+00,8.526740322071610367e-02,9.756151888404226979e-02
22 | 1.223250966781287696e-01,1.099115144095344915e-01,0.000000000000000000e+00,8.529053702645743307e-02,9.758257622450267066e-02
23 | 1.223617683186233041e-01,1.098724626128535359e-01,1.497371514979784584e-05,8.526033905064875351e-02,9.757823202364984683e-02
24 | 1.223291092514937478e-01,1.099246559639243115e-01,4.980787363108342278e-05,8.526129740117022182e-02,9.753581427590436725e-02
25 | 1.223626243275437037e-01,1.099582130935764929e-01,6.308000037032449435e-06,8.526965717186341109e-02,9.756646717669061053e-02
26 | 1.223617626209659304e-01,1.098736577260579772e-01,8.406870578593763033e-06,8.529708392232722425e-02,9.756277587162337506e-02
27 | 1.223176664196287122e-01,1.099253714695041934e-01,5.518861779841703922e-05,8.522502284263075434e-02,9.755603931146274166e-02
28 | 1.222912600957415941e-01,1.100259229369470737e-01,0.000000000000000000e+00,8.531527014826328914e-02,9.757467710247302861e-02
29 | 1.222800160168794337e-01,1.099038318216076920e-01,3.784865392110700892e-05,8.528857617315148409e-02,9.754951223687349793e-02
30 | 1.223706994854290991e-01,1.099869312656376052e-01,0.000000000000000000e+00,8.531575567348569089e-02,9.757562352891299695e-02
31 | 1.223496554405524434e-01,1.099489444571730423e-01,4.628716427210617770e-05,8.530603352410454088e-02,9.767376215321860178e-02
32 | 1.224009969067771791e-01,1.098341494265258900e-01,2.786675495635186281e-05,8.526173245807036616e-02,9.753095230229694157e-02
33 | 1.223372518947088289e-01,1.099797020310143425e-01,0.000000000000000000e+00,8.530584750650761772e-02,9.757419847646744970e-02
34 | 1.223421358718503466e-01,1.099565031633992218e-01,1.227117129278040023e-05,8.530580469546854283e-02,9.750737390009468764e-02
35 | 1.224180981140450541e-01,1.099278111046291251e-01,9.449817576605239715e-06,8.521684701723866717e-02,9.748057235356880068e-02
36 | 1.223015824615599073e-01,1.098943624190251295e-01,4.491270099383266895e-05,8.528755857619388370e-02,9.762100693574934929e-02
37 | 1.223830085007041879e-01,1.099159080470773764e-01,3.126973932924349874e-06,8.524630470824806627e-02,9.758914465506705882e-02
38 | 1.223665609012401650e-01,1.098890230802919005e-01,3.467992775462005382e-05,8.527326877417129580e-02,9.758773125165151607e-02
39 | 1.223610561879446279e-01,1.099043680630223535e-01,1.497890894404698333e-05,8.525352314714126911e-02,9.753832284121652374e-02
40 | 1.223685670029289463e-01,1.099198943305315646e-01,3.060307978724770606e-06,8.527047560826120365e-02,9.758618080721900845e-02
41 | 1.223488664805484905e-01,1.099861863601808293e-01,7.796360524860099239e-05,8.518171231086830997e-02,9.758092075956487088e-02
42 | 1.223537759950696358e-01,1.099636192213130637e-01,2.207480157267206236e-06,8.526770813687419015e-02,9.756758670457599258e-02
43 | 1.223669219113383555e-01,1.099190476806897743e-01,0.000000000000000000e+00,8.527699405150587775e-02,9.755673580563875569e-02
44 | 1.223615403242515609e-01,1.099966797686947051e-01,0.000000000000000000e+00,8.530326728147978599e-02,9.759464338023422780e-02
45 | 1.223630339023228375e-01,1.099128257813569987e-01,3.240975916330649919e-05,8.530945655824462293e-02,9.754908149192029199e-02
46 | 1.223331297861666722e-01,1.099320527526661401e-01,2.854965796555697445e-05,8.525572108162496332e-02,9.758027883712001860e-02
47 | 1.223281430363027111e-01,1.098659956788121256e-01,0.000000000000000000e+00,8.528296175430763459e-02,9.753371459107519625e-02
48 | 1.223324838351803334e-01,1.099142608048528647e-01,8.803091206684215549e-07,8.524515685979208723e-02,9.751705218858781887e-02
49 | 1.223509462488765465e-01,1.100118213659305871e-01,2.994743029959569169e-05,8.529402833306609644e-02,9.753364286913612791e-02
50 | 1.223049289551381980e-01,1.098719292523950147e-01,0.000000000000000000e+00,8.528695581499989853e-02,9.754488754242804371e-02
51 |
--------------------------------------------------------------------------------
/50种群500代/65/Result/Encoding.txt:
--------------------------------------------------------------------------------
1 | RI
--------------------------------------------------------------------------------
/50种群500代/65/Result/Field.csv:
--------------------------------------------------------------------------------
1 | 0.000000000000000000e+00,0.000000000000000000e+00,0.000000000000000000e+00,0.000000000000000000e+00,0.000000000000000000e+00
2 | 8.000000000000000000e+00,8.000000000000000000e+00,8.000000000000000000e+00,8.000000000000000000e+00,8.000000000000000000e+00
3 | 0.000000000000000000e+00,0.000000000000000000e+00,0.000000000000000000e+00,0.000000000000000000e+00,0.000000000000000000e+00
4 |
--------------------------------------------------------------------------------
/50种群500代/65/Result/FitnV.csv:
--------------------------------------------------------------------------------
1 | 3.635084340203320608e-07
2 | 4.497832151173497550e-07
3 | 3.763767608688795008e-07
4 | 3.882736336890957318e-07
5 | 3.792879397224169225e-07
6 | 4.249161520419875160e-07
7 | 4.116118361707776785e-07
8 | 4.034845915157347918e-07
9 | 4.062010248162550852e-07
10 | 4.516812168731121346e-07
11 | 3.815860054601216689e-07
12 | 3.708767053467454389e-07
13 | 3.878255938616348431e-07
14 | 3.747824166566715576e-07
15 | 4.264117023922153749e-07
16 | 4.121602614759467542e-07
17 | 4.017369974462781101e-07
18 | 4.345688466855790466e-07
19 | 3.830007244687294587e-07
20 | 4.379911615615128540e-07
21 | 4.269105602361378260e-07
22 | 4.210670567772467621e-07
23 | 4.230100785207469016e-07
24 | 4.105082780370139517e-07
25 | 4.575545062834862620e-07
26 | 3.988325261161662638e-07
27 | 4.169185103819472715e-07
28 | 3.888395667672739364e-07
29 | 3.987806849181652069e-07
30 | 4.005451046396046877e-07
31 | 3.825786052402690984e-07
32 | 3.599647016017115675e-07
33 | 3.799648311542114243e-07
34 | 3.776265202759532258e-07
35 | 3.722353767443564720e-07
36 | 4.297801297070691362e-07
37 | 3.981907639172277413e-07
38 | 3.803328354479162954e-07
39 | 3.774684955715201795e-07
40 | 4.218422873236704618e-07
41 | 4.103702622160199098e-07
42 | 4.165677864875760861e-07
43 | 3.999928139819530770e-07
44 | 3.708589702000608668e-07
45 | 3.927165153072564863e-07
46 | 4.509843165578786284e-07
47 | 4.444632395461667329e-07
48 | 4.107700988242868334e-07
49 | 3.979118901042966172e-07
50 | 3.814250248979078606e-07
51 |
--------------------------------------------------------------------------------
/50种群500代/65/Result/ObjV.csv:
--------------------------------------------------------------------------------
1 | 6.135390839001468066e+02
2 | 6.135390838138720255e+02
3 | 6.135390838872784798e+02
4 | 6.135390838753816070e+02
5 | 6.135390838843673009e+02
6 | 6.135390838387390886e+02
7 | 6.135390838520434045e+02
8 | 6.135390838601706491e+02
9 | 6.135390838574542158e+02
10 | 6.135390838119740238e+02
11 | 6.135390838820692352e+02
12 | 6.135390838927785353e+02
13 | 6.135390838758296468e+02
14 | 6.135390838888728240e+02
15 | 6.135390838372435383e+02
16 | 6.135390838514949792e+02
17 | 6.135390838619182432e+02
18 | 6.135390838290863940e+02
19 | 6.135390838806545162e+02
20 | 6.135390838256640791e+02
21 | 6.135390838367446804e+02
22 | 6.135390838425881839e+02
23 | 6.135390838406451621e+02
24 | 6.135390838531469626e+02
25 | 6.135390838061007344e+02
26 | 6.135390838648227145e+02
27 | 6.135390838467367303e+02
28 | 6.135390838748156739e+02
29 | 6.135390838648745557e+02
30 | 6.135390838631101360e+02
31 | 6.135390838810766354e+02
32 | 6.135390839036905390e+02
33 | 6.135390838836904095e+02
34 | 6.135390838860287204e+02
35 | 6.135390838914198639e+02
36 | 6.135390838338751109e+02
37 | 6.135390838654644767e+02
38 | 6.135390838833224052e+02
39 | 6.135390838861867451e+02
40 | 6.135390838418129533e+02
41 | 6.135390838532849784e+02
42 | 6.135390838470874542e+02
43 | 6.135390838636624267e+02
44 | 6.135390838927962704e+02
45 | 6.135390838709387253e+02
46 | 6.135390838126709241e+02
47 | 6.135390838191920011e+02
48 | 6.135390838528851418e+02
49 | 6.135390838657433505e+02
50 | 6.135390838822302157e+02
51 |
--------------------------------------------------------------------------------
/50种群500代/65/Result/Phen.csv:
--------------------------------------------------------------------------------
1 | 1.223605750665543584e-01,1.099987307292495942e-01,2.136134478533880648e-05,8.536567771085240564e-02,9.762629535663377989e-02
2 | 1.223557204905843243e-01,1.099768942850336828e-01,2.819719964675712525e-05,8.525223462047117062e-02,9.756223239686670490e-02
3 | 1.223898117706373051e-01,1.099211555869868961e-01,5.709931593111394890e-05,8.516913394199092380e-02,9.751980980404117982e-02
4 | 1.223784459183415996e-01,1.099198324155376827e-01,4.993627805180886315e-05,8.522254139484586322e-02,9.757400592270962236e-02
5 | 1.224112262037556076e-01,1.099623239387581969e-01,0.000000000000000000e+00,8.524287528244919865e-02,9.759717319014218906e-02
6 | 1.223210852898331813e-01,1.099123718021798451e-01,0.000000000000000000e+00,8.538977280462378694e-02,9.757502591713998474e-02
7 | 1.223724153844839568e-01,1.099921273323881260e-01,7.746002939833712469e-05,8.524859642063986609e-02,9.758592574686567045e-02
8 | 1.223848724649096165e-01,1.099776928096504458e-01,9.117171274264176356e-06,8.528135552486773574e-02,9.758628523281030753e-02
9 | 1.223580037255744546e-01,1.098578472965394681e-01,4.322134796865259506e-05,8.526100084384730105e-02,9.754433694821751377e-02
10 | 1.223380764032502704e-01,1.098707577246223616e-01,1.440181839505797330e-06,8.529145611783181535e-02,9.752262343771569975e-02
11 | 1.223956369734821858e-01,1.099082732888313346e-01,1.393337747817593140e-05,8.526467662356607136e-02,9.756810812245056419e-02
12 | 1.223983432176249941e-01,1.098750609299531805e-01,1.393337747817593140e-05,8.525253411828725980e-02,9.757696695557037392e-02
13 | 1.223632580535147507e-01,1.099270265865456842e-01,0.000000000000000000e+00,8.529707465990707393e-02,9.757190500497073260e-02
14 | 1.223430259001314080e-01,1.099858050369959678e-01,2.020356449029474770e-05,8.532032378146486851e-02,9.760192951371496339e-02
15 | 1.223550537400932559e-01,1.099443360192595975e-01,1.087778951560101947e-05,8.520111451226293486e-02,9.759803468004858706e-02
16 | 1.222894782683279780e-01,1.100005923860789409e-01,0.000000000000000000e+00,8.530815667320079676e-02,9.755632800416877415e-02
17 | 1.223492833068726138e-01,1.098945090580520090e-01,0.000000000000000000e+00,8.523103593426575864e-02,9.758343977038980155e-02
18 | 1.223880544192844644e-01,1.099474008381033652e-01,1.450903979656293583e-05,8.527355524184185298e-02,9.756422812091983254e-02
19 | 1.224027956509924214e-01,1.098703551878409679e-01,4.724908788302618163e-06,8.526015873093126252e-02,9.759387259019539074e-02
20 | 1.223822145981900977e-01,1.100280308782057292e-01,0.000000000000000000e+00,8.534321459858321135e-02,9.759279185618380259e-02
21 | 1.223399889939892349e-01,1.098668481229277127e-01,0.000000000000000000e+00,8.526740322071610367e-02,9.756151888404226979e-02
22 | 1.223250966781287696e-01,1.099115144095344915e-01,0.000000000000000000e+00,8.529053702645743307e-02,9.758257622450267066e-02
23 | 1.223617683186233041e-01,1.098724626128535359e-01,1.497371514979784584e-05,8.526033905064875351e-02,9.757823202364984683e-02
24 | 1.223291092514937478e-01,1.099246559639243115e-01,4.980787363108342278e-05,8.526129740117022182e-02,9.753581427590436725e-02
25 | 1.223626243275437037e-01,1.099582130935764929e-01,6.308000037032449435e-06,8.526965717186341109e-02,9.756646717669061053e-02
26 | 1.223617626209659304e-01,1.098736577260579772e-01,8.406870578593763033e-06,8.529708392232722425e-02,9.756277587162337506e-02
27 | 1.223176664196287122e-01,1.099253714695041934e-01,5.518861779841703922e-05,8.522502284263075434e-02,9.755603931146274166e-02
28 | 1.222912600957415941e-01,1.100259229369470737e-01,0.000000000000000000e+00,8.531527014826328914e-02,9.757467710247302861e-02
29 | 1.222800160168794337e-01,1.099038318216076920e-01,3.784865392110700892e-05,8.528857617315148409e-02,9.754951223687349793e-02
30 | 1.223706994854290991e-01,1.099869312656376052e-01,0.000000000000000000e+00,8.531575567348569089e-02,9.757562352891299695e-02
31 | 1.223496554405524434e-01,1.099489444571730423e-01,4.628716427210617770e-05,8.530603352410454088e-02,9.767376215321860178e-02
32 | 1.224009969067771791e-01,1.098341494265258900e-01,2.786675495635186281e-05,8.526173245807036616e-02,9.753095230229694157e-02
33 | 1.223372518947088289e-01,1.099797020310143425e-01,0.000000000000000000e+00,8.530584750650761772e-02,9.757419847646744970e-02
34 | 1.223421358718503466e-01,1.099565031633992218e-01,1.227117129278040023e-05,8.530580469546854283e-02,9.750737390009468764e-02
35 | 1.224180981140450541e-01,1.099278111046291251e-01,9.449817576605239715e-06,8.521684701723866717e-02,9.748057235356880068e-02
36 | 1.223015824615599073e-01,1.098943624190251295e-01,4.491270099383266895e-05,8.528755857619388370e-02,9.762100693574934929e-02
37 | 1.223830085007041879e-01,1.099159080470773764e-01,3.126973932924349874e-06,8.524630470824806627e-02,9.758914465506705882e-02
38 | 1.223665609012401650e-01,1.098890230802919005e-01,3.467992775462005382e-05,8.527326877417129580e-02,9.758773125165151607e-02
39 | 1.223610561879446279e-01,1.099043680630223535e-01,1.497890894404698333e-05,8.525352314714126911e-02,9.753832284121652374e-02
40 | 1.223685670029289463e-01,1.099198943305315646e-01,3.060307978724770606e-06,8.527047560826120365e-02,9.758618080721900845e-02
41 | 1.223488664805484905e-01,1.099861863601808293e-01,7.796360524860099239e-05,8.518171231086830997e-02,9.758092075956487088e-02
42 | 1.223537759950696358e-01,1.099636192213130637e-01,2.207480157267206236e-06,8.526770813687419015e-02,9.756758670457599258e-02
43 | 1.223669219113383555e-01,1.099190476806897743e-01,0.000000000000000000e+00,8.527699405150587775e-02,9.755673580563875569e-02
44 | 1.223615403242515609e-01,1.099966797686947051e-01,0.000000000000000000e+00,8.530326728147978599e-02,9.759464338023422780e-02
45 | 1.223630339023228375e-01,1.099128257813569987e-01,3.240975916330649919e-05,8.530945655824462293e-02,9.754908149192029199e-02
46 | 1.223331297861666722e-01,1.099320527526661401e-01,2.854965796555697445e-05,8.525572108162496332e-02,9.758027883712001860e-02
47 | 1.223281430363027111e-01,1.098659956788121256e-01,0.000000000000000000e+00,8.528296175430763459e-02,9.753371459107519625e-02
48 | 1.223324838351803334e-01,1.099142608048528647e-01,8.803091206684215549e-07,8.524515685979208723e-02,9.751705218858781887e-02
49 | 1.223509462488765465e-01,1.100118213659305871e-01,2.994743029959569169e-05,8.529402833306609644e-02,9.753364286913612791e-02
50 | 1.223049289551381980e-01,1.098719292523950147e-01,0.000000000000000000e+00,8.528695581499989853e-02,9.754488754242804371e-02
51 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 3, 29 June 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 | Preamble
9 |
10 | The GNU General Public License is a free, copyleft license for
11 | software and other kinds of works.
12 |
13 | The licenses for most software and other practical works are designed
14 | to take away your freedom to share and change the works. By contrast,
15 | the GNU General Public License is intended to guarantee your freedom to
16 | share and change all versions of a program--to make sure it remains free
17 | software for all its users. We, the Free Software Foundation, use the
18 | GNU General Public License for most of our software; it applies also to
19 | any other work released this way by its authors. You can apply it to
20 | your programs, too.
21 |
22 | When we speak of free software, we are referring to freedom, not
23 | price. Our General Public Licenses are designed to make sure that you
24 | have the freedom to distribute copies of free software (and charge for
25 | them if you wish), that you receive source code or can get it if you
26 | want it, that you can change the software or use pieces of it in new
27 | free programs, and that you know you can do these things.
28 |
29 | To protect your rights, we need to prevent others from denying you
30 | these rights or asking you to surrender the rights. Therefore, you have
31 | certain responsibilities if you distribute copies of the software, or if
32 | you modify it: responsibilities to respect the freedom of others.
33 |
34 | For example, if you distribute copies of such a program, whether
35 | gratis or for a fee, you must pass on to the recipients the same
36 | freedoms that you received. You must make sure that they, too, receive
37 | or can get the source code. And you must show them these terms so they
38 | know their rights.
39 |
40 | Developers that use the GNU GPL protect your rights with two steps:
41 | (1) assert copyright on the software, and (2) offer you this License
42 | giving you legal permission to copy, distribute and/or modify it.
43 |
44 | For the developers' and authors' protection, the GPL clearly explains
45 | that there is no warranty for this free software. For both users' and
46 | authors' sake, the GPL requires that modified versions be marked as
47 | changed, so that their problems will not be attributed erroneously to
48 | authors of previous versions.
49 |
50 | Some devices are designed to deny users access to install or run
51 | modified versions of the software inside them, although the manufacturer
52 | can do so. This is fundamentally incompatible with the aim of
53 | protecting users' freedom to change the software. The systematic
54 | pattern of such abuse occurs in the area of products for individuals to
55 | use, which is precisely where it is most unacceptable. Therefore, we
56 | have designed this version of the GPL to prohibit the practice for those
57 | products. If such problems arise substantially in other domains, we
58 | stand ready to extend this provision to those domains in future versions
59 | of the GPL, as needed to protect the freedom of users.
60 |
61 | Finally, every program is threatened constantly by software patents.
62 | States should not allow patents to restrict development and use of
63 | software on general-purpose computers, but in those that do, we wish to
64 | avoid the special danger that patents applied to a free program could
65 | make it effectively proprietary. To prevent this, the GPL assures that
66 | patents cannot be used to render the program non-free.
67 |
68 | The precise terms and conditions for copying, distribution and
69 | modification follow.
70 |
71 | TERMS AND CONDITIONS
72 |
73 | 0. Definitions.
74 |
75 | "This License" refers to version 3 of the GNU General Public License.
76 |
77 | "Copyright" also means copyright-like laws that apply to other kinds of
78 | works, such as semiconductor masks.
79 |
80 | "The Program" refers to any copyrightable work licensed under this
81 | License. Each licensee is addressed as "you". "Licensees" and
82 | "recipients" may be individuals or organizations.
83 |
84 | To "modify" a work means to copy from or adapt all or part of the work
85 | in a fashion requiring copyright permission, other than the making of an
86 | exact copy. The resulting work is called a "modified version" of the
87 | earlier work or a work "based on" the earlier work.
88 |
89 | A "covered work" means either the unmodified Program or a work based
90 | on the Program.
91 |
92 | To "propagate" a work means to do anything with it that, without
93 | permission, would make you directly or secondarily liable for
94 | infringement under applicable copyright law, except executing it on a
95 | computer or modifying a private copy. Propagation includes copying,
96 | distribution (with or without modification), making available to the
97 | public, and in some countries other activities as well.
98 |
99 | To "convey" a work means any kind of propagation that enables other
100 | parties to make or receive copies. Mere interaction with a user through
101 | a computer network, with no transfer of a copy, is not conveying.
102 |
103 | An interactive user interface displays "Appropriate Legal Notices"
104 | to the extent that it includes a convenient and prominently visible
105 | feature that (1) displays an appropriate copyright notice, and (2)
106 | tells the user that there is no warranty for the work (except to the
107 | extent that warranties are provided), that licensees may convey the
108 | work under this License, and how to view a copy of this License. If
109 | the interface presents a list of user commands or options, such as a
110 | menu, a prominent item in the list meets this criterion.
111 |
112 | 1. Source Code.
113 |
114 | The "source code" for a work means the preferred form of the work
115 | for making modifications to it. "Object code" means any non-source
116 | form of a work.
117 |
118 | A "Standard Interface" means an interface that either is an official
119 | standard defined by a recognized standards body, or, in the case of
120 | interfaces specified for a particular programming language, one that
121 | is widely used among developers working in that language.
122 |
123 | The "System Libraries" of an executable work include anything, other
124 | than the work as a whole, that (a) is included in the normal form of
125 | packaging a Major Component, but which is not part of that Major
126 | Component, and (b) serves only to enable use of the work with that
127 | Major Component, or to implement a Standard Interface for which an
128 | implementation is available to the public in source code form. A
129 | "Major Component", in this context, means a major essential component
130 | (kernel, window system, and so on) of the specific operating system
131 | (if any) on which the executable work runs, or a compiler used to
132 | produce the work, or an object code interpreter used to run it.
133 |
134 | The "Corresponding Source" for a work in object code form means all
135 | the source code needed to generate, install, and (for an executable
136 | work) run the object code and to modify the work, including scripts to
137 | control those activities. However, it does not include the work's
138 | System Libraries, or general-purpose tools or generally available free
139 | programs which are used unmodified in performing those activities but
140 | which are not part of the work. For example, Corresponding Source
141 | includes interface definition files associated with source files for
142 | the work, and the source code for shared libraries and dynamically
143 | linked subprograms that the work is specifically designed to require,
144 | such as by intimate data communication or control flow between those
145 | subprograms and other parts of the work.
146 |
147 | The Corresponding Source need not include anything that users
148 | can regenerate automatically from other parts of the Corresponding
149 | Source.
150 |
151 | The Corresponding Source for a work in source code form is that
152 | same work.
153 |
154 | 2. Basic Permissions.
155 |
156 | All rights granted under this License are granted for the term of
157 | copyright on the Program, and are irrevocable provided the stated
158 | conditions are met. This License explicitly affirms your unlimited
159 | permission to run the unmodified Program. The output from running a
160 | covered work is covered by this License only if the output, given its
161 | content, constitutes a covered work. This License acknowledges your
162 | rights of fair use or other equivalent, as provided by copyright law.
163 |
164 | You may make, run and propagate covered works that you do not
165 | convey, without conditions so long as your license otherwise remains
166 | in force. You may convey covered works to others for the sole purpose
167 | of having them make modifications exclusively for you, or provide you
168 | with facilities for running those works, provided that you comply with
169 | the terms of this License in conveying all material for which you do
170 | not control copyright. Those thus making or running the covered works
171 | for you must do so exclusively on your behalf, under your direction
172 | and control, on terms that prohibit them from making any copies of
173 | your copyrighted material outside their relationship with you.
174 |
175 | Conveying under any other circumstances is permitted solely under
176 | the conditions stated below. Sublicensing is not allowed; section 10
177 | makes it unnecessary.
178 |
179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180 |
181 | No covered work shall be deemed part of an effective technological
182 | measure under any applicable law fulfilling obligations under article
183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or
184 | similar laws prohibiting or restricting circumvention of such
185 | measures.
186 |
187 | When you convey a covered work, you waive any legal power to forbid
188 | circumvention of technological measures to the extent such circumvention
189 | is effected by exercising rights under this License with respect to
190 | the covered work, and you disclaim any intention to limit operation or
191 | modification of the work as a means of enforcing, against the work's
192 | users, your or third parties' legal rights to forbid circumvention of
193 | technological measures.
194 |
195 | 4. Conveying Verbatim Copies.
196 |
197 | You may convey verbatim copies of the Program's source code as you
198 | receive it, in any medium, provided that you conspicuously and
199 | appropriately publish on each copy an appropriate copyright notice;
200 | keep intact all notices stating that this License and any
201 | non-permissive terms added in accord with section 7 apply to the code;
202 | keep intact all notices of the absence of any warranty; and give all
203 | recipients a copy of this License along with the Program.
204 |
205 | You may charge any price or no price for each copy that you convey,
206 | and you may offer support or warranty protection for a fee.
207 |
208 | 5. Conveying Modified Source Versions.
209 |
210 | You may convey a work based on the Program, or the modifications to
211 | produce it from the Program, in the form of source code under the
212 | terms of section 4, provided that you also meet all of these conditions:
213 |
214 | a) The work must carry prominent notices stating that you modified
215 | it, and giving a relevant date.
216 |
217 | b) The work must carry prominent notices stating that it is
218 | released under this License and any conditions added under section
219 | 7. This requirement modifies the requirement in section 4 to
220 | "keep intact all notices".
221 |
222 | c) You must license the entire work, as a whole, under this
223 | License to anyone who comes into possession of a copy. This
224 | License will therefore apply, along with any applicable section 7
225 | additional terms, to the whole of the work, and all its parts,
226 | regardless of how they are packaged. This License gives no
227 | permission to license the work in any other way, but it does not
228 | invalidate such permission if you have separately received it.
229 |
230 | d) If the work has interactive user interfaces, each must display
231 | Appropriate Legal Notices; however, if the Program has interactive
232 | interfaces that do not display Appropriate Legal Notices, your
233 | work need not make them do so.
234 |
235 | A compilation of a covered work with other separate and independent
236 | works, which are not by their nature extensions of the covered work,
237 | and which are not combined with it such as to form a larger program,
238 | in or on a volume of a storage or distribution medium, is called an
239 | "aggregate" if the compilation and its resulting copyright are not
240 | used to limit the access or legal rights of the compilation's users
241 | beyond what the individual works permit. Inclusion of a covered work
242 | in an aggregate does not cause this License to apply to the other
243 | parts of the aggregate.
244 |
245 | 6. Conveying Non-Source Forms.
246 |
247 | You may convey a covered work in object code form under the terms
248 | of sections 4 and 5, provided that you also convey the
249 | machine-readable Corresponding Source under the terms of this License,
250 | in one of these ways:
251 |
252 | a) Convey the object code in, or embodied in, a physical product
253 | (including a physical distribution medium), accompanied by the
254 | Corresponding Source fixed on a durable physical medium
255 | customarily used for software interchange.
256 |
257 | b) Convey the object code in, or embodied in, a physical product
258 | (including a physical distribution medium), accompanied by a
259 | written offer, valid for at least three years and valid for as
260 | long as you offer spare parts or customer support for that product
261 | model, to give anyone who possesses the object code either (1) a
262 | copy of the Corresponding Source for all the software in the
263 | product that is covered by this License, on a durable physical
264 | medium customarily used for software interchange, for a price no
265 | more than your reasonable cost of physically performing this
266 | conveying of source, or (2) access to copy the
267 | Corresponding Source from a network server at no charge.
268 |
269 | c) Convey individual copies of the object code with a copy of the
270 | written offer to provide the Corresponding Source. This
271 | alternative is allowed only occasionally and noncommercially, and
272 | only if you received the object code with such an offer, in accord
273 | with subsection 6b.
274 |
275 | d) Convey the object code by offering access from a designated
276 | place (gratis or for a charge), and offer equivalent access to the
277 | Corresponding Source in the same way through the same place at no
278 | further charge. You need not require recipients to copy the
279 | Corresponding Source along with the object code. If the place to
280 | copy the object code is a network server, the Corresponding Source
281 | may be on a different server (operated by you or a third party)
282 | that supports equivalent copying facilities, provided you maintain
283 | clear directions next to the object code saying where to find the
284 | Corresponding Source. Regardless of what server hosts the
285 | Corresponding Source, you remain obligated to ensure that it is
286 | available for as long as needed to satisfy these requirements.
287 |
288 | e) Convey the object code using peer-to-peer transmission, provided
289 | you inform other peers where the object code and Corresponding
290 | Source of the work are being offered to the general public at no
291 | charge under subsection 6d.
292 |
293 | A separable portion of the object code, whose source code is excluded
294 | from the Corresponding Source as a System Library, need not be
295 | included in conveying the object code work.
296 |
297 | A "User Product" is either (1) a "consumer product", which means any
298 | tangible personal property which is normally used for personal, family,
299 | or household purposes, or (2) anything designed or sold for incorporation
300 | into a dwelling. In determining whether a product is a consumer product,
301 | doubtful cases shall be resolved in favor of coverage. For a particular
302 | product received by a particular user, "normally used" refers to a
303 | typical or common use of that class of product, regardless of the status
304 | of the particular user or of the way in which the particular user
305 | actually uses, or expects or is expected to use, the product. A product
306 | is a consumer product regardless of whether the product has substantial
307 | commercial, industrial or non-consumer uses, unless such uses represent
308 | the only significant mode of use of the product.
309 |
310 | "Installation Information" for a User Product means any methods,
311 | procedures, authorization keys, or other information required to install
312 | and execute modified versions of a covered work in that User Product from
313 | a modified version of its Corresponding Source. The information must
314 | suffice to ensure that the continued functioning of the modified object
315 | code is in no case prevented or interfered with solely because
316 | modification has been made.
317 |
318 | If you convey an object code work under this section in, or with, or
319 | specifically for use in, a User Product, and the conveying occurs as
320 | part of a transaction in which the right of possession and use of the
321 | User Product is transferred to the recipient in perpetuity or for a
322 | fixed term (regardless of how the transaction is characterized), the
323 | Corresponding Source conveyed under this section must be accompanied
324 | by the Installation Information. But this requirement does not apply
325 | if neither you nor any third party retains the ability to install
326 | modified object code on the User Product (for example, the work has
327 | been installed in ROM).
328 |
329 | The requirement to provide Installation Information does not include a
330 | requirement to continue to provide support service, warranty, or updates
331 | for a work that has been modified or installed by the recipient, or for
332 | the User Product in which it has been modified or installed. Access to a
333 | network may be denied when the modification itself materially and
334 | adversely affects the operation of the network or violates the rules and
335 | protocols for communication across the network.
336 |
337 | Corresponding Source conveyed, and Installation Information provided,
338 | in accord with this section must be in a format that is publicly
339 | documented (and with an implementation available to the public in
340 | source code form), and must require no special password or key for
341 | unpacking, reading or copying.
342 |
343 | 7. Additional Terms.
344 |
345 | "Additional permissions" are terms that supplement the terms of this
346 | License by making exceptions from one or more of its conditions.
347 | Additional permissions that are applicable to the entire Program shall
348 | be treated as though they were included in this License, to the extent
349 | that they are valid under applicable law. If additional permissions
350 | apply only to part of the Program, that part may be used separately
351 | under those permissions, but the entire Program remains governed by
352 | this License without regard to the additional permissions.
353 |
354 | When you convey a copy of a covered work, you may at your option
355 | remove any additional permissions from that copy, or from any part of
356 | it. (Additional permissions may be written to require their own
357 | removal in certain cases when you modify the work.) You may place
358 | additional permissions on material, added by you to a covered work,
359 | for which you have or can give appropriate copyright permission.
360 |
361 | Notwithstanding any other provision of this License, for material you
362 | add to a covered work, you may (if authorized by the copyright holders of
363 | that material) supplement the terms of this License with terms:
364 |
365 | a) Disclaiming warranty or limiting liability differently from the
366 | terms of sections 15 and 16 of this License; or
367 |
368 | b) Requiring preservation of specified reasonable legal notices or
369 | author attributions in that material or in the Appropriate Legal
370 | Notices displayed by works containing it; or
371 |
372 | c) Prohibiting misrepresentation of the origin of that material, or
373 | requiring that modified versions of such material be marked in
374 | reasonable ways as different from the original version; or
375 |
376 | d) Limiting the use for publicity purposes of names of licensors or
377 | authors of the material; or
378 |
379 | e) Declining to grant rights under trademark law for use of some
380 | trade names, trademarks, or service marks; or
381 |
382 | f) Requiring indemnification of licensors and authors of that
383 | material by anyone who conveys the material (or modified versions of
384 | it) with contractual assumptions of liability to the recipient, for
385 | any liability that these contractual assumptions directly impose on
386 | those licensors and authors.
387 |
388 | All other non-permissive additional terms are considered "further
389 | restrictions" within the meaning of section 10. If the Program as you
390 | received it, or any part of it, contains a notice stating that it is
391 | governed by this License along with a term that is a further
392 | restriction, you may remove that term. If a license document contains
393 | a further restriction but permits relicensing or conveying under this
394 | License, you may add to a covered work material governed by the terms
395 | of that license document, provided that the further restriction does
396 | not survive such relicensing or conveying.
397 |
398 | If you add terms to a covered work in accord with this section, you
399 | must place, in the relevant source files, a statement of the
400 | additional terms that apply to those files, or a notice indicating
401 | where to find the applicable terms.
402 |
403 | Additional terms, permissive or non-permissive, may be stated in the
404 | form of a separately written license, or stated as exceptions;
405 | the above requirements apply either way.
406 |
407 | 8. Termination.
408 |
409 | You may not propagate or modify a covered work except as expressly
410 | provided under this License. Any attempt otherwise to propagate or
411 | modify it is void, and will automatically terminate your rights under
412 | this License (including any patent licenses granted under the third
413 | paragraph of section 11).
414 |
415 | However, if you cease all violation of this License, then your
416 | license from a particular copyright holder is reinstated (a)
417 | provisionally, unless and until the copyright holder explicitly and
418 | finally terminates your license, and (b) permanently, if the copyright
419 | holder fails to notify you of the violation by some reasonable means
420 | prior to 60 days after the cessation.
421 |
422 | Moreover, your license from a particular copyright holder is
423 | reinstated permanently if the copyright holder notifies you of the
424 | violation by some reasonable means, this is the first time you have
425 | received notice of violation of this License (for any work) from that
426 | copyright holder, and you cure the violation prior to 30 days after
427 | your receipt of the notice.
428 |
429 | Termination of your rights under this section does not terminate the
430 | licenses of parties who have received copies or rights from you under
431 | this License. If your rights have been terminated and not permanently
432 | reinstated, you do not qualify to receive new licenses for the same
433 | material under section 10.
434 |
435 | 9. Acceptance Not Required for Having Copies.
436 |
437 | You are not required to accept this License in order to receive or
438 | run a copy of the Program. Ancillary propagation of a covered work
439 | occurring solely as a consequence of using peer-to-peer transmission
440 | to receive a copy likewise does not require acceptance. However,
441 | nothing other than this License grants you permission to propagate or
442 | modify any covered work. These actions infringe copyright if you do
443 | not accept this License. Therefore, by modifying or propagating a
444 | covered work, you indicate your acceptance of this License to do so.
445 |
446 | 10. Automatic Licensing of Downstream Recipients.
447 |
448 | Each time you convey a covered work, the recipient automatically
449 | receives a license from the original licensors, to run, modify and
450 | propagate that work, subject to this License. You are not responsible
451 | for enforcing compliance by third parties with this License.
452 |
453 | An "entity transaction" is a transaction transferring control of an
454 | organization, or substantially all assets of one, or subdividing an
455 | organization, or merging organizations. If propagation of a covered
456 | work results from an entity transaction, each party to that
457 | transaction who receives a copy of the work also receives whatever
458 | licenses to the work the party's predecessor in interest had or could
459 | give under the previous paragraph, plus a right to possession of the
460 | Corresponding Source of the work from the predecessor in interest, if
461 | the predecessor has it or can get it with reasonable efforts.
462 |
463 | You may not impose any further restrictions on the exercise of the
464 | rights granted or affirmed under this License. For example, you may
465 | not impose a license fee, royalty, or other charge for exercise of
466 | rights granted under this License, and you may not initiate litigation
467 | (including a cross-claim or counterclaim in a lawsuit) alleging that
468 | any patent claim is infringed by making, using, selling, offering for
469 | sale, or importing the Program or any portion of it.
470 |
471 | 11. Patents.
472 |
473 | A "contributor" is a copyright holder who authorizes use under this
474 | License of the Program or a work on which the Program is based. The
475 | work thus licensed is called the contributor's "contributor version".
476 |
477 | A contributor's "essential patent claims" are all patent claims
478 | owned or controlled by the contributor, whether already acquired or
479 | hereafter acquired, that would be infringed by some manner, permitted
480 | by this License, of making, using, or selling its contributor version,
481 | but do not include claims that would be infringed only as a
482 | consequence of further modification of the contributor version. For
483 | purposes of this definition, "control" includes the right to grant
484 | patent sublicenses in a manner consistent with the requirements of
485 | this License.
486 |
487 | Each contributor grants you a non-exclusive, worldwide, royalty-free
488 | patent license under the contributor's essential patent claims, to
489 | make, use, sell, offer for sale, import and otherwise run, modify and
490 | propagate the contents of its contributor version.
491 |
492 | In the following three paragraphs, a "patent license" is any express
493 | agreement or commitment, however denominated, not to enforce a patent
494 | (such as an express permission to practice a patent or covenant not to
495 | sue for patent infringement). To "grant" such a patent license to a
496 | party means to make such an agreement or commitment not to enforce a
497 | patent against the party.
498 |
499 | If you convey a covered work, knowingly relying on a patent license,
500 | and the Corresponding Source of the work is not available for anyone
501 | to copy, free of charge and under the terms of this License, through a
502 | publicly available network server or other readily accessible means,
503 | then you must either (1) cause the Corresponding Source to be so
504 | available, or (2) arrange to deprive yourself of the benefit of the
505 | patent license for this particular work, or (3) arrange, in a manner
506 | consistent with the requirements of this License, to extend the patent
507 | license to downstream recipients. "Knowingly relying" means you have
508 | actual knowledge that, but for the patent license, your conveying the
509 | covered work in a country, or your recipient's use of the covered work
510 | in a country, would infringe one or more identifiable patents in that
511 | country that you have reason to believe are valid.
512 |
513 | If, pursuant to or in connection with a single transaction or
514 | arrangement, you convey, or propagate by procuring conveyance of, a
515 | covered work, and grant a patent license to some of the parties
516 | receiving the covered work authorizing them to use, propagate, modify
517 | or convey a specific copy of the covered work, then the patent license
518 | you grant is automatically extended to all recipients of the covered
519 | work and works based on it.
520 |
521 | A patent license is "discriminatory" if it does not include within
522 | the scope of its coverage, prohibits the exercise of, or is
523 | conditioned on the non-exercise of one or more of the rights that are
524 | specifically granted under this License. You may not convey a covered
525 | work if you are a party to an arrangement with a third party that is
526 | in the business of distributing software, under which you make payment
527 | to the third party based on the extent of your activity of conveying
528 | the work, and under which the third party grants, to any of the
529 | parties who would receive the covered work from you, a discriminatory
530 | patent license (a) in connection with copies of the covered work
531 | conveyed by you (or copies made from those copies), or (b) primarily
532 | for and in connection with specific products or compilations that
533 | contain the covered work, unless you entered into that arrangement,
534 | or that patent license was granted, prior to 28 March 2007.
535 |
536 | Nothing in this License shall be construed as excluding or limiting
537 | any implied license or other defenses to infringement that may
538 | otherwise be available to you under applicable patent law.
539 |
540 | 12. No Surrender of Others' Freedom.
541 |
542 | If conditions are imposed on you (whether by court order, agreement or
543 | otherwise) that contradict the conditions of this License, they do not
544 | excuse you from the conditions of this License. If you cannot convey a
545 | covered work so as to satisfy simultaneously your obligations under this
546 | License and any other pertinent obligations, then as a consequence you may
547 | not convey it at all. For example, if you agree to terms that obligate you
548 | to collect a royalty for further conveying from those to whom you convey
549 | the Program, the only way you could satisfy both those terms and this
550 | License would be to refrain entirely from conveying the Program.
551 |
552 | 13. Use with the GNU Affero General Public License.
553 |
554 | Notwithstanding any other provision of this License, you have
555 | permission to link or combine any covered work with a work licensed
556 | under version 3 of the GNU Affero General Public License into a single
557 | combined work, and to convey the resulting work. The terms of this
558 | License will continue to apply to the part which is the covered work,
559 | but the special requirements of the GNU Affero General Public License,
560 | section 13, concerning interaction through a network will apply to the
561 | combination as such.
562 |
563 | 14. Revised Versions of this License.
564 |
565 | The Free Software Foundation may publish revised and/or new versions of
566 | the GNU General Public License from time to time. Such new versions will
567 | be similar in spirit to the present version, but may differ in detail to
568 | address new problems or concerns.
569 |
570 | Each version is given a distinguishing version number. If the
571 | Program specifies that a certain numbered version of the GNU General
572 | Public License "or any later version" applies to it, you have the
573 | option of following the terms and conditions either of that numbered
574 | version or of any later version published by the Free Software
575 | Foundation. If the Program does not specify a version number of the
576 | GNU General Public License, you may choose any version ever published
577 | by the Free Software Foundation.
578 |
579 | If the Program specifies that a proxy can decide which future
580 | versions of the GNU General Public License can be used, that proxy's
581 | public statement of acceptance of a version permanently authorizes you
582 | to choose that version for the Program.
583 |
584 | Later license versions may give you additional or different
585 | permissions. However, no additional obligations are imposed on any
586 | author or copyright holder as a result of your choosing to follow a
587 | later version.
588 |
589 | 15. Disclaimer of Warranty.
590 |
591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599 |
600 | 16. Limitation of Liability.
601 |
602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610 | SUCH DAMAGES.
611 |
612 | 17. Interpretation of Sections 15 and 16.
613 |
614 | If the disclaimer of warranty and limitation of liability provided
615 | above cannot be given local legal effect according to their terms,
616 | reviewing courts shall apply local law that most closely approximates
617 | an absolute waiver of all civil liability in connection with the
618 | Program, unless a warranty or assumption of liability accompanies a
619 | copy of the Program in return for a fee.
620 |
621 | END OF TERMS AND CONDITIONS
622 |
623 | How to Apply These Terms to Your New Programs
624 |
625 | If you develop a new program, and you want it to be of the greatest
626 | possible use to the public, the best way to achieve this is to make it
627 | free software which everyone can redistribute and change under these terms.
628 |
629 | To do so, attach the following notices to the program. It is safest
630 | to attach them to the start of each source file to most effectively
631 | state the exclusion of warranty; and each file should have at least
632 | the "copyright" line and a pointer to where the full notice is found.
633 |
634 |
635 | Copyright (C)
636 |
637 | This program is free software: you can redistribute it and/or modify
638 | it under the terms of the GNU General Public License as published by
639 | the Free Software Foundation, either version 3 of the License, or
640 | (at your option) any later version.
641 |
642 | This program is distributed in the hope that it will be useful,
643 | but WITHOUT ANY WARRANTY; without even the implied warranty of
644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
645 | GNU General Public License for more details.
646 |
647 | You should have received a copy of the GNU General Public License
648 | along with this program. If not, see .
649 |
650 | Also add information on how to contact you by electronic and paper mail.
651 |
652 | If the program does terminal interaction, make it output a short
653 | notice like this when it starts in an interactive mode:
654 |
655 | Copyright (C)
656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657 | This is free software, and you are welcome to redistribute it
658 | under certain conditions; type `show c' for details.
659 |
660 | The hypothetical commands `show w' and `show c' should show the appropriate
661 | parts of the General Public License. Of course, your program's commands
662 | might be different; for a GUI interface, you would use an "about box".
663 |
664 | You should also get your employer (if you work as a programmer) or school,
665 | if any, to sign a "copyright disclaimer" for the program, if necessary.
666 | For more information on this, and how to apply and follow the GNU GPL, see
667 | .
668 |
669 | The GNU General Public License does not permit incorporating your program
670 | into proprietary programs. If your program is a subroutine library, you
671 | may consider it more useful to permit linking proprietary applications with
672 | the library. If this is what you want to do, use the GNU Lesser General
673 | Public License instead of this License. But first, please read
674 | .
675 |
--------------------------------------------------------------------------------
/MyProblem.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | import numpy as np
3 | import geatpy as ea
4 | """
5 | 定义具体待优化的模型及其对应的约束条件
6 | """
7 |
8 |
9 | class MyProblem(ea.Problem): # 继承Problem父类
10 | def __init__(self, sampleNum): # 传入种群数目/规模
11 | self.net = MyNetwork(sampleNum) # 交通网络信息类
12 |
13 | name = 'MyProblem' # 初始化name(函数名称,可以随意设置)
14 | M = 1 # 初始化M(目标维数)
15 | maxormins = [1] # 初始化maxormins(目标最小最大化标记列表,1:最小化该目标;-1:最大化该目标)
16 | Dim = self.net.varNum # 初始化Dim(决策变量维数/变量个数)
17 | varTypes = [0] * Dim # 初始化varTypes(决策变量的类型,元素为0表示对应的变量是连续的;1表示是离散的)
18 |
19 | # 下面四个变量是针对此交通网络设计的定值
20 | lb = [0]*Dim # 决策变量下界
21 | ub = [8]*Dim # 决策变量上界
22 | lbin = [1]*Dim # 决策变量下边界(0表示不包含该变量的下边界,1表示包含)
23 | ubin = [1]*Dim # 决策变量上边界(0表示不包含该变量的上边界,1表示包含)
24 |
25 | # 调用父类构造方法完成实例化
26 | ea.Problem.__init__(self, name, M, maxormins, Dim, varTypes, lb, ub, lbin, ubin)
27 |
28 | def aimFunc(self, pop): # 目标函数
29 | Vars = pop.Phen # 得到决策变量矩阵
30 | # x1 = Vars[:, [0]]
31 | # x2 = Vars[:, [1]] #
32 | # pop.ObjV = x1**2 + 3*x1 + x2**3 - x2 + 7 # 计算目标函数值,赋值给pop种群对象的ObjV属性
33 | # 采用可行性法则处理约束(注释掉则无约束)
34 | # pop.CV = np.hstack([x1 + x2 - 5,
35 | # - 2*x1 + x2 + 1])
36 |
37 | # 目标函数的两个部分分别计算,再相加(应该是两个ndarray相加)
38 | pop.ObjV = self.net.get_obj_part1(Vars) + self.net.get_obj_part2(Vars)
39 |
40 | def calReferObjV(self): # 设定目标数参考值(本问题目标函数参考值设定为理论最优值)
41 | referenceObjV = np.array([[2.5]])
42 | return referenceObjV
43 |
44 | def report(self):
45 | self.net.report()
46 |
47 |
48 | from model import TrafficFlowModel
49 | '''
50 | 个人定义的网络类,用来调用实现用户均衡的package
51 | '''
52 | class MyNetwork:
53 | def __init__(self, sampleNum):
54 | self.last_model = None
55 | self.sampleNum = sampleNum # 配合遗传算法使用的种群数量
56 |
57 | # 定义一些交通网络设计时需要的变量
58 | self.varNum = 5 # 路段数目
59 | self.Ca = [45, 40, 70, 40, 45] # 路段的原有通行能力
60 | self.T0 = [4, 6, 2, 5, 3] # 路段的零流阻抗
61 | self.Da = [2.0, 2.0, 1.5, 2.0, 2.0] # 路段的单位投资成本
62 |
63 | # Graph represented by directed dictionary
64 | # In order: first ("5", "7"), second ("5", "9"), third ("6", "7")...
65 | self.graph = [
66 | ("1", ["2", "3"]),
67 | ("2", ["3", "4"]),
68 | ("3", ["4"]),
69 | ("4", [])
70 | ]
71 |
72 | # Origin-destination pairs
73 | self.origins = ["1"]
74 | self.destinations = ["4"]
75 |
76 | # Demand between each OD pair (Conjugated to the Cartesian
77 | # product of Origins and destinations with order)
78 | # self.demand = [65]
79 | self.demand = [130]
80 | # self.demand = [180]
81 |
82 | def __bpm(self, t0, xa, ca):
83 | return t0*(1+0.15*(xa/ca)**4)
84 |
85 | # 计算目标函数的第一部分(路段阻抗成本)
86 | def get_obj_part1(self, Vars):
87 | # Ya = {} # 新增交通量的集合
88 | # for i in range(self.varNum):
89 | # Ya[i] = Vars[:, [i]]
90 | Xa = self.__get_xa(Vars) # 各路段分配通行能力的集合
91 | Ta = 0 # 总的路段阻抗成本(是个ndarray)
92 | for i in range(self.varNum):
93 | # 当前通行能力 = 原有通行能力ca + 新增的通行能力ya
94 | Ta += (self.__bpm(self.T0[i], Xa[:, [i]], self.Ca[i]+Vars[:, [i]]) * Xa[:, [i]])
95 | return Ta
96 |
97 | # 计算目标函数的第二部分(总投资成本)
98 | def get_obj_part2(self, Vars):
99 | Ia = 0 # 总投资成本(是个ndarray)
100 | for i in range(self.varNum):
101 | Ia += (self.Da[i] * (Vars[:, [i]]**2))
102 | return 1.6*Ia
103 |
104 | # 下层规划模型求解:用户均衡 F-W算法
105 | def __get_xa(self, Vars):
106 | # todo 调用F-W算法求xa
107 | Xa = None
108 | for i in range(self.sampleNum):
109 | # Initialize the model by data
110 | mod = TrafficFlowModel(self.graph, self.origins, self.destinations,
111 | self.demand, self.T0, self.__get_cur_Ca(Vars[i, :]))
112 |
113 | # Change the accuracy of solution if necessary
114 | mod._conv_accuracy = 1e-3
115 | mod.set_disp_precision(3)
116 |
117 | # Solve the model by Frank-Wolfe Algorithm
118 | mod.solve()
119 |
120 | # Generate report to console(此处不建议启用)
121 | # mod.report()
122 | self.last_model = mod
123 |
124 | # Return the solution if necessary
125 | flow, link_t, path_t, v_c = mod._formatted_solution()
126 | if i == 0:
127 | Xa = flow
128 | else:
129 | Xa = np.vstack([Xa, flow])
130 | return Xa
131 | # Xa应该是一个矩阵,97行中使用的Xa[i]应该是Xa中的第i列
132 |
133 | # 获得当前的通行能力
134 | def __get_cur_Ca(self, xa):
135 | cur_ca = xa+self.Ca
136 | return cur_ca.tolist()
137 |
138 | def report(self):
139 | self.last_model.report()
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Traffic-Network-Design
2 | The assignment of a transportation course for my first year as a graduate student, solved the bilevel programming problem using GA algorithm and T-F algorithm.
3 |
4 | # Quote
5 | The main repositories used in this assignment are as follows,
6 | - [GeneticAlgorithmsWithPython](https://github.com/handcraftsman/GeneticAlgorithmsWithPython) is used to solve the Traffic assignment problem —— solve User Equilibrium using F-W algorithm
7 | - [geatpy](https://github.com/geatpy-dev/geatpy) is used to calculate the optimal value of the upper objective function
8 |
9 | The version of `geatpy` I use is updated as follow:
10 |
11 | ```bash
12 | (base) [user@host Traffic-Network-Design (master ✗)]$ conda list geatpy
13 | # packages in environment at /Users/user/miniforge3:
14 | #
15 | # Name Version Build Channel
16 | geatpy 2.7.0 pypi_0 pypi
17 | ```
18 |
19 | # HOW TO USE
20 | - Define your network information in class MyNetwork in `Myproblem.py`
21 | - Define the upper and lower bounds of the independent variable and the aimFunc in class MyProblem in `Myproblem.py`
22 | - Set the necessary parameters related to genetic algorithm in `main.py` such as NIND and myAlgorithm.MAXGEN
23 | - Run the program
24 |
25 | ```cmd
26 | python main.py
27 | ```
28 |
29 | # More Info
30 | As this is only a homework of my own, I don't want to spend too much time on this document.
31 | For more information, please refer to the repositories I cited above.
32 |
--------------------------------------------------------------------------------
/Reference/User-Equilibrium-Solution-master/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2018 Zheng Li
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/Reference/User-Equilibrium-Solution-master/README.md:
--------------------------------------------------------------------------------
1 | # USER-EQUILIBRIUM-SOLUTION
2 |
3 | User equilibrium is a classical problem on the traffic flow assignment in the field of Transportation Engineering, its main idea is: Every driver cannot reduce his travel time by unilaterally change his travel route.
4 |
5 | ## THEORY OF USER EQUILIBRIUM SOLUTION
6 |
7 | Please refer to [User-Equilibrium-Solution.pdf](static/user-equilibrium-solution.pdf).
8 |
9 | ### Abstract
10 |
11 | We have given an equivalent formulation, which is a convex optimization problem, of finding user equilibrium solution in the traffic flow assignment, with proof of the equivalence. For the equivalent formulation, we have demonstrated the existence and uniqueness of minimizer. Moreover, the variant of Frank-Wolfe Algorithm is introduced for numerically solving the equivalent formulation.
12 |
13 | ### Contents
14 |
15 | + Statement of Problem
16 | + Decision Variables and Parameters
17 | + Objective and Definition of User Equilibrium
18 | + Equivalent Mathematical Formulation
19 | + Statement of Equivalent Formulation
20 | + Existence of Minimizer
21 | + Convexity of Equivalent Formulation
22 | + Review on Constrained Problems
23 | + Demonstration of Equivalence
24 | + Introduction to Frank-Wolfe Algorithm
25 |
26 | ## INSTRUCTIONS OF PROGRAM
27 |
28 | All the things are done within 3 main procedures, implement them in `main.py`:
29 |
30 | ### 1. Data input
31 |
32 | All the data must be introduced into model by the constructor `TrafficFlowModel.__init__`.
33 |
34 | ### 2. Solve
35 |
36 | Invoke `TrafficFlowModel.solve`.
37 |
38 | ### 3. Output report
39 |
40 | Invoke `TrafficFlowModel.report`.
41 |
42 | Then you can just run `$ python main.py`.
43 |
44 | ## TIPS
45 |
46 | 1. Parameters in the link performance function such as `TrafficFlowModel._alpha` and `TrafficFlowModel._beta` are directly exposed to users, one can revise them if necessary.
47 | 2. Notice the mutual correspondence between the input data while writing them into the `data.py`.
48 | 3. When the program doesn't go well, please firstly use `TrafficFlowModel.__str__` (which is already contained in `TrafficFlowModel.report`) to print all the current parameters for ensuring all the data having been introduced into model correctly.
49 | 4. In the file `main.py`, all the most-used methods of `TrafficFlowModel` class are given, which are guidelines for the user; and all functions in the repository are more or less with illustrations.
50 | 5. It happens that the travelling time of paths in each group are not approximately equal (Thanks to [@Sword-holder](https://github.com/Sword-holder) and his team members for pointing out this phenomenon), since some paths have zero flow. However, in general the number of paths is greater than that of links, which implies the linear mapping from `path_flow` to `link_flow` cannot be injective, so we cannot mathematically obtain the `path_flow` from the `link_flow`, since the inverse mapping does not exist. But this does not influence the existence of unique optimal `path_flow`, the optimal `link_flow` obtained by Frank-Wolfe algorithm is the image of optimal `path_flow` under aforementioned linear mapping.
51 | 6. This program might not be numerical stable when it encounters big road network.
52 | 7. If you have trouble with implementing of model, or find some bugs, please contact [me](mailto:zheng.andrea.li@gmail.com).
53 |
54 | ## SAMPLE
55 |
56 | This sample was provided by Prof. [F. Xiao](https://scholar.google.com/citations?user=prn-uaQAAAAJ) within his lectures at [Southwest Jiaotong University](https://english.swjtu.edu.cn/), and you can find all the data of this toy sample in `data.py`.
57 |
58 | ### Graph display
59 |
60 | 
61 |
62 | ### Parameters of links
63 |
64 | | LINK | LENGTH | NO. OF LANES | FREE FLOW SPEED | CAPACITY PER LANE|
65 | | :-----: | :----: | :----------: | :-------------: | :---------------:|
66 | | 5 - 7 | 10.0 | 2 | 60 | 1800 |
67 | | 5 - 9 | 10.0 | 2 | 60 | 1800 |
68 | | 6 - 7 | 10.0 | 2 | 60 | 1800 |
69 | | 6 - 8 | 14.1 | 2 | 60 | 1800 |
70 | | 7 - 8 | 10.0 | 2 | 60 | 1800 |
71 | | 7 - 10 | 10.0 | 2 | 60 | 1800 |
72 | | 8 - 11 | 10.0 | 2 | 60 | 1800 |
73 | | 8 - 12 | 14.1 | 2 | 60 | 1800 |
74 | | 9 - 10 | 10.0 | 2 | 60 | 1800 |
75 | | 9 - 16 | 22.4 | 2 | 60 | 1800 |
76 | | 10 - 11 | 10.0 | 2 | 60 | 1800 |
77 | | 10 - 13 | 10.0 | 2 | 60 | 1800 |
78 | | 11 - 14 | 10.0 | 2 | 60 | 1800 |
79 | | 12 - 15 | 10.0 | 2 | 60 | 1800 |
80 | | 13 - 14 | 10.0 | 2 | 60 | 1800 |
81 | | 13 - 16 | 10.0 | 2 | 60 | 1800 |
82 | | 14 - 15 | 10.0 | 2 | 60 | 1800 |
83 | | 14 - 17 | 10.0 | 2 | 60 | 1800 |
84 | | 16 - 17 | 10.0 | 2 | 60 | 1800 |
85 |
86 | ### Origin-destination pairs and demands
87 |
88 | | DEMAND | 15 | 17 |
89 | | ------ | :--- | :--: |
90 | | 5 | 6000 | 6750 |
91 | | 6 | 7500 | 5250 |
92 |
93 | ### Report of solution (printed in console)
94 |
95 | ```python
96 | # --------------------------------------------------------------------------------
97 | # TRAFFIC FLOW ASSIGN MODEL (USER EQUILIBRIUM)
98 | # FRANK-WOLFE ALGORITHM - PARAMS OF MODEL
99 | # --------------------------------------------------------------------------------
100 | # --------------------------------------------------------------------------------
101 | # LINK Information:
102 | # --------------------------------------------------------------------------------
103 | # 0 : link= ['5', '7'], free time= 10.00, capacity= 3600
104 | # 1 : link= ['5', '9'], free time= 10.00, capacity= 3600
105 | # 2 : link= ['6', '7'], free time= 10.00, capacity= 3600
106 | # 3 : link= ['6', '8'], free time= 14.10, capacity= 3600
107 | # 4 : link= ['7', '8'], free time= 10.00, capacity= 3600
108 | # 5 : link= ['7', '10'], free time= 10.00, capacity= 3600
109 | # 6 : link= ['8', '11'], free time= 10.00, capacity= 3600
110 | # 7 : link= ['8', '12'], free time= 14.10, capacity= 3600
111 | # 8 : link= ['9', '10'], free time= 10.00, capacity= 3600
112 | # 9 : link= ['9', '16'], free time= 22.40, capacity= 3600
113 | # 10 : link= ['10', '11'], free time= 10.00, capacity= 3600
114 | # 11 : link= ['10', '13'], free time= 10.00, capacity= 3600
115 | # 12 : link= ['11', '14'], free time= 10.00, capacity= 3600
116 | # 13 : link= ['12', '15'], free time= 10.00, capacity= 3600
117 | # 14 : link= ['13', '14'], free time= 10.00, capacity= 3600
118 | # 15 : link= ['13', '16'], free time= 10.00, capacity= 3600
119 | # 16 : link= ['14', '15'], free time= 10.00, capacity= 3600
120 | # 17 : link= ['14', '17'], free time= 10.00, capacity= 3600
121 | # 18 : link= ['16', '17'], free time= 10.00, capacity= 3600
122 | # --------------------------------------------------------------------------------
123 | # OD Pairs Information:
124 | # --------------------------------------------------------------------------------
125 | # 0 : OD pair= ['5', '15'], demand= 6000
126 | # 1 : OD pair= ['5', '17'], demand= 6750
127 | # 2 : OD pair= ['6', '15'], demand= 7500
128 | # 3 : OD pair= ['6', '17'], demand= 5250
129 | # --------------------------------------------------------------------------------
130 | # Path Information:
131 | # --------------------------------------------------------------------------------
132 | # 0 : Conjugated OD pair= 0, Path= ['5', '7', '8', '11', '14', '15']
133 | # 1 : Conjugated OD pair= 0, Path= ['5', '7', '8', '12', '15']
134 | # 2 : Conjugated OD pair= 0, Path= ['5', '7', '10', '11', '14', '15']
135 | # 3 : Conjugated OD pair= 0, Path= ['5', '7', '10', '13', '14', '15']
136 | # 4 : Conjugated OD pair= 0, Path= ['5', '9', '10', '11', '14', '15']
137 | # 5 : Conjugated OD pair= 0, Path= ['5', '9', '10', '13', '14', '15']
138 | # 6 : Conjugated OD pair= 1, Path= ['5', '7', '8', '11', '14', '17']
139 | # 7 : Conjugated OD pair= 1, Path= ['5', '7', '10', '11', '14', '17']
140 | # 8 : Conjugated OD pair= 1, Path= ['5', '7', '10', '13', '14', '17']
141 | # 9 : Conjugated OD pair= 1, Path= ['5', '7', '10', '13', '16', '17']
142 | # 10 : Conjugated OD pair= 1, Path= ['5', '9', '10', '11', '14', '17']
143 | # 11 : Conjugated OD pair= 1, Path= ['5', '9', '10', '13', '14', '17']
144 | # 12 : Conjugated OD pair= 1, Path= ['5', '9', '10', '13', '16', '17']
145 | # 13 : Conjugated OD pair= 1, Path= ['5', '9', '16', '17']
146 | # 14 : Conjugated OD pair= 2, Path= ['6', '7', '8', '11', '14', '15']
147 | # 15 : Conjugated OD pair= 2, Path= ['6', '7', '8', '12', '15']
148 | # 16 : Conjugated OD pair= 2, Path= ['6', '7', '10', '11', '14', '15']
149 | # 17 : Conjugated OD pair= 2, Path= ['6', '7', '10', '13', '14', '15']
150 | # 18 : Conjugated OD pair= 2, Path= ['6', '8', '11', '14', '15']
151 | # 19 : Conjugated OD pair= 2, Path= ['6', '8', '12', '15']
152 | # 20 : Conjugated OD pair= 3, Path= ['6', '7', '8', '11', '14', '17']
153 | # 21 : Conjugated OD pair= 3, Path= ['6', '7', '10', '11', '14', '17']
154 | # 22 : Conjugated OD pair= 3, Path= ['6', '7', '10', '13', '14', '17']
155 | # 23 : Conjugated OD pair= 3, Path= ['6', '7', '10', '13', '16', '17']
156 | # 24 : Conjugated OD pair= 3, Path= ['6', '8', '11', '14', '17']
157 | # --------------------------------------------------------------------------------
158 | # Link - Path Incidence Matrix:
159 | # --------------------------------------------------------------------------------
160 | # [[1 1 1 1 0 0 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]
161 | # [0 0 0 0 1 1 0 0 0 0 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0]
162 | # [0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 0 0 1 1 1 1 0]
163 | # [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 1]
164 | # [1 1 0 0 0 0 1 0 0 0 0 0 0 0 1 1 0 0 0 0 1 0 0 0 0]
165 | # [0 0 1 1 0 0 0 1 1 1 0 0 0 0 0 0 1 1 0 0 0 1 1 1 0]
166 | # [1 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 1 0 1 0 0 0 1]
167 | # [0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1 0 0 0 0 0]
168 | # [0 0 0 0 1 1 0 0 0 0 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0]
169 | # [0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0]
170 | # [0 0 1 0 1 0 0 1 0 0 1 0 0 0 0 0 1 0 0 0 0 1 0 0 0]
171 | # [0 0 0 1 0 1 0 0 1 1 0 1 1 0 0 0 0 1 0 0 0 0 1 1 0]
172 | # [1 0 1 0 1 0 1 1 0 0 1 0 0 0 1 0 1 0 1 0 1 1 0 0 1]
173 | # [0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1 0 0 0 0 0]
174 | # [0 0 0 1 0 1 0 0 1 0 0 1 0 0 0 0 0 1 0 0 0 0 1 0 0]
175 | # [0 0 0 0 0 0 0 0 0 1 0 0 1 0 0 0 0 0 0 0 0 0 0 1 0]
176 | # [1 0 1 1 1 1 0 0 0 0 0 0 0 0 1 0 1 1 1 0 0 0 0 0 0]
177 | # [0 0 0 0 0 0 1 1 1 0 1 1 0 0 0 0 0 0 0 0 1 1 1 0 1]
178 | # [0 0 0 0 0 0 0 0 0 1 0 0 1 1 0 0 0 0 0 0 0 0 0 1 0]]
179 | # --------------------------------------------------------------------------------
180 | # TRAFFIC FLOW ASSIGN MODEL (USER EQUILIBRIUM)
181 | # FRANK-WOLFE ALGORITHM - REPORT OF SOLUTION
182 | # --------------------------------------------------------------------------------
183 | # --------------------------------------------------------------------------------
184 | # TIMES OF ITERATION : 1199
185 | # --------------------------------------------------------------------------------
186 | # --------------------------------------------------------------------------------
187 | # PERFORMANCE OF LINKS
188 | # --------------------------------------------------------------------------------
189 | # 0 : link= ['5', '7'], flow= 5632.68, time= 18.99, v/c= 1.565
190 | # 1 : link= ['5', '9'], flow= 7117.32, time= 32.92, v/c= 1.977
191 | # 2 : link= ['6', '7'], flow= 6048.31, time= 21.95, v/c= 1.680
192 | # 3 : link= ['6', '8'], flow= 6701.69, time= 39.50, v/c= 1.862
193 | # 4 : link= ['7', '8'], flow= 5392.05, time= 17.55, v/c= 1.498
194 | # 5 : link= ['7', '10'], flow= 6288.95, time= 23.97, v/c= 1.747
195 | # 6 : link= ['8', '11'], flow= 5191.43, time= 16.49, v/c= 1.442
196 | # 7 : link= ['8', '12'], flow= 6902.30, time= 42.68, v/c= 1.917
197 | # 8 : link= ['9', '10'], flow= 1481.14, time= 10.04, v/c= 0.411
198 | # 9 : link= ['9', '16'], flow= 5636.18, time= 42.59, v/c= 1.566
199 | # 10 : link= ['10', '11'], flow= 1648.04, time= 10.07, v/c= 0.458
200 | # 11 : link= ['10', '13'], flow= 6122.05, time= 22.54, v/c= 1.701
201 | # 12 : link= ['11', '14'], flow= 6839.47, time= 29.54, v/c= 1.900
202 | # 13 : link= ['12', '15'], flow= 6902.30, time= 30.27, v/c= 1.917
203 | # 14 : link= ['13', '14'], flow= 5303.10, time= 17.06, v/c= 1.473
204 | # 15 : link= ['13', '16'], flow= 818.95, time= 10.00, v/c= 0.227
205 | # 16 : link= ['14', '15'], flow= 6597.70, time= 26.92, v/c= 1.833
206 | # 17 : link= ['14', '17'], flow= 5544.87, time= 18.44, v/c= 1.540
207 | # 18 : link= ['16', '17'], flow= 6455.13, time= 25.51, v/c= 1.793
208 | # --------------------------------------------------------------------------------
209 | # PERFORMANCE OF PATHS (GROUP BY ORIGIN-DESTINATION PAIR)
210 | # --------------------------------------------------------------------------------
211 | # 0 : group= 0, time= 109.49, path= ['5', '7', '8', '11', '14', '15']
212 | # 1 : group= 0, time= 109.49, path= ['5', '7', '8', '12', '15']
213 | # 2 : group= 0, time= 109.49, path= ['5', '7', '10', '11', '14', '15']
214 | # 3 : group= 0, time= 109.49, path= ['5', '7', '10', '13', '14', '15']
215 | # 4 : group= 0, time= 109.49, path= ['5', '9', '10', '11', '14', '15']
216 | # 5 : group= 0, time= 109.49, path= ['5', '9', '10', '13', '14', '15']
217 | # 6 : group= 1, time= 101.01, path= ['5', '7', '8', '11', '14', '17']
218 | # 7 : group= 1, time= 101.01, path= ['5', '7', '10', '11', '14', '17']
219 | # 8 : group= 1, time= 101.01, path= ['5', '7', '10', '13', '14', '17']
220 | # 9 : group= 1, time= 101.01, path= ['5', '7', '10', '13', '16', '17']
221 | # 10 : group= 1, time= 101.01, path= ['5', '9', '10', '11', '14', '17']
222 | # 11 : group= 1, time= 101.01, path= ['5', '9', '10', '13', '14', '17']
223 | # 12 : group= 1, time= 101.01, path= ['5', '9', '10', '13', '16', '17']
224 | # 13 : group= 1, time= 101.01, path= ['5', '9', '16', '17']
225 | # 14 : group= 2, time= 112.45, path= ['6', '7', '8', '11', '14', '15']
226 | # 15 : group= 2, time= 112.45, path= ['6', '7', '8', '12', '15']
227 | # 16 : group= 2, time= 112.45, path= ['6', '7', '10', '11', '14', '15']
228 | # 17 : group= 2, time= 112.45, path= ['6', '7', '10', '13', '14', '15']
229 | # 18 : group= 2, time= 112.45, path= ['6', '8', '11', '14', '15']
230 | # 19 : group= 2, time= 112.45, path= ['6', '8', '12', '15']
231 | # 20 : group= 3, time= 103.97, path= ['6', '7', '8', '11', '14', '17']
232 | # 21 : group= 3, time= 103.97, path= ['6', '7', '10', '11', '14', '17']
233 | # 22 : group= 3, time= 103.97, path= ['6', '7', '10', '13', '14', '17']
234 | # 23 : group= 3, time= 103.98, path= ['6', '7', '10', '13', '16', '17']
235 | # 24 : group= 3, time= 103.97, path= ['6', '8', '11', '14', '17']
236 | ```
237 |
--------------------------------------------------------------------------------
/Reference/User-Equilibrium-Solution-master/__pycache__/data.cpython-36.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/qizidog/Traffic-Network-Design/958dd68126647056adf2933cf2328c326088e14b/Reference/User-Equilibrium-Solution-master/__pycache__/data.cpython-36.pyc
--------------------------------------------------------------------------------
/Reference/User-Equilibrium-Solution-master/__pycache__/graph.cpython-36.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/qizidog/Traffic-Network-Design/958dd68126647056adf2933cf2328c326088e14b/Reference/User-Equilibrium-Solution-master/__pycache__/graph.cpython-36.pyc
--------------------------------------------------------------------------------
/Reference/User-Equilibrium-Solution-master/__pycache__/model.cpython-36.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/qizidog/Traffic-Network-Design/958dd68126647056adf2933cf2328c326088e14b/Reference/User-Equilibrium-Solution-master/__pycache__/model.cpython-36.pyc
--------------------------------------------------------------------------------
/Reference/User-Equilibrium-Solution-master/data.py:
--------------------------------------------------------------------------------
1 | """ SAMPLE
2 | In this file you can find sample data which could be used
3 | into the TrafficFlowMod class in model.py file
4 | """
5 |
6 | # Graph represented by directed dictionary
7 | # In order: first ("5", "7"), second ("5", "9"), third ("6", "7")...
8 | graph = [
9 | ("5", ["7", "9"]),
10 | ("6", ["7", "8"]),
11 | ("7", ["8", "10"]),
12 | ("8", ["11", "12"]),
13 | ("9", ["10", "16"]),
14 | ("10", ["11", "13"]),
15 | ("11", ["14"]),
16 | ("12", ["15"]),
17 | ("13", ["14", "16"]),
18 | ("14", ["15", "17"]),
19 | ("15", []),
20 | ("16", ["17"]),
21 | ("17", [])
22 | ]
23 |
24 | # Capacity of each link (Conjugated to Graph with order)
25 | # Here all the 19 links have the same capacity
26 | capacity = [3600] * 19
27 |
28 | # Free travel time of each link (Conjugated to Graph with order)
29 | free_time = [
30 | 10, 10,
31 | 10, 14.1,
32 | 10, 10,
33 | 10, 14.1,
34 | 10, 22.4,
35 | 10, 10,
36 | 10,
37 | 10,
38 | 10, 10,
39 | 10, 10,
40 | 10
41 | ]
42 |
43 | # Origin-destination pairs
44 | origins = ["5", "6"]
45 | destinations = ["15", "17"]
46 | # Generated ordered OD pairs:
47 | # first ("5", "15"), second ("5", "17"), third ("6", "15")...
48 |
49 |
50 | # Demand between each OD pair (Conjugated to the Cartesian
51 | # product of Origins and destinations with order)
52 | demand = [6000, 6750, 7500, 5250]
53 |
54 |
--------------------------------------------------------------------------------
/Reference/User-Equilibrium-Solution-master/graph.py:
--------------------------------------------------------------------------------
1 |
2 | class Graph(object):
3 | """ DIRECTED GRAPH CLASS
4 |
5 | A simple Python graph class, demonstrating the essential
6 | facts and functionalities of directed graphs, and it is
7 | designed for our traffic flow assignment problem, thus we
8 | have the following assumptions:
9 |
10 | 1. The graph contains no self-loop, that is, an edge that
11 | connects a vertex to itself;
12 |
13 | 2. There is at most one edge which connects two vertice;
14 |
15 | Revised from: https://www.python-course.eu/graphs_python.php
16 | and in our case we must give order to all the edges, thus we
17 | do not use the unordered data structure.
18 | """
19 |
20 | def __init__(self, graph_dict= None):
21 | """ initializes a directed graph object by a dictionary,
22 | If no dictionary or None is given, an empty dictionary
23 | will be used. Notice that this initial graph cannot
24 | contain a self-loop.
25 | """
26 | from collections import OrderedDict
27 | if graph_dict == None:
28 | graph_dict = OrderedDict()
29 | self.__graph_dict = OrderedDict(graph_dict)
30 | if self.__is_with_loop():
31 | raise ValueError("The graph are supposed to be without self-loop please recheck the input data!")
32 |
33 | def vertices(self):
34 | """ returns the vertices of a graph
35 | """
36 | return list(self.__graph_dict.keys())
37 |
38 | def edges(self):
39 | """ returns the edges of a graph
40 | """
41 | return self.__generate_edges()
42 |
43 | def add_vertex(self, vertex):
44 | """ If the vertex "vertex" is not in
45 | self.__graph_dict, a key "vertex" with an empty
46 | list as a value is added to the dictionary.
47 | Otherwise nothing has to be done.
48 | """
49 | if vertex not in self.__graph_dict:
50 | self.__graph_dict[vertex] = []
51 | else:
52 | print("The vertex %s already exists in the graph, thus it has been ignored!" % vertex)
53 |
54 | def add_edge(self, edge):
55 | """ Assume that edge is ordered, and between two
56 | vertices there could exists only one edge.
57 | """
58 | vertex1, vertex2 = self.__decompose_edge(edge)
59 | if not self.__is_edge_in_graph(edge):
60 | if vertex1 in self.__graph_dict:
61 | self.__graph_dict[vertex1].append(vertex2)
62 | if vertex2 not in self.__graph_dict:
63 | self.__graph_dict[vertex2] = []
64 | else:
65 | self.__graph_dict[vertex1] = [vertex2]
66 | else:
67 | print("The edge %s already exists in the graph, thus it has been ignored!" % ([vertex1, vertex2]))
68 |
69 | def find_all_paths(self, start_vertex, end_vertex, path= []):
70 | """ find all simple paths (path with no repeated vertices)
71 | from start vertex to end vertex in graph
72 | """
73 | path = path + [start_vertex]
74 | if start_vertex == end_vertex:
75 | return [path]
76 | paths = []
77 | for neighbor in self.__graph_dict[start_vertex]:
78 | if neighbor not in path:
79 | sub_paths = self.find_all_paths(neighbor, end_vertex, path)
80 | for sub_path in sub_paths:
81 | paths.append(sub_path)
82 | return paths
83 |
84 | def __is_edge_in_graph(self, edge):
85 | """ Judge if an edge is already in the graph
86 | """
87 | vertex1, vertex2 = self.__decompose_edge(edge)
88 | if vertex1 in self.__graph_dict:
89 | if vertex2 in self.__graph_dict[vertex1]:
90 | return True
91 | else:
92 | return False
93 | else:
94 | return False
95 |
96 | def __decompose_edge(self, edge):
97 | """ Input is a list or a tuple with only two elements
98 | """
99 | if (isinstance(edge, list) or isinstance(edge, tuple)) and len(edge) == 2:
100 | return edge[0], edge[1]
101 | else:
102 | raise ValueError("%s is not of type list or tuple or its length does not equal to 2" % edge)
103 |
104 | def __is_with_loop(self):
105 | """ If the graph contains a self-loop, that is, an
106 | edge connects a vertex to itself, then return
107 | True, otherwise return False
108 | """
109 | for vertex in self.__graph_dict:
110 | if vertex in self.__graph_dict[vertex]:
111 | return True
112 | return False
113 |
114 | def __generate_edges(self):
115 | """ A static method generating the edges of the
116 | graph "graph". Edges are represented as list
117 | of two vertices
118 | """
119 | edges = []
120 | for vertex in self.__graph_dict:
121 | for neighbor in self.__graph_dict[vertex]:
122 | edges.append([vertex, neighbor])
123 | return edges
124 |
125 | def __str__(self):
126 | res = "vertices: "
127 | for k in self.__graph_dict:
128 | res += str(k) + " "
129 | res += "\nedges: "
130 | for edge in self.__generate_edges():
131 | res += str(edge) + " "
132 | return res
133 |
134 | class TrafficNetwork(Graph):
135 | ''' TRAFFIC NETWORK CLASS
136 | Traffic network is a combination of basic graph
137 | and the demands, the informations about links, paths
138 | and link-path incidence matrix will be generated
139 | after the initialization.
140 | '''
141 |
142 | def __init__(self, graph= None, O= [], D= []):
143 | Graph.__init__(self, graph)
144 | self.__origins = O
145 | self.__destinations = D
146 | self.__cast()
147 |
148 | # Override of add_edge function, notice that when an edge
149 | # is added, then the links and paths will changes alongside.
150 | # However, it doesn't matter when a vertex is added
151 | def add_edge(self, edge):
152 | Graph.add_edge(self, edge)
153 | self.__cast()
154 |
155 | def add_origin(self, origin):
156 | if origin not in self.__origins:
157 | self.__origins.append(origin)
158 | self.__cast()
159 | else:
160 | print("The origin %s already exists, thus has been ignored!" % origin)
161 |
162 | def add_destination(self, destination):
163 | if destination not in self.__destinations:
164 | self.__destinations.append(destination)
165 | self.__cast()
166 | else:
167 | print("The destination %s already exists, thus has been ignored!" % destination)
168 |
169 | def num_of_links(self):
170 | return len(self.__links)
171 |
172 | def num_of_paths(self):
173 | return len(self.__paths)
174 |
175 | def num_of_OD_pairs(self):
176 | return len(self.__OD_pairs)
177 |
178 | def __cast(self):
179 | """ Calculate or re-calculate the links, paths and
180 | Link-Path incidence matrix
181 | """
182 | if self.__origins != None and self.__destinations != None:
183 | # OD pairs = Origin-Destination Pairs
184 | self.__OD_pairs = self.__generate_OD_pairs()
185 | self.__links = self.edges()
186 | self.__paths, self.__paths_category = self.__generate_paths_by_demands()
187 | # LP Matrix = Link-Path Incidence Matrix
188 | self.__LP_matrix = self.__generate_LP_matrix()
189 |
190 | def __generate_OD_pairs(self):
191 | ''' Generate the OD pairs (Origin-Destination Pairs)
192 | by Cartesian production
193 | '''
194 | OD_pairs = []
195 | for o in self.__origins:
196 | for d in self.__destinations:
197 | OD_pairs.append([o, d])
198 | return OD_pairs
199 |
200 | def __generate_paths_by_demands(self):
201 | """ According the demands, i.e. the origins and the
202 | destinations of the traffic flow, to construct a list
203 | of paths which are necessary for the traffic flow
204 | assignment model
205 | """
206 | paths_by_demands = []
207 | paths_category = []
208 | od_pair_index = 0
209 | for OD_pair in self.__OD_pairs:
210 | paths = self.find_all_paths(*OD_pair)
211 | paths_by_demands.extend(paths)
212 | paths_category.extend([od_pair_index] * len(paths))
213 | od_pair_index += 1
214 | return paths_by_demands, paths_category
215 |
216 | def __generate_LP_matrix(self):
217 | """ Generate the Link-Path incidence matrix Delta:
218 | if the i-th link is on j-th link, then delta_ij = 1,
219 | otherwise delta_ij = 0
220 | """
221 | import numpy as np
222 | n_links = self.num_of_links()
223 | n_paths = self.num_of_paths()
224 | lp_mat = np.zeros(shape= (n_links, n_paths), dtype= int)
225 | path_index = 0
226 | for path in self.__paths:
227 | for i in range(len(path) - 1):
228 | current_link = self.__get_link_from_path_by_order(path, i)
229 | link_index = self.__links.index(current_link)
230 | lp_mat[link_index, path_index] = 1
231 | path_index += 1
232 | return lp_mat
233 |
234 | def __get_link_from_path_by_order(self, path, order):
235 | """ Given a path, which is a list with length N,
236 | search the link by order, which is a integer
237 | in the range [0, N-2]
238 | """
239 | if len(path) >= 2:
240 | if order >= 0 and order <= len(path) - 2:
241 | return [path[order], path[order+1]]
242 | else:
243 | raise ValueError("%d is not in the reasonale range!" % order)
244 | else:
245 | raise ValueError("%s contains only one vertex and cannot be input!" % path)
246 |
247 | def disp_links(self):
248 | ''' Print all the links in the network by order
249 | '''
250 | counter = 0
251 | for link in self.__links:
252 | print("%d : %s" % (counter, link))
253 | counter += 1
254 |
255 | def disp_paths(self):
256 | """ Print all the paths in order according to
257 | given origins and destinations
258 | """
259 | counter = 0
260 | for path in self.__paths:
261 | print("%d : %s " % (counter, path))
262 | counter += 1
263 |
264 | def LP_matrix(self):
265 | ''' Return the Link-Path matrix of
266 | current traffic network
267 | '''
268 | return self.__LP_matrix
269 |
270 | def LP_matrix_rank(self):
271 | ''' Return the rank of Link-Path matrix
272 | of current traffic network
273 | '''
274 | import numpy as np
275 | return np.linalg.matrix_rank(self.__LP_matrix)
276 |
277 | def OD_pairs(self):
278 | """ Return the origin-destination pairs of
279 | current traffic network
280 | """
281 | return self.__OD_pairs
282 |
283 | def paths_category(self):
284 | """ Return a list which implies the conjugacy
285 | between path (self.__paths) and origin-
286 | destinaiton pair (self.__OD_pairs)
287 | """
288 | return self.__paths_category
289 |
290 | def paths(self):
291 | """ Return the paths with respected to given
292 | origins and destinations
293 | """
294 | return self.__paths
--------------------------------------------------------------------------------
/Reference/User-Equilibrium-Solution-master/main.py:
--------------------------------------------------------------------------------
1 | from model import TrafficFlowModel
2 | import data as dt
3 |
4 | # Initialize the model by data
5 | mod = TrafficFlowModel(dt.graph, dt.origins, dt.destinations,
6 | dt.demand, dt.free_time, dt.capacity)
7 |
8 | # Change the accuracy of solution if necessary
9 | mod._conv_accuracy = 1e-6
10 |
11 | # Display all the numerical details of
12 | # each variable during the iteritions
13 | # mod.disp_detail()
14 |
15 | # Set the precision of display, which influences
16 | # only the digit of numerical component in arrays
17 | mod.set_disp_precision(4)
18 |
19 | # Solve the model by Frank-Wolfe Algorithm
20 | mod.solve()
21 |
22 | # Generate report to console
23 | mod.report()
24 |
25 | # Return the solution if necessary
26 | mod._formatted_solution()
--------------------------------------------------------------------------------
/Reference/User-Equilibrium-Solution-master/model.py:
--------------------------------------------------------------------------------
1 | from graph import TrafficNetwork, Graph
2 | import numpy as np
3 |
4 |
5 | class TrafficFlowModel:
6 | ''' TRAFFIC FLOW ASSIGN MODEL
7 | Inside the Frank-Wolfe algorithm is given, one can use
8 | the method `solve` to compute the numerical solution of
9 | User Equilibrium problem.
10 | '''
11 | def __init__(self, graph= None, origins= [], destinations= [],
12 | demands= [], link_free_time= None, link_capacity= None):
13 |
14 | self.__network = TrafficNetwork(graph= graph, O= origins, D= destinations)
15 |
16 | # Initialization of parameters
17 | self.__link_free_time = np.array(link_free_time)
18 | self.__link_capacity = np.array(link_capacity)
19 | self.__demand = np.array(demands)
20 |
21 | # Alpha and beta (used in performance function)
22 | self._alpha = 0.15
23 | self._beta = 4
24 |
25 | # Convergent criterion
26 | self._conv_accuracy = 1e-5
27 |
28 | # Boolean varible: If true print the detail while iterations
29 | self.__detail = False
30 |
31 | # Boolean varible: If true the model is solved properly
32 | self.__solved = False
33 |
34 | # Some variables for contemporarily storing the
35 | # computation result
36 | self.__final_link_flow = None
37 | self.__iterations_times = None
38 |
39 | def __insert_links_in_order(self, links):
40 | ''' Insert the links as the expected order into the
41 | data structure `TrafficFlowModel.__network`
42 | '''
43 | first_vertice = [link[0] for link in links]
44 | for vertex in first_vertice:
45 | self.__network.add_vertex(vertex)
46 | for link in links:
47 | self.__network.add_edge(link)
48 |
49 | def solve(self):
50 | ''' Solve the traffic flow assignment model (user equilibrium)
51 | by Frank-Wolfe algorithm, all the necessary data must be
52 | properly input into the model in advance.
53 |
54 | (Implicitly) Return
55 | ------
56 | self.__solved = True
57 | '''
58 | if self.__detail:
59 | print(self.__dash_line())
60 | print("TRAFFIC FLOW ASSIGN MODEL (USER EQUILIBRIUM) \nFRANK-WOLFE ALGORITHM - DETAIL OF ITERATIONS")
61 | print(self.__dash_line())
62 | print(self.__dash_line())
63 | print("Initialization")
64 | print(self.__dash_line())
65 |
66 | # Step 0: based on the x0, generate the x1
67 | empty_flow = np.zeros(self.__network.num_of_links())
68 | link_flow = self.__all_or_nothing_assign(empty_flow)
69 |
70 | counter = 0
71 | while True:
72 |
73 | if self.__detail:
74 | print(self.__dash_line())
75 | print("Iteration %s" % counter)
76 | print(self.__dash_line())
77 | print("Current link flow:\n%s" % link_flow)
78 |
79 | # Step 1 & Step 2: Use the link flow matrix -x to generate the time, then generate the auxiliary link flow matrix -y
80 | auxiliary_link_flow = self.__all_or_nothing_assign(link_flow)
81 |
82 | # Step 3: Linear Search
83 | opt_theta = self.__golden_section(link_flow, auxiliary_link_flow)
84 |
85 | # Step 4: Using optimal theta to update the link flow matrix
86 | new_link_flow = (1 - opt_theta) * link_flow + opt_theta * auxiliary_link_flow
87 |
88 | # Print the detail if necessary
89 | if self.__detail:
90 | print("Optimal theta: %.8f" % opt_theta)
91 | print("Auxiliary link flow:\n%s" % auxiliary_link_flow)
92 |
93 | # Step 5: Check the Convergence, if FALSE, then return to Step 1
94 | if self.__is_convergent(link_flow, new_link_flow):
95 | if self.__detail:
96 | print(self.__dash_line())
97 | self.__solved = True
98 | self.__final_link_flow = new_link_flow
99 | self.__iterations_times = counter
100 | break
101 | else:
102 | link_flow = new_link_flow
103 | counter += 1
104 |
105 | def _formatted_solution(self):
106 | ''' According to the link flow we obtained in `solve`,
107 | generate a tuple which contains four elements:
108 | `link flow`, `link travel time`, `path travel time` and
109 | `link vehicle capacity ratio`. This function is exposed
110 | to users in case they need to do some extensions based
111 | on the computation result.
112 | '''
113 | if self.__solved:
114 | link_flow = self.__final_link_flow
115 | link_time = self.__link_flow_to_link_time(link_flow)
116 | path_time = self.__link_time_to_path_time(link_time)
117 | link_vc = link_flow / self.__link_capacity
118 | return link_flow, link_time, path_time, link_vc
119 | else:
120 | return None
121 |
122 | def report(self):
123 | ''' Generate the report of the result in console,
124 | this function can be invoked only after the
125 | model is solved.
126 | '''
127 | if self.__solved:
128 | # Print the input of the model
129 | print(self)
130 |
131 | # Print the report
132 |
133 | # Do the computation
134 | link_flow, link_time, path_time, link_vc = self._formatted_solution()
135 |
136 | print(self.__dash_line())
137 | print("TRAFFIC FLOW ASSIGN MODEL (USER EQUILIBRIUM) \nFRANK-WOLFE ALGORITHM - REPORT OF SOLUTION")
138 | print(self.__dash_line())
139 | print(self.__dash_line())
140 | print("TIMES OF ITERATION : %d" % self.__iterations_times)
141 | print(self.__dash_line())
142 | print(self.__dash_line())
143 | print("PERFORMANCE OF LINKS")
144 | print(self.__dash_line())
145 | for i in range(self.__network.num_of_links()):
146 | print("%2d : link= %12s, flow= %8.2f, time= %8.3f, v/c= %.3f" % (i, self.__network.edges()[i], link_flow[i], link_time[i], link_vc[i]))
147 | print(self.__dash_line())
148 | print("PERFORMANCE OF PATHS (GROUP BY ORIGIN-DESTINATION PAIR)")
149 | print(self.__dash_line())
150 | counter = 0
151 | for i in range(self.__network.num_of_paths()):
152 | if counter < self.__network.paths_category()[i]:
153 | counter = counter + 1
154 | print(self.__dash_line())
155 | print("%2d : group= %2d, time= %8.3f, path= %s" % (i, self.__network.paths_category()[i], path_time[i], self.__network.paths()[i]))
156 | print(self.__dash_line())
157 | else:
158 | raise ValueError("The report could be generated only after the model is solved!")
159 |
160 | def __all_or_nothing_assign(self, link_flow):
161 | ''' Perform the all-or-nothing assignment of
162 | Frank-Wolfe algorithm in the User Equilibrium
163 | Traffic Assignment Model.
164 | This assignment aims to assign all the traffic
165 | flow, within given origin and destination, into
166 | the least time consuming path
167 |
168 | Input: link flow -> Output: new link flow
169 | The input is an array.
170 | '''
171 | # LINK FLOW -> LINK TIME
172 | link_time = self.__link_flow_to_link_time(link_flow)
173 | # LINK TIME -> PATH TIME
174 | path_time = self.__link_time_to_path_time(link_time)
175 |
176 | # PATH TIME -> PATH FLOW
177 | # Find the minimal traveling time within group
178 | # (splited by origin - destination pairs) and
179 | # assign all the flow to that path
180 | path_flow = np.zeros(self.__network.num_of_paths())
181 | for OD_pair_index in range(self.__network.num_of_OD_pairs()):
182 | indice_grouped = []
183 | for path_index in range(self.__network.num_of_paths()):
184 | if self.__network.paths_category()[path_index] == OD_pair_index:
185 | indice_grouped.append(path_index)
186 | sub_path_time = [path_time[ind] for ind in indice_grouped]
187 | min_in_group = min(sub_path_time)
188 | ind_min = sub_path_time.index(min_in_group)
189 | target_path_ind = indice_grouped[ind_min]
190 | path_flow[target_path_ind] = self.__demand[OD_pair_index]
191 | if self.__detail:
192 | print("Link time:\n%s" % link_time)
193 | print("Path flow:\n%s" % path_flow)
194 | print("Path time:\n%s" % path_time)
195 |
196 | # PATH FLOW -> LINK FLOW
197 | new_link_flow = self.__path_flow_to_link_flow(path_flow)
198 |
199 | return new_link_flow
200 |
201 | def __link_flow_to_link_time(self, link_flow):
202 | ''' Based on current link flow, use link
203 | time performance function to compute the link
204 | traveling time.
205 | The input is an array.
206 | '''
207 | n_links = self.__network.num_of_links()
208 | link_time = np.zeros(n_links)
209 | for i in range(n_links):
210 | link_time[i] = self.__link_time_performance(link_flow[i], self.__link_free_time[i], self.__link_capacity[i])
211 | return link_time
212 |
213 | def __link_time_to_path_time(self, link_time):
214 | ''' Based on current link traveling time,
215 | use link-path incidence matrix to compute
216 | the path traveling time.
217 | The input is an array.
218 | '''
219 | path_time = link_time.dot(self.__network.LP_matrix())
220 | return path_time
221 |
222 | def __path_flow_to_link_flow(self, path_flow):
223 | ''' Based on current path flow, use link-path incidence
224 | matrix to compute the traffic flow on each link.
225 | The input is an array.
226 | '''
227 | link_flow = self.__network.LP_matrix().dot(path_flow)
228 | return link_flow
229 |
230 | def _get_path_free_time(self):
231 | ''' Only used in the final evaluation, not the recursive structure
232 | '''
233 | path_free_time = self.__link_free_time.dot(self.__network.LP_matrix())
234 | return path_free_time
235 |
236 | def __link_time_performance(self, link_flow, t0, capacity):
237 | ''' Performance function, which indicates the relationship
238 | between flows (traffic volume) and travel time on
239 | the same link. According to the suggestion from Federal
240 | Highway Administration (FHWA) of America, we could use
241 | the following function:
242 | t = t0 * (1 + alpha * (flow / capacity))^beta
243 | '''
244 | value = t0 * (1 + self._alpha * ((link_flow/capacity)**self._beta))
245 | return value
246 |
247 | def __link_time_performance_integrated(self, link_flow, t0, capacity):
248 | ''' The integrated (with repsect to link flow) form of
249 | aforementioned performance function.
250 | '''
251 | val1 = t0 * link_flow
252 | # Some optimization should be implemented for avoiding overflow
253 | val2 = (self._alpha * t0 * link_flow / (self._beta + 1)) * (link_flow / capacity)**self._beta
254 | value = val1 + val2
255 | return value
256 |
257 | def __object_function(self, mixed_flow):
258 | ''' Objective function in the linear search step
259 | of the optimization model of user equilibrium
260 | traffic assignment problem, the only variable
261 | is mixed_flow in this case.
262 | '''
263 | val = 0
264 | for i in range(self.__network.num_of_links()):
265 | val += self.__link_time_performance_integrated(link_flow= mixed_flow[i], t0= self.__link_free_time[i], capacity= self.__link_capacity[i])
266 | return val
267 |
268 | def __golden_section(self, link_flow, auxiliary_link_flow, accuracy= 1e-8):
269 | ''' The golden-section search is a technique for
270 | finding the extremum of a strictly unimodal
271 | function by successively narrowing the range
272 | of values inside which the extremum is known
273 | to exist. The accuracy is suggested to be set
274 | as 1e-8. For more details please refer to:
275 | https://en.wikipedia.org/wiki/Golden-section_search
276 | '''
277 | # Initial params, notice that in our case the
278 | # optimal theta must be in the interval [0, 1]
279 | LB = 0
280 | UB = 1
281 | goldenPoint = 0.618
282 | leftX = LB + (1 - goldenPoint) * (UB - LB)
283 | rightX = LB + goldenPoint * (UB - LB)
284 | while True:
285 | val_left = self.__object_function((1 - leftX) * link_flow + leftX * auxiliary_link_flow)
286 | val_right = self.__object_function((1 - rightX) * link_flow + rightX * auxiliary_link_flow)
287 | if val_left <= val_right:
288 | UB = rightX
289 | else:
290 | LB = leftX
291 | if abs(LB - UB) < accuracy:
292 | opt_theta = (rightX + leftX) / 2.0
293 | return opt_theta
294 | else:
295 | if val_left <= val_right:
296 | rightX = leftX
297 | leftX = LB + (1 - goldenPoint) * (UB - LB)
298 | else:
299 | leftX = rightX
300 | rightX = LB + goldenPoint*(UB - LB)
301 |
302 | def __is_convergent(self, flow1, flow2):
303 | ''' Regard those two link flows lists as the point
304 | in Euclidean space R^n, then judge the convergence
305 | under given accuracy criterion.
306 | Here the formula
307 | ERR = || x_{k+1} - x_{k} || / || x_{k} ||
308 | is recommended.
309 | '''
310 | err = np.linalg.norm(flow1 - flow2) / np.linalg.norm(flow1)
311 | if self.__detail:
312 | print("ERR: %.8f" % err)
313 | if err < self._conv_accuracy:
314 | return True
315 | else:
316 | return False
317 |
318 | def disp_detail(self):
319 | ''' Display all the numerical details of each variable
320 | during the iteritions.
321 | '''
322 | self.__detail = True
323 |
324 | def set_disp_precision(self, precision):
325 | ''' Set the precision of display, which influences only
326 | the digit of numerical component in arrays.
327 | '''
328 | np.set_printoptions(precision= precision)
329 |
330 | def __dash_line(self):
331 | ''' Return a string which consistently
332 | contains '-' with fixed length
333 | '''
334 | return "-" * 80
335 |
336 | def __str__(self):
337 | string = ""
338 | string += self.__dash_line()
339 | string += "\n"
340 | string += "TRAFFIC FLOW ASSIGN MODEL (USER EQUILIBRIUM) \nFRANK-WOLFE ALGORITHM - PARAMS OF MODEL"
341 | string += "\n"
342 | string += self.__dash_line()
343 | string += "\n"
344 | string += self.__dash_line()
345 | string += "\n"
346 | string += "LINK Information:\n"
347 | string += self.__dash_line()
348 | string += "\n"
349 | for i in range(self.__network.num_of_links()):
350 | string += "%2d : link= %s, free time= %.2f, capacity= %s \n" % (i, self.__network.edges()[i], self.__link_free_time[i], self.__link_capacity[i])
351 | string += self.__dash_line()
352 | string += "\n"
353 | string += "OD Pairs Information:\n"
354 | string += self.__dash_line()
355 | string += "\n"
356 | for i in range(self.__network.num_of_OD_pairs()):
357 | string += "%2d : OD pair= %s, demand= %d \n" % (i, self.__network.OD_pairs()[i], self.__demand[i])
358 | string += self.__dash_line()
359 | string += "\n"
360 | string += "Path Information:\n"
361 | string += self.__dash_line()
362 | string += "\n"
363 | for i in range(self.__network.num_of_paths()):
364 | string += "%2d : Conjugated OD pair= %s, Path= %s \n" % (i, self.__network.paths_category()[i], self.__network.paths()[i])
365 | string += self.__dash_line()
366 | string += "\n"
367 | string += f"Link-Path Incidence Matrix (Rank: {self.__network.LP_matrix_rank()}):\n"
368 | string += self.__dash_line()
369 | string += "\n"
370 | string += str(self.__network.LP_matrix())
371 | return string
--------------------------------------------------------------------------------
/Reference/User-Equilibrium-Solution-master/static/NETWORK.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/qizidog/Traffic-Network-Design/958dd68126647056adf2933cf2328c326088e14b/Reference/User-Equilibrium-Solution-master/static/NETWORK.png
--------------------------------------------------------------------------------
/Reference/User-Equilibrium-Solution-master/static/user-equilibrium-solution.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/qizidog/Traffic-Network-Design/958dd68126647056adf2933cf2328c326088e14b/Reference/User-Equilibrium-Solution-master/static/user-equilibrium-solution.pdf
--------------------------------------------------------------------------------
/Reference/t-f-algorithm/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2018 Zheng Li
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/Reference/t-f-algorithm/README.md:
--------------------------------------------------------------------------------
1 | # USER-EQUILIBRIUM-SOLUTION
2 |
3 | User equilibrium is a classical problem on the traffic flow assignment in the field of Transportation Engineering, its main idea is: Every driver cannot reduce his travel time by unilaterally change his travel route.
4 |
5 | ## THEORY OF USER EQUILIBRIUM SOLUTION
6 |
7 | Please refer to [User-Equilibrium-Solution.pdf](static/user-equilibrium-solution.pdf).
8 |
9 | ### Abstract
10 |
11 | We have given an equivalent formulation, which is a convex optimization problem, of finding user equilibrium solution in the traffic flow assignment, with proof of the equivalence. For the equivalent formulation, we have demonstrated the existence and uniqueness of minimizer. Moreover, the variant of Frank-Wolfe Algorithm is introduced for numerically solving the equivalent formulation.
12 |
13 | ### Contents
14 |
15 | + Statement of Problem
16 | + Decision Variables and Parameters
17 | + Objective and Definition of User Equilibrium
18 | + Equivalent Mathematical Formulation
19 | + Statement of Equivalent Formulation
20 | + Existence of Minimizer
21 | + Convexity of Equivalent Formulation
22 | + Review on Constrained Problems
23 | + Demonstration of Equivalence
24 | + Introduction to Frank-Wolfe Algorithm
25 |
26 | ## INSTRUCTIONS OF PROGRAM
27 |
28 | All the things are done within 3 main procedures, implement them in `main.py`:
29 |
30 | ### 1. Data input
31 |
32 | All the data must be introduced into model by the constructor `TrafficFlowModel.__init__`.
33 |
34 | ### 2. Solve
35 |
36 | Invoke `TrafficFlowModel.solve`.
37 |
38 | ### 3. Output report
39 |
40 | Invoke `TrafficFlowModel.report`.
41 |
42 | Then you can just run `$ python main.py`.
43 |
44 | ## TIPS
45 |
46 | 1. Parameters in the link performance function such as `TrafficFlowModel._alpha` and `TrafficFlowModel._beta` are directly exposed to users, one can revise them if necessary.
47 | 2. Notice the mutual correspondence between the input data while writing them into the `data.py`.
48 | 3. When the program doesn't go well, please firstly use `TrafficFlowModel.__str__` (which is already contained in `TrafficFlowModel.report`) to print all the current parameters for ensuring all the data having been introduced into model correctly.
49 | 4. In the file `main.py`, all the most-used methods of `TrafficFlowModel` class are given, which are guidelines for the user; and all functions in the repository are more or less with illustrations.
50 | 5. It happens that the travelling time of paths in each group are not approximately equal (Thanks to [@Sword-holder](https://github.com/Sword-holder) and his team members for pointing out this phenomenon), since some paths have zero flow. However, in general the number of paths is greater than that of links, which implies the linear mapping from `path_flow` to `link_flow` cannot be injective, so we cannot mathematically obtain the `path_flow` from the `link_flow`, since the inverse mapping does not exist. But this does not influence the existence of unique optimal `path_flow`, the optimal `link_flow` obtained by Frank-Wolfe algorithm is the image of optimal `path_flow` under aforementioned linear mapping.
51 | 6. This program might not be numerical stable when it encounters big road network.
52 | 7. If you have trouble with implementing of model, or find some bugs, please contact [me](mailto:zheng.andrea.li@gmail.com).
53 |
54 | ## SAMPLE
55 |
56 | This sample was provided by Prof. [F. Xiao](https://scholar.google.com/citations?user=prn-uaQAAAAJ) within his lectures at [Southwest Jiaotong University](https://english.swjtu.edu.cn/), and you can find all the data of this toy sample in `data.py`.
57 |
58 | ### Graph display
59 |
60 | 
61 |
62 | ### Parameters of links
63 |
64 | | LINK | LENGTH | NO. OF LANES | FREE FLOW SPEED | CAPACITY PER LANE|
65 | | :-----: | :----: | :----------: | :-------------: | :---------------:|
66 | | 5 - 7 | 10.0 | 2 | 60 | 1800 |
67 | | 5 - 9 | 10.0 | 2 | 60 | 1800 |
68 | | 6 - 7 | 10.0 | 2 | 60 | 1800 |
69 | | 6 - 8 | 14.1 | 2 | 60 | 1800 |
70 | | 7 - 8 | 10.0 | 2 | 60 | 1800 |
71 | | 7 - 10 | 10.0 | 2 | 60 | 1800 |
72 | | 8 - 11 | 10.0 | 2 | 60 | 1800 |
73 | | 8 - 12 | 14.1 | 2 | 60 | 1800 |
74 | | 9 - 10 | 10.0 | 2 | 60 | 1800 |
75 | | 9 - 16 | 22.4 | 2 | 60 | 1800 |
76 | | 10 - 11 | 10.0 | 2 | 60 | 1800 |
77 | | 10 - 13 | 10.0 | 2 | 60 | 1800 |
78 | | 11 - 14 | 10.0 | 2 | 60 | 1800 |
79 | | 12 - 15 | 10.0 | 2 | 60 | 1800 |
80 | | 13 - 14 | 10.0 | 2 | 60 | 1800 |
81 | | 13 - 16 | 10.0 | 2 | 60 | 1800 |
82 | | 14 - 15 | 10.0 | 2 | 60 | 1800 |
83 | | 14 - 17 | 10.0 | 2 | 60 | 1800 |
84 | | 16 - 17 | 10.0 | 2 | 60 | 1800 |
85 |
86 | ### Origin-destination pairs and demands
87 |
88 | | DEMAND | 15 | 17 |
89 | | ------ | :--- | :--: |
90 | | 5 | 6000 | 6750 |
91 | | 6 | 7500 | 5250 |
92 |
93 | ### Report of solution (printed in console)
94 |
95 | ```python
96 | # --------------------------------------------------------------------------------
97 | # TRAFFIC FLOW ASSIGN MODEL (USER EQUILIBRIUM)
98 | # FRANK-WOLFE ALGORITHM - PARAMS OF MODEL
99 | # --------------------------------------------------------------------------------
100 | # --------------------------------------------------------------------------------
101 | # LINK Information:
102 | # --------------------------------------------------------------------------------
103 | # 0 : link= ['5', '7'], free time= 10.00, capacity= 3600
104 | # 1 : link= ['5', '9'], free time= 10.00, capacity= 3600
105 | # 2 : link= ['6', '7'], free time= 10.00, capacity= 3600
106 | # 3 : link= ['6', '8'], free time= 14.10, capacity= 3600
107 | # 4 : link= ['7', '8'], free time= 10.00, capacity= 3600
108 | # 5 : link= ['7', '10'], free time= 10.00, capacity= 3600
109 | # 6 : link= ['8', '11'], free time= 10.00, capacity= 3600
110 | # 7 : link= ['8', '12'], free time= 14.10, capacity= 3600
111 | # 8 : link= ['9', '10'], free time= 10.00, capacity= 3600
112 | # 9 : link= ['9', '16'], free time= 22.40, capacity= 3600
113 | # 10 : link= ['10', '11'], free time= 10.00, capacity= 3600
114 | # 11 : link= ['10', '13'], free time= 10.00, capacity= 3600
115 | # 12 : link= ['11', '14'], free time= 10.00, capacity= 3600
116 | # 13 : link= ['12', '15'], free time= 10.00, capacity= 3600
117 | # 14 : link= ['13', '14'], free time= 10.00, capacity= 3600
118 | # 15 : link= ['13', '16'], free time= 10.00, capacity= 3600
119 | # 16 : link= ['14', '15'], free time= 10.00, capacity= 3600
120 | # 17 : link= ['14', '17'], free time= 10.00, capacity= 3600
121 | # 18 : link= ['16', '17'], free time= 10.00, capacity= 3600
122 | # --------------------------------------------------------------------------------
123 | # OD Pairs Information:
124 | # --------------------------------------------------------------------------------
125 | # 0 : OD pair= ['5', '15'], demand= 6000
126 | # 1 : OD pair= ['5', '17'], demand= 6750
127 | # 2 : OD pair= ['6', '15'], demand= 7500
128 | # 3 : OD pair= ['6', '17'], demand= 5250
129 | # --------------------------------------------------------------------------------
130 | # Path Information:
131 | # --------------------------------------------------------------------------------
132 | # 0 : Conjugated OD pair= 0, Path= ['5', '7', '8', '11', '14', '15']
133 | # 1 : Conjugated OD pair= 0, Path= ['5', '7', '8', '12', '15']
134 | # 2 : Conjugated OD pair= 0, Path= ['5', '7', '10', '11', '14', '15']
135 | # 3 : Conjugated OD pair= 0, Path= ['5', '7', '10', '13', '14', '15']
136 | # 4 : Conjugated OD pair= 0, Path= ['5', '9', '10', '11', '14', '15']
137 | # 5 : Conjugated OD pair= 0, Path= ['5', '9', '10', '13', '14', '15']
138 | # 6 : Conjugated OD pair= 1, Path= ['5', '7', '8', '11', '14', '17']
139 | # 7 : Conjugated OD pair= 1, Path= ['5', '7', '10', '11', '14', '17']
140 | # 8 : Conjugated OD pair= 1, Path= ['5', '7', '10', '13', '14', '17']
141 | # 9 : Conjugated OD pair= 1, Path= ['5', '7', '10', '13', '16', '17']
142 | # 10 : Conjugated OD pair= 1, Path= ['5', '9', '10', '11', '14', '17']
143 | # 11 : Conjugated OD pair= 1, Path= ['5', '9', '10', '13', '14', '17']
144 | # 12 : Conjugated OD pair= 1, Path= ['5', '9', '10', '13', '16', '17']
145 | # 13 : Conjugated OD pair= 1, Path= ['5', '9', '16', '17']
146 | # 14 : Conjugated OD pair= 2, Path= ['6', '7', '8', '11', '14', '15']
147 | # 15 : Conjugated OD pair= 2, Path= ['6', '7', '8', '12', '15']
148 | # 16 : Conjugated OD pair= 2, Path= ['6', '7', '10', '11', '14', '15']
149 | # 17 : Conjugated OD pair= 2, Path= ['6', '7', '10', '13', '14', '15']
150 | # 18 : Conjugated OD pair= 2, Path= ['6', '8', '11', '14', '15']
151 | # 19 : Conjugated OD pair= 2, Path= ['6', '8', '12', '15']
152 | # 20 : Conjugated OD pair= 3, Path= ['6', '7', '8', '11', '14', '17']
153 | # 21 : Conjugated OD pair= 3, Path= ['6', '7', '10', '11', '14', '17']
154 | # 22 : Conjugated OD pair= 3, Path= ['6', '7', '10', '13', '14', '17']
155 | # 23 : Conjugated OD pair= 3, Path= ['6', '7', '10', '13', '16', '17']
156 | # 24 : Conjugated OD pair= 3, Path= ['6', '8', '11', '14', '17']
157 | # --------------------------------------------------------------------------------
158 | # Link - Path Incidence Matrix:
159 | # --------------------------------------------------------------------------------
160 | # [[1 1 1 1 0 0 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]
161 | # [0 0 0 0 1 1 0 0 0 0 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0]
162 | # [0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 0 0 1 1 1 1 0]
163 | # [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 1]
164 | # [1 1 0 0 0 0 1 0 0 0 0 0 0 0 1 1 0 0 0 0 1 0 0 0 0]
165 | # [0 0 1 1 0 0 0 1 1 1 0 0 0 0 0 0 1 1 0 0 0 1 1 1 0]
166 | # [1 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 1 0 1 0 0 0 1]
167 | # [0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1 0 0 0 0 0]
168 | # [0 0 0 0 1 1 0 0 0 0 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0]
169 | # [0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0]
170 | # [0 0 1 0 1 0 0 1 0 0 1 0 0 0 0 0 1 0 0 0 0 1 0 0 0]
171 | # [0 0 0 1 0 1 0 0 1 1 0 1 1 0 0 0 0 1 0 0 0 0 1 1 0]
172 | # [1 0 1 0 1 0 1 1 0 0 1 0 0 0 1 0 1 0 1 0 1 1 0 0 1]
173 | # [0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1 0 0 0 0 0]
174 | # [0 0 0 1 0 1 0 0 1 0 0 1 0 0 0 0 0 1 0 0 0 0 1 0 0]
175 | # [0 0 0 0 0 0 0 0 0 1 0 0 1 0 0 0 0 0 0 0 0 0 0 1 0]
176 | # [1 0 1 1 1 1 0 0 0 0 0 0 0 0 1 0 1 1 1 0 0 0 0 0 0]
177 | # [0 0 0 0 0 0 1 1 1 0 1 1 0 0 0 0 0 0 0 0 1 1 1 0 1]
178 | # [0 0 0 0 0 0 0 0 0 1 0 0 1 1 0 0 0 0 0 0 0 0 0 1 0]]
179 | # --------------------------------------------------------------------------------
180 | # TRAFFIC FLOW ASSIGN MODEL (USER EQUILIBRIUM)
181 | # FRANK-WOLFE ALGORITHM - REPORT OF SOLUTION
182 | # --------------------------------------------------------------------------------
183 | # --------------------------------------------------------------------------------
184 | # TIMES OF ITERATION : 1199
185 | # --------------------------------------------------------------------------------
186 | # --------------------------------------------------------------------------------
187 | # PERFORMANCE OF LINKS
188 | # --------------------------------------------------------------------------------
189 | # 0 : link= ['5', '7'], flow= 5632.68, time= 18.99, v/c= 1.565
190 | # 1 : link= ['5', '9'], flow= 7117.32, time= 32.92, v/c= 1.977
191 | # 2 : link= ['6', '7'], flow= 6048.31, time= 21.95, v/c= 1.680
192 | # 3 : link= ['6', '8'], flow= 6701.69, time= 39.50, v/c= 1.862
193 | # 4 : link= ['7', '8'], flow= 5392.05, time= 17.55, v/c= 1.498
194 | # 5 : link= ['7', '10'], flow= 6288.95, time= 23.97, v/c= 1.747
195 | # 6 : link= ['8', '11'], flow= 5191.43, time= 16.49, v/c= 1.442
196 | # 7 : link= ['8', '12'], flow= 6902.30, time= 42.68, v/c= 1.917
197 | # 8 : link= ['9', '10'], flow= 1481.14, time= 10.04, v/c= 0.411
198 | # 9 : link= ['9', '16'], flow= 5636.18, time= 42.59, v/c= 1.566
199 | # 10 : link= ['10', '11'], flow= 1648.04, time= 10.07, v/c= 0.458
200 | # 11 : link= ['10', '13'], flow= 6122.05, time= 22.54, v/c= 1.701
201 | # 12 : link= ['11', '14'], flow= 6839.47, time= 29.54, v/c= 1.900
202 | # 13 : link= ['12', '15'], flow= 6902.30, time= 30.27, v/c= 1.917
203 | # 14 : link= ['13', '14'], flow= 5303.10, time= 17.06, v/c= 1.473
204 | # 15 : link= ['13', '16'], flow= 818.95, time= 10.00, v/c= 0.227
205 | # 16 : link= ['14', '15'], flow= 6597.70, time= 26.92, v/c= 1.833
206 | # 17 : link= ['14', '17'], flow= 5544.87, time= 18.44, v/c= 1.540
207 | # 18 : link= ['16', '17'], flow= 6455.13, time= 25.51, v/c= 1.793
208 | # --------------------------------------------------------------------------------
209 | # PERFORMANCE OF PATHS (GROUP BY ORIGIN-DESTINATION PAIR)
210 | # --------------------------------------------------------------------------------
211 | # 0 : group= 0, time= 109.49, path= ['5', '7', '8', '11', '14', '15']
212 | # 1 : group= 0, time= 109.49, path= ['5', '7', '8', '12', '15']
213 | # 2 : group= 0, time= 109.49, path= ['5', '7', '10', '11', '14', '15']
214 | # 3 : group= 0, time= 109.49, path= ['5', '7', '10', '13', '14', '15']
215 | # 4 : group= 0, time= 109.49, path= ['5', '9', '10', '11', '14', '15']
216 | # 5 : group= 0, time= 109.49, path= ['5', '9', '10', '13', '14', '15']
217 | # 6 : group= 1, time= 101.01, path= ['5', '7', '8', '11', '14', '17']
218 | # 7 : group= 1, time= 101.01, path= ['5', '7', '10', '11', '14', '17']
219 | # 8 : group= 1, time= 101.01, path= ['5', '7', '10', '13', '14', '17']
220 | # 9 : group= 1, time= 101.01, path= ['5', '7', '10', '13', '16', '17']
221 | # 10 : group= 1, time= 101.01, path= ['5', '9', '10', '11', '14', '17']
222 | # 11 : group= 1, time= 101.01, path= ['5', '9', '10', '13', '14', '17']
223 | # 12 : group= 1, time= 101.01, path= ['5', '9', '10', '13', '16', '17']
224 | # 13 : group= 1, time= 101.01, path= ['5', '9', '16', '17']
225 | # 14 : group= 2, time= 112.45, path= ['6', '7', '8', '11', '14', '15']
226 | # 15 : group= 2, time= 112.45, path= ['6', '7', '8', '12', '15']
227 | # 16 : group= 2, time= 112.45, path= ['6', '7', '10', '11', '14', '15']
228 | # 17 : group= 2, time= 112.45, path= ['6', '7', '10', '13', '14', '15']
229 | # 18 : group= 2, time= 112.45, path= ['6', '8', '11', '14', '15']
230 | # 19 : group= 2, time= 112.45, path= ['6', '8', '12', '15']
231 | # 20 : group= 3, time= 103.97, path= ['6', '7', '8', '11', '14', '17']
232 | # 21 : group= 3, time= 103.97, path= ['6', '7', '10', '11', '14', '17']
233 | # 22 : group= 3, time= 103.97, path= ['6', '7', '10', '13', '14', '17']
234 | # 23 : group= 3, time= 103.98, path= ['6', '7', '10', '13', '16', '17']
235 | # 24 : group= 3, time= 103.97, path= ['6', '8', '11', '14', '17']
236 | ```
237 |
--------------------------------------------------------------------------------
/Reference/t-f-algorithm/__pycache__/data.cpython-36.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/qizidog/Traffic-Network-Design/958dd68126647056adf2933cf2328c326088e14b/Reference/t-f-algorithm/__pycache__/data.cpython-36.pyc
--------------------------------------------------------------------------------
/Reference/t-f-algorithm/__pycache__/data.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/qizidog/Traffic-Network-Design/958dd68126647056adf2933cf2328c326088e14b/Reference/t-f-algorithm/__pycache__/data.cpython-37.pyc
--------------------------------------------------------------------------------
/Reference/t-f-algorithm/__pycache__/graph.cpython-36.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/qizidog/Traffic-Network-Design/958dd68126647056adf2933cf2328c326088e14b/Reference/t-f-algorithm/__pycache__/graph.cpython-36.pyc
--------------------------------------------------------------------------------
/Reference/t-f-algorithm/__pycache__/graph.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/qizidog/Traffic-Network-Design/958dd68126647056adf2933cf2328c326088e14b/Reference/t-f-algorithm/__pycache__/graph.cpython-37.pyc
--------------------------------------------------------------------------------
/Reference/t-f-algorithm/__pycache__/model.cpython-36.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/qizidog/Traffic-Network-Design/958dd68126647056adf2933cf2328c326088e14b/Reference/t-f-algorithm/__pycache__/model.cpython-36.pyc
--------------------------------------------------------------------------------
/Reference/t-f-algorithm/__pycache__/model.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/qizidog/Traffic-Network-Design/958dd68126647056adf2933cf2328c326088e14b/Reference/t-f-algorithm/__pycache__/model.cpython-37.pyc
--------------------------------------------------------------------------------
/Reference/t-f-algorithm/data.py:
--------------------------------------------------------------------------------
1 | """ SAMPLE
2 | In this file you can find sample data which could be used
3 | into the TrafficFlowMod class in model.py file
4 | """
5 |
6 | # Graph represented by directed dictionary
7 | # In order: first ("5", "7"), second ("5", "9"), third ("6", "7")...
8 | graph = [
9 | ("1", ["2", "3"]),
10 | ("2", ["3", "4"]),
11 | ("3", ["4"]),
12 | ("4", [])
13 | ]
14 |
15 | # Capacity of each link (Conjugated to Graph with order)
16 | # Here all the 19 links have the same capacity
17 | capacity = [45+8.4828, 40+7.6246, 70+0.0001, 40+6.5432, 45+7.4799]
18 |
19 | # Free travel time of each link (Conjugated to Graph with order)
20 | free_time = [
21 | 4, 6, 2, 5, 3
22 | ]
23 |
24 | # Origin-destination pairs
25 | origins = ["1"]
26 | destinations = ["4"]
27 | # Generated ordered OD pairs:
28 | # first ("5", "15"), second ("5", "17"), third ("6", "15")...
29 |
30 |
31 | # Demand between each OD pair (Conjugated to the Cartesian
32 | # product of Origins and destinations with order)
33 | demand = [180]
34 |
35 |
--------------------------------------------------------------------------------
/Reference/t-f-algorithm/graph.py:
--------------------------------------------------------------------------------
1 |
2 | class Graph(object):
3 | """ DIRECTED GRAPH CLASS
4 |
5 | A simple Python graph class, demonstrating the essential
6 | facts and functionalities of directed graphs, and it is
7 | designed for our traffic flow assignment problem, thus we
8 | have the following assumptions:
9 |
10 | 1. The graph contains no self-loop, that is, an edge that
11 | connects a vertex to itself;
12 |
13 | 2. There is at most one edge which connects two vertice;
14 |
15 | Revised from: https://www.python-course.eu/graphs_python.php
16 | and in our case we must give order to all the edges, thus we
17 | do not use the unordered data structure.
18 | """
19 |
20 | def __init__(self, graph_dict= None):
21 | """ initializes a directed graph object by a dictionary,
22 | If no dictionary or None is given, an empty dictionary
23 | will be used. Notice that this initial graph cannot
24 | contain a self-loop.
25 | """
26 | from collections import OrderedDict
27 | if graph_dict == None:
28 | graph_dict = OrderedDict()
29 | self.__graph_dict = OrderedDict(graph_dict)
30 | if self.__is_with_loop():
31 | raise ValueError("The graph are supposed to be without self-loop please recheck the input data!")
32 |
33 | def vertices(self):
34 | """ returns the vertices of a graph
35 | """
36 | return list(self.__graph_dict.keys())
37 |
38 | def edges(self):
39 | """ returns the edges of a graph
40 | """
41 | return self.__generate_edges()
42 |
43 | def add_vertex(self, vertex):
44 | """ If the vertex "vertex" is not in
45 | self.__graph_dict, a key "vertex" with an empty
46 | list as a value is added to the dictionary.
47 | Otherwise nothing has to be done.
48 | """
49 | if vertex not in self.__graph_dict:
50 | self.__graph_dict[vertex] = []
51 | else:
52 | print("The vertex %s already exists in the graph, thus it has been ignored!" % vertex)
53 |
54 | def add_edge(self, edge):
55 | """ Assume that edge is ordered, and between two
56 | vertices there could exists only one edge.
57 | """
58 | vertex1, vertex2 = self.__decompose_edge(edge)
59 | if not self.__is_edge_in_graph(edge):
60 | if vertex1 in self.__graph_dict:
61 | self.__graph_dict[vertex1].append(vertex2)
62 | if vertex2 not in self.__graph_dict:
63 | self.__graph_dict[vertex2] = []
64 | else:
65 | self.__graph_dict[vertex1] = [vertex2]
66 | else:
67 | print("The edge %s already exists in the graph, thus it has been ignored!" % ([vertex1, vertex2]))
68 |
69 | def find_all_paths(self, start_vertex, end_vertex, path= []):
70 | """ find all simple paths (path with no repeated vertices)
71 | from start vertex to end vertex in graph
72 | """
73 | path = path + [start_vertex]
74 | if start_vertex == end_vertex:
75 | return [path]
76 | paths = []
77 | for neighbor in self.__graph_dict[start_vertex]:
78 | if neighbor not in path:
79 | sub_paths = self.find_all_paths(neighbor, end_vertex, path)
80 | for sub_path in sub_paths:
81 | paths.append(sub_path)
82 | return paths
83 |
84 | def __is_edge_in_graph(self, edge):
85 | """ Judge if an edge is already in the graph
86 | """
87 | vertex1, vertex2 = self.__decompose_edge(edge)
88 | if vertex1 in self.__graph_dict:
89 | if vertex2 in self.__graph_dict[vertex1]:
90 | return True
91 | else:
92 | return False
93 | else:
94 | return False
95 |
96 | def __decompose_edge(self, edge):
97 | """ Input is a list or a tuple with only two elements
98 | """
99 | if (isinstance(edge, list) or isinstance(edge, tuple)) and len(edge) == 2:
100 | return edge[0], edge[1]
101 | else:
102 | raise ValueError("%s is not of type list or tuple or its length does not equal to 2" % edge)
103 |
104 | def __is_with_loop(self):
105 | """ If the graph contains a self-loop, that is, an
106 | edge connects a vertex to itself, then return
107 | True, otherwise return False
108 | """
109 | for vertex in self.__graph_dict:
110 | if vertex in self.__graph_dict[vertex]:
111 | return True
112 | return False
113 |
114 | def __generate_edges(self):
115 | """ A static method generating the edges of the
116 | graph "graph". Edges are represented as list
117 | of two vertices
118 | """
119 | edges = []
120 | for vertex in self.__graph_dict:
121 | for neighbor in self.__graph_dict[vertex]:
122 | edges.append([vertex, neighbor])
123 | return edges
124 |
125 | def __str__(self):
126 | res = "vertices: "
127 | for k in self.__graph_dict:
128 | res += str(k) + " "
129 | res += "\nedges: "
130 | for edge in self.__generate_edges():
131 | res += str(edge) + " "
132 | return res
133 |
134 | class TrafficNetwork(Graph):
135 | ''' TRAFFIC NETWORK CLASS
136 | Traffic network is a combination of basic graph
137 | and the demands, the informations about links, paths
138 | and link-path incidence matrix will be generated
139 | after the initialization.
140 | '''
141 |
142 | def __init__(self, graph= None, O= [], D= []):
143 | Graph.__init__(self, graph)
144 | self.__origins = O
145 | self.__destinations = D
146 | self.__cast()
147 |
148 | # Override of add_edge function, notice that when an edge
149 | # is added, then the links and paths will changes alongside.
150 | # However, it doesn't matter when a vertex is added
151 | def add_edge(self, edge):
152 | Graph.add_edge(self, edge)
153 | self.__cast()
154 |
155 | def add_origin(self, origin):
156 | if origin not in self.__origins:
157 | self.__origins.append(origin)
158 | self.__cast()
159 | else:
160 | print("The origin %s already exists, thus has been ignored!" % origin)
161 |
162 | def add_destination(self, destination):
163 | if destination not in self.__destinations:
164 | self.__destinations.append(destination)
165 | self.__cast()
166 | else:
167 | print("The destination %s already exists, thus has been ignored!" % destination)
168 |
169 | def num_of_links(self):
170 | return len(self.__links)
171 |
172 | def num_of_paths(self):
173 | return len(self.__paths)
174 |
175 | def num_of_OD_pairs(self):
176 | return len(self.__OD_pairs)
177 |
178 | def __cast(self):
179 | """ Calculate or re-calculate the links, paths and
180 | Link-Path incidence matrix
181 | """
182 | if self.__origins != None and self.__destinations != None:
183 | # OD pairs = Origin-Destination Pairs
184 | self.__OD_pairs = self.__generate_OD_pairs()
185 | self.__links = self.edges()
186 | self.__paths, self.__paths_category = self.__generate_paths_by_demands()
187 | # LP Matrix = Link-Path Incidence Matrix
188 | self.__LP_matrix = self.__generate_LP_matrix()
189 |
190 | def __generate_OD_pairs(self):
191 | ''' Generate the OD pairs (Origin-Destination Pairs)
192 | by Cartesian production
193 | '''
194 | OD_pairs = []
195 | for o in self.__origins:
196 | for d in self.__destinations:
197 | OD_pairs.append([o, d])
198 | return OD_pairs
199 |
200 | def __generate_paths_by_demands(self):
201 | """ According the demands, i.e. the origins and the
202 | destinations of the traffic flow, to construct a list
203 | of paths which are necessary for the traffic flow
204 | assignment model
205 | """
206 | paths_by_demands = []
207 | paths_category = []
208 | od_pair_index = 0
209 | for OD_pair in self.__OD_pairs:
210 | paths = self.find_all_paths(*OD_pair)
211 | paths_by_demands.extend(paths)
212 | paths_category.extend([od_pair_index] * len(paths))
213 | od_pair_index += 1
214 | return paths_by_demands, paths_category
215 |
216 | def __generate_LP_matrix(self):
217 | """ Generate the Link-Path incidence matrix Delta:
218 | if the i-th link is on j-th link, then delta_ij = 1,
219 | otherwise delta_ij = 0
220 | """
221 | import numpy as np
222 | n_links = self.num_of_links()
223 | n_paths = self.num_of_paths()
224 | lp_mat = np.zeros(shape= (n_links, n_paths), dtype= int)
225 | path_index = 0
226 | for path in self.__paths:
227 | for i in range(len(path) - 1):
228 | current_link = self.__get_link_from_path_by_order(path, i)
229 | link_index = self.__links.index(current_link)
230 | lp_mat[link_index, path_index] = 1
231 | path_index += 1
232 | return lp_mat
233 |
234 | def __get_link_from_path_by_order(self, path, order):
235 | """ Given a path, which is a list with length N,
236 | search the link by order, which is a integer
237 | in the range [0, N-2]
238 | """
239 | if len(path) >= 2:
240 | if order >= 0 and order <= len(path) - 2:
241 | return [path[order], path[order+1]]
242 | else:
243 | raise ValueError("%d is not in the reasonale range!" % order)
244 | else:
245 | raise ValueError("%s contains only one vertex and cannot be input!" % path)
246 |
247 | def disp_links(self):
248 | ''' Print all the links in the network by order
249 | '''
250 | counter = 0
251 | for link in self.__links:
252 | print("%d : %s" % (counter, link))
253 | counter += 1
254 |
255 | def disp_paths(self):
256 | """ Print all the paths in order according to
257 | given origins and destinations
258 | """
259 | counter = 0
260 | for path in self.__paths:
261 | print("%d : %s " % (counter, path))
262 | counter += 1
263 |
264 | def LP_matrix(self):
265 | ''' Return the Link-Path matrix of
266 | current traffic network
267 | '''
268 | return self.__LP_matrix
269 |
270 | def LP_matrix_rank(self):
271 | ''' Return the rank of Link-Path matrix
272 | of current traffic network
273 | '''
274 | import numpy as np
275 | return np.linalg.matrix_rank(self.__LP_matrix)
276 |
277 | def OD_pairs(self):
278 | """ Return the origin-destination pairs of
279 | current traffic network
280 | """
281 | return self.__OD_pairs
282 |
283 | def paths_category(self):
284 | """ Return a list which implies the conjugacy
285 | between path (self.__paths) and origin-
286 | destinaiton pair (self.__OD_pairs)
287 | """
288 | return self.__paths_category
289 |
290 | def paths(self):
291 | """ Return the paths with respected to given
292 | origins and destinations
293 | """
294 | return self.__paths
--------------------------------------------------------------------------------
/Reference/t-f-algorithm/main.py:
--------------------------------------------------------------------------------
1 | from model import TrafficFlowModel
2 | import data as dt
3 |
4 | # Initialize the model by data
5 | mod = TrafficFlowModel(dt.graph, dt.origins, dt.destinations,
6 | dt.demand, dt.free_time, dt.capacity)
7 |
8 | # Change the accuracy of solution if necessary
9 | # mod._conv_accuracy = 1e-6
10 |
11 | # Display all the numerical details of
12 | # each variable during the iteritions
13 | # mod.disp_detail()
14 |
15 | # Set the precision of display, which influences
16 | # only the digit of numerical component in arrays
17 | # mod.set_disp_precision(4)
18 |
19 | # Solve the model by Frank-Wolfe Algorithm
20 | mod.solve()
21 |
22 | # Generate report to console
23 | mod.report()
24 |
25 | # Return the solution if necessary
26 | flow, link_t, path_t, v_c = mod._formatted_solution()
27 | print("flow: "+str(flow))
28 | print("link_t: "+str(link_t))
29 | print("path_t: "+str(path_t))
30 | print("v_c: "+str(v_c))
31 | print(type(flow))
32 |
--------------------------------------------------------------------------------
/Reference/t-f-algorithm/model.py:
--------------------------------------------------------------------------------
1 | from graph import TrafficNetwork, Graph
2 | import numpy as np
3 |
4 |
5 | class TrafficFlowModel:
6 | ''' TRAFFIC FLOW ASSIGN MODEL
7 | Inside the Frank-Wolfe algorithm is given, one can use
8 | the method `solve` to compute the numerical solution of
9 | User Equilibrium problem.
10 | '''
11 | def __init__(self, graph= None, origins= [], destinations= [],
12 | demands= [], link_free_time= None, link_capacity= None):
13 |
14 | self.__network = TrafficNetwork(graph= graph, O= origins, D= destinations)
15 |
16 | # Initialization of parameters
17 | self.__link_free_time = np.array(link_free_time)
18 | self.__link_capacity = np.array(link_capacity)
19 | self.__demand = np.array(demands)
20 |
21 | # Alpha and beta (used in performance function)
22 | self._alpha = 0.15
23 | self._beta = 4
24 |
25 | # Convergent criterion
26 | self._conv_accuracy = 1e-5
27 |
28 | # Boolean varible: If true print the detail while iterations
29 | self.__detail = False
30 |
31 | # Boolean varible: If true the model is solved properly
32 | self.__solved = False
33 |
34 | # Some variables for contemporarily storing the
35 | # computation result
36 | self.__final_link_flow = None
37 | self.__iterations_times = None
38 |
39 |
40 | def __insert_links_in_order(self, links):
41 | ''' Insert the links as the expected order into the
42 | data structure `TrafficFlowModel.__network`
43 | '''
44 | first_vertice = [link[0] for link in links]
45 | for vertex in first_vertice:
46 | self.__network.add_vertex(vertex)
47 | for link in links:
48 | self.__network.add_edge(link)
49 |
50 | def solve(self):
51 | ''' Solve the traffic flow assignment model (user equilibrium)
52 | by Frank-Wolfe algorithm, all the necessary data must be
53 | properly input into the model in advance.
54 |
55 | (Implicitly) Return
56 | ------
57 | self.__solved = True
58 | '''
59 | if self.__detail:
60 | print(self.__dash_line())
61 | print("TRAFFIC FLOW ASSIGN MODEL (USER EQUILIBRIUM) \nFRANK-WOLFE ALGORITHM - DETAIL OF ITERATIONS")
62 | print(self.__dash_line())
63 | print(self.__dash_line())
64 | print("Initialization")
65 | print(self.__dash_line())
66 |
67 | # Step 0: based on the x0, generate the x1
68 | empty_flow = np.zeros(self.__network.num_of_links())
69 | link_flow = self.__all_or_nothing_assign(empty_flow)
70 |
71 | counter = 0
72 | while True:
73 |
74 | if self.__detail:
75 | print(self.__dash_line())
76 | print("Iteration %s" % counter)
77 | print(self.__dash_line())
78 | print("Current link flow:\n%s" % link_flow)
79 |
80 | # Step 1 & Step 2: Use the link flow matrix -x to generate the time, then generate the auxiliary link flow matrix -y
81 | auxiliary_link_flow = self.__all_or_nothing_assign(link_flow)
82 |
83 | # Step 3: Linear Search
84 | opt_theta = self.__golden_section(link_flow, auxiliary_link_flow)
85 |
86 | # Step 4: Using optimal theta to update the link flow matrix
87 | new_link_flow = (1 - opt_theta) * link_flow + opt_theta * auxiliary_link_flow
88 |
89 | # Print the detail if necessary
90 | if self.__detail:
91 | print("Optimal theta: %.8f" % opt_theta)
92 | print("Auxiliary link flow:\n%s" % auxiliary_link_flow)
93 |
94 | # Step 5: Check the Convergence, if FALSE, then return to Step 1
95 | if self.__is_convergent(link_flow, new_link_flow):
96 | if self.__detail:
97 | print(self.__dash_line())
98 | self.__solved = True
99 | self.__final_link_flow = new_link_flow
100 | self.__iterations_times = counter
101 | break
102 | else:
103 | link_flow = new_link_flow
104 | counter += 1
105 |
106 | def _formatted_solution(self):
107 | ''' According to the link flow we obtained in `solve`,
108 | generate a tuple which contains four elements:
109 | `link flow`, `link travel time`, `path travel time` and
110 | `link vehicle capacity ratio`. This function is exposed
111 | to users in case they need to do some extensions based
112 | on the computation result.
113 | '''
114 | if self.__solved:
115 | link_flow = self.__final_link_flow
116 | link_time = self.__link_flow_to_link_time(link_flow)
117 | path_time = self.__link_time_to_path_time(link_time)
118 | link_vc = link_flow / self.__link_capacity
119 | return link_flow, link_time, path_time, link_vc
120 | else:
121 | return None
122 |
123 | def report(self):
124 | ''' Generate the report of the result in console,
125 | this function can be invoked only after the
126 | model is solved.
127 | '''
128 | if self.__solved:
129 | # Print the input of the model
130 | print(self)
131 |
132 | # Print the report
133 |
134 | # Do the computation
135 | link_flow, link_time, path_time, link_vc = self._formatted_solution()
136 |
137 | print(self.__dash_line())
138 | print("TRAFFIC FLOW ASSIGN MODEL (USER EQUILIBRIUM) \nFRANK-WOLFE ALGORITHM - REPORT OF SOLUTION")
139 | print(self.__dash_line())
140 | print(self.__dash_line())
141 | print("TIMES OF ITERATION : %d" % self.__iterations_times)
142 | print(self.__dash_line())
143 | print(self.__dash_line())
144 | print("PERFORMANCE OF LINKS")
145 | print(self.__dash_line())
146 | for i in range(self.__network.num_of_links()):
147 | print("%2d : link= %12s, flow= %8.2f, time= %8.3f, v/c= %.3f" % (i, self.__network.edges()[i], link_flow[i], link_time[i], link_vc[i]))
148 | print(self.__dash_line())
149 | print("PERFORMANCE OF PATHS (GROUP BY ORIGIN-DESTINATION PAIR)")
150 | print(self.__dash_line())
151 | counter = 0
152 | for i in range(self.__network.num_of_paths()):
153 | if counter < self.__network.paths_category()[i]:
154 | counter = counter + 1
155 | print(self.__dash_line())
156 | print("%2d : group= %2d, time= %8.3f, path= %s" % (i, self.__network.paths_category()[i], path_time[i], self.__network.paths()[i]))
157 | print(self.__dash_line())
158 | else:
159 | raise ValueError("The report could be generated only after the model is solved!")
160 |
161 | def __all_or_nothing_assign(self, link_flow):
162 | ''' Perform the all-or-nothing assignment of
163 | Frank-Wolfe algorithm in the User Equilibrium
164 | Traffic Assignment Model.
165 | This assignment aims to assign all the traffic
166 | flow, within given origin and destination, into
167 | the least time consuming path
168 |
169 | Input: link flow -> Output: new link flow
170 | The input is an array.
171 | '''
172 | # LINK FLOW -> LINK TIME
173 | link_time = self.__link_flow_to_link_time(link_flow)
174 | # LINK TIME -> PATH TIME
175 | path_time = self.__link_time_to_path_time(link_time)
176 |
177 | # PATH TIME -> PATH FLOW
178 | # Find the minimal traveling time within group
179 | # (splited by origin - destination pairs) and
180 | # assign all the flow to that path
181 | path_flow = np.zeros(self.__network.num_of_paths())
182 | for OD_pair_index in range(self.__network.num_of_OD_pairs()):
183 | indice_grouped = []
184 | for path_index in range(self.__network.num_of_paths()):
185 | if self.__network.paths_category()[path_index] == OD_pair_index:
186 | indice_grouped.append(path_index)
187 | sub_path_time = [path_time[ind] for ind in indice_grouped]
188 | min_in_group = min(sub_path_time)
189 | ind_min = sub_path_time.index(min_in_group)
190 | target_path_ind = indice_grouped[ind_min]
191 | path_flow[target_path_ind] = self.__demand[OD_pair_index]
192 | if self.__detail:
193 | print("Link time:\n%s" % link_time)
194 | print("Path flow:\n%s" % path_flow)
195 | print("Path time:\n%s" % path_time)
196 |
197 | # PATH FLOW -> LINK FLOW
198 | new_link_flow = self.__path_flow_to_link_flow(path_flow)
199 |
200 | return new_link_flow
201 |
202 | def __link_flow_to_link_time(self, link_flow):
203 | ''' Based on current link flow, use link
204 | time performance function to compute the link
205 | traveling time.
206 | The input is an array.
207 | '''
208 | n_links = self.__network.num_of_links()
209 | link_time = np.zeros(n_links)
210 | for i in range(n_links):
211 | link_time[i] = self.__link_time_performance(link_flow[i], self.__link_free_time[i], self.__link_capacity[i])
212 | return link_time
213 |
214 | def __link_time_to_path_time(self, link_time):
215 | ''' Based on current link traveling time,
216 | use link-path incidence matrix to compute
217 | the path traveling time.
218 | The input is an array.
219 | '''
220 | path_time = link_time.dot(self.__network.LP_matrix())
221 | return path_time
222 |
223 | def __path_flow_to_link_flow(self, path_flow):
224 | ''' Based on current path flow, use link-path incidence
225 | matrix to compute the traffic flow on each link.
226 | The input is an array.
227 | '''
228 | link_flow = self.__network.LP_matrix().dot(path_flow)
229 | return link_flow
230 |
231 | def _get_path_free_time(self):
232 | ''' Only used in the final evaluation, not the recursive structure
233 | '''
234 | path_free_time = self.__link_free_time.dot(self.__network.LP_matrix())
235 | return path_free_time
236 |
237 | def __link_time_performance(self, link_flow, t0, capacity):
238 | ''' Performance function, which indicates the relationship
239 | between flows (traffic volume) and travel time on
240 | the same link. According to the suggestion from Federal
241 | Highway Administration (FHWA) of America, we could use
242 | the following function: BPR function
243 | t = t0 * (1 + alpha * (flow / capacity))^beta
244 | '''
245 | value = t0 * (1 + self._alpha * ((link_flow/capacity)**self._beta))
246 | return value
247 |
248 | def __link_time_performance_integrated(self, link_flow, t0, capacity):
249 | ''' The integrated (with repsect to link flow) form of
250 | aforementioned performance function.
251 | '''
252 | val1 = t0 * link_flow
253 | # Some optimization should be implemented for avoiding overflow
254 | val2 = (self._alpha * t0 * link_flow / (self._beta + 1)) * (link_flow / capacity)**self._beta
255 | value = val1 + val2
256 | return value
257 |
258 | def __object_function(self, mixed_flow):
259 | ''' Objective function in the linear search step
260 | of the optimization model of user equilibrium
261 | traffic assignment problem, the only variable
262 | is mixed_flow in this case.
263 | '''
264 | val = 0
265 | for i in range(self.__network.num_of_links()):
266 | val += self.__link_time_performance_integrated(link_flow= mixed_flow[i], t0= self.__link_free_time[i], capacity= self.__link_capacity[i])
267 | return val
268 |
269 | def __golden_section(self, link_flow, auxiliary_link_flow, accuracy= 1e-8):
270 | ''' The golden-section search is a technique for
271 | finding the extremum of a strictly unimodal
272 | function by successively narrowing the range
273 | of values inside which the extremum is known
274 | to exist. The accuracy is suggested to be set
275 | as 1e-8. For more details please refer to:
276 | https://en.wikipedia.org/wiki/Golden-section_search
277 | '''
278 | # Initial params, notice that in our case the
279 | # optimal theta must be in the interval [0, 1]
280 | LB = 0
281 | UB = 1
282 | goldenPoint = 0.618
283 | leftX = LB + (1 - goldenPoint) * (UB - LB)
284 | rightX = LB + goldenPoint * (UB - LB)
285 | while True:
286 | val_left = self.__object_function((1 - leftX) * link_flow + leftX * auxiliary_link_flow)
287 | val_right = self.__object_function((1 - rightX) * link_flow + rightX * auxiliary_link_flow)
288 | if val_left <= val_right:
289 | UB = rightX
290 | else:
291 | LB = leftX
292 | if abs(LB - UB) < accuracy:
293 | opt_theta = (rightX + leftX) / 2.0
294 | return opt_theta
295 | else:
296 | if val_left <= val_right:
297 | rightX = leftX
298 | leftX = LB + (1 - goldenPoint) * (UB - LB)
299 | else:
300 | leftX = rightX
301 | rightX = LB + goldenPoint*(UB - LB)
302 |
303 | def __is_convergent(self, flow1, flow2):
304 | ''' Regard those two link flows lists as the point
305 | in Euclidean space R^n, then judge the convergence
306 | under given accuracy criterion.
307 | Here the formula
308 | ERR = || x_{k+1} - x_{k} || / || x_{k} ||
309 | is recommended.
310 | '''
311 | err = np.linalg.norm(flow1 - flow2) / np.linalg.norm(flow1)
312 | if self.__detail:
313 | print("ERR: %.8f" % err)
314 | if err < self._conv_accuracy:
315 | return True
316 | else:
317 | return False
318 |
319 | def disp_detail(self):
320 | ''' Display all the numerical details of each variable
321 | during the iteritions.
322 | '''
323 | self.__detail = True
324 |
325 | def set_disp_precision(self, precision):
326 | ''' Set the precision of display, which influences only
327 | the digit of numerical component in arrays.
328 | '''
329 | np.set_printoptions(precision= precision)
330 |
331 | def __dash_line(self):
332 | ''' Return a string which consistently
333 | contains '-' with fixed length
334 | '''
335 | return "-" * 80
336 |
337 | def __str__(self):
338 | string = ""
339 | string += self.__dash_line()
340 | string += "\n"
341 | string += "TRAFFIC FLOW ASSIGN MODEL (USER EQUILIBRIUM) \nFRANK-WOLFE ALGORITHM - PARAMS OF MODEL"
342 | string += "\n"
343 | string += self.__dash_line()
344 | string += "\n"
345 | string += self.__dash_line()
346 | string += "\n"
347 | string += "LINK Information:\n"
348 | string += self.__dash_line()
349 | string += "\n"
350 | for i in range(self.__network.num_of_links()):
351 | string += "%2d : link= %s, free time= %.2f, capacity= %s \n" % (i, self.__network.edges()[i], self.__link_free_time[i], self.__link_capacity[i])
352 | string += self.__dash_line()
353 | string += "\n"
354 | string += "OD Pairs Information:\n"
355 | string += self.__dash_line()
356 | string += "\n"
357 | for i in range(self.__network.num_of_OD_pairs()):
358 | string += "%2d : OD pair= %s, demand= %d \n" % (i, self.__network.OD_pairs()[i], self.__demand[i])
359 | string += self.__dash_line()
360 | string += "\n"
361 | string += "Path Information:\n"
362 | string += self.__dash_line()
363 | string += "\n"
364 | for i in range(self.__network.num_of_paths()):
365 | string += "%2d : Conjugated OD pair= %s, Path= %s \n" % (i, self.__network.paths_category()[i], self.__network.paths()[i])
366 | string += self.__dash_line()
367 | string += "\n"
368 | string += f"Link-Path Incidence Matrix (Rank: {self.__network.LP_matrix_rank()}):\n"
369 | string += self.__dash_line()
370 | string += "\n"
371 | string += str(self.__network.LP_matrix())
372 | return string
--------------------------------------------------------------------------------
/Reference/t-f-algorithm/static/NETWORK.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/qizidog/Traffic-Network-Design/958dd68126647056adf2933cf2328c326088e14b/Reference/t-f-algorithm/static/NETWORK.png
--------------------------------------------------------------------------------
/Reference/t-f-algorithm/static/user-equilibrium-solution.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/qizidog/Traffic-Network-Design/958dd68126647056adf2933cf2328c326088e14b/Reference/t-f-algorithm/static/user-equilibrium-solution.pdf
--------------------------------------------------------------------------------
/__pycache__/MyProblem.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/qizidog/Traffic-Network-Design/958dd68126647056adf2933cf2328c326088e14b/__pycache__/MyProblem.cpython-37.pyc
--------------------------------------------------------------------------------
/__pycache__/graph.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/qizidog/Traffic-Network-Design/958dd68126647056adf2933cf2328c326088e14b/__pycache__/graph.cpython-37.pyc
--------------------------------------------------------------------------------
/__pycache__/model.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/qizidog/Traffic-Network-Design/958dd68126647056adf2933cf2328c326088e14b/__pycache__/model.cpython-37.pyc
--------------------------------------------------------------------------------
/graph.py:
--------------------------------------------------------------------------------
1 |
2 | class Graph(object):
3 | """ DIRECTED GRAPH CLASS
4 |
5 | A simple Python graph class, demonstrating the essential
6 | facts and functionalities of directed graphs, and it is
7 | designed for our traffic flow assignment problem, thus we
8 | have the following assumptions:
9 |
10 | 1. The graph contains no self-loop, that is, an edge that
11 | connects a vertex to itself;
12 |
13 | 2. There is at most one edge which connects two vertice;
14 |
15 | Revised from: https://www.python-course.eu/graphs_python.php
16 | and in our case we must give order to all the edges, thus we
17 | do not use the unordered data structure.
18 | """
19 |
20 | def __init__(self, graph_dict= None):
21 | """ initializes a directed graph object by a dictionary,
22 | If no dictionary or None is given, an empty dictionary
23 | will be used. Notice that this initial graph cannot
24 | contain a self-loop.
25 | """
26 | from collections import OrderedDict
27 | if graph_dict == None:
28 | graph_dict = OrderedDict()
29 | self.__graph_dict = OrderedDict(graph_dict)
30 | if self.__is_with_loop():
31 | raise ValueError("The graph are supposed to be without self-loop please recheck the input data!")
32 |
33 | def vertices(self):
34 | """ returns the vertices of a graph
35 | """
36 | return list(self.__graph_dict.keys())
37 |
38 | def edges(self):
39 | """ returns the edges of a graph
40 | """
41 | return self.__generate_edges()
42 |
43 | def add_vertex(self, vertex):
44 | """ If the vertex "vertex" is not in
45 | self.__graph_dict, a key "vertex" with an empty
46 | list as a value is added to the dictionary.
47 | Otherwise nothing has to be done.
48 | """
49 | if vertex not in self.__graph_dict:
50 | self.__graph_dict[vertex] = []
51 | else:
52 | print("The vertex %s already exists in the graph, thus it has been ignored!" % vertex)
53 |
54 | def add_edge(self, edge):
55 | """ Assume that edge is ordered, and between two
56 | vertices there could exists only one edge.
57 | """
58 | vertex1, vertex2 = self.__decompose_edge(edge)
59 | if not self.__is_edge_in_graph(edge):
60 | if vertex1 in self.__graph_dict:
61 | self.__graph_dict[vertex1].append(vertex2)
62 | if vertex2 not in self.__graph_dict:
63 | self.__graph_dict[vertex2] = []
64 | else:
65 | self.__graph_dict[vertex1] = [vertex2]
66 | else:
67 | print("The edge %s already exists in the graph, thus it has been ignored!" % ([vertex1, vertex2]))
68 |
69 | def find_all_paths(self, start_vertex, end_vertex, path= []):
70 | """ find all simple paths (path with no repeated vertices)
71 | from start vertex to end vertex in graph
72 | """
73 | path = path + [start_vertex]
74 | if start_vertex == end_vertex:
75 | return [path]
76 | paths = []
77 | for neighbor in self.__graph_dict[start_vertex]:
78 | if neighbor not in path:
79 | sub_paths = self.find_all_paths(neighbor, end_vertex, path)
80 | for sub_path in sub_paths:
81 | paths.append(sub_path)
82 | return paths
83 |
84 | def __is_edge_in_graph(self, edge):
85 | """ Judge if an edge is already in the graph
86 | """
87 | vertex1, vertex2 = self.__decompose_edge(edge)
88 | if vertex1 in self.__graph_dict:
89 | if vertex2 in self.__graph_dict[vertex1]:
90 | return True
91 | else:
92 | return False
93 | else:
94 | return False
95 |
96 | def __decompose_edge(self, edge):
97 | """ Input is a list or a tuple with only two elements
98 | """
99 | if (isinstance(edge, list) or isinstance(edge, tuple)) and len(edge) == 2:
100 | return edge[0], edge[1]
101 | else:
102 | raise ValueError("%s is not of type list or tuple or its length does not equal to 2" % edge)
103 |
104 | def __is_with_loop(self):
105 | """ If the graph contains a self-loop, that is, an
106 | edge connects a vertex to itself, then return
107 | True, otherwise return False
108 | """
109 | for vertex in self.__graph_dict:
110 | if vertex in self.__graph_dict[vertex]:
111 | return True
112 | return False
113 |
114 | def __generate_edges(self):
115 | """ A static method generating the edges of the
116 | graph "graph". Edges are represented as list
117 | of two vertices
118 | """
119 | edges = []
120 | for vertex in self.__graph_dict:
121 | for neighbor in self.__graph_dict[vertex]:
122 | edges.append([vertex, neighbor])
123 | return edges
124 |
125 | def __str__(self):
126 | res = "vertices: "
127 | for k in self.__graph_dict:
128 | res += str(k) + " "
129 | res += "\nedges: "
130 | for edge in self.__generate_edges():
131 | res += str(edge) + " "
132 | return res
133 |
134 | class TrafficNetwork(Graph):
135 | ''' TRAFFIC NETWORK CLASS
136 | Traffic network is a combination of basic graph
137 | and the demands, the informations about links, paths
138 | and link-path incidence matrix will be generated
139 | after the initialization.
140 | '''
141 |
142 | def __init__(self, graph= None, O= [], D= []):
143 | Graph.__init__(self, graph)
144 | self.__origins = O
145 | self.__destinations = D
146 | self.__cast()
147 |
148 | # Override of add_edge function, notice that when an edge
149 | # is added, then the links and paths will changes alongside.
150 | # However, it doesn't matter when a vertex is added
151 | def add_edge(self, edge):
152 | Graph.add_edge(self, edge)
153 | self.__cast()
154 |
155 | def add_origin(self, origin):
156 | if origin not in self.__origins:
157 | self.__origins.append(origin)
158 | self.__cast()
159 | else:
160 | print("The origin %s already exists, thus has been ignored!" % origin)
161 |
162 | def add_destination(self, destination):
163 | if destination not in self.__destinations:
164 | self.__destinations.append(destination)
165 | self.__cast()
166 | else:
167 | print("The destination %s already exists, thus has been ignored!" % destination)
168 |
169 | def num_of_links(self):
170 | return len(self.__links)
171 |
172 | def num_of_paths(self):
173 | return len(self.__paths)
174 |
175 | def num_of_OD_pairs(self):
176 | return len(self.__OD_pairs)
177 |
178 | def __cast(self):
179 | """ Calculate or re-calculate the links, paths and
180 | Link-Path incidence matrix
181 | """
182 | if self.__origins != None and self.__destinations != None:
183 | # OD pairs = Origin-Destination Pairs
184 | self.__OD_pairs = self.__generate_OD_pairs()
185 | self.__links = self.edges()
186 | self.__paths, self.__paths_category = self.__generate_paths_by_demands()
187 | # LP Matrix = Link-Path Incidence Matrix
188 | self.__LP_matrix = self.__generate_LP_matrix()
189 |
190 | def __generate_OD_pairs(self):
191 | ''' Generate the OD pairs (Origin-Destination Pairs)
192 | by Cartesian production
193 | '''
194 | OD_pairs = []
195 | for o in self.__origins:
196 | for d in self.__destinations:
197 | OD_pairs.append([o, d])
198 | return OD_pairs
199 |
200 | def __generate_paths_by_demands(self):
201 | """ According the demands, i.e. the origins and the
202 | destinations of the traffic flow, to construct a list
203 | of paths which are necessary for the traffic flow
204 | assignment model
205 | """
206 | paths_by_demands = []
207 | paths_category = []
208 | od_pair_index = 0
209 | for OD_pair in self.__OD_pairs:
210 | paths = self.find_all_paths(*OD_pair)
211 | paths_by_demands.extend(paths)
212 | paths_category.extend([od_pair_index] * len(paths))
213 | od_pair_index += 1
214 | return paths_by_demands, paths_category
215 |
216 | def __generate_LP_matrix(self):
217 | """ Generate the Link-Path incidence matrix Delta:
218 | if the i-th link is on j-th link, then delta_ij = 1,
219 | otherwise delta_ij = 0
220 | """
221 | import numpy as np
222 | n_links = self.num_of_links()
223 | n_paths = self.num_of_paths()
224 | lp_mat = np.zeros(shape= (n_links, n_paths), dtype= int)
225 | path_index = 0
226 | for path in self.__paths:
227 | for i in range(len(path) - 1):
228 | current_link = self.__get_link_from_path_by_order(path, i)
229 | link_index = self.__links.index(current_link)
230 | lp_mat[link_index, path_index] = 1
231 | path_index += 1
232 | return lp_mat
233 |
234 | def __get_link_from_path_by_order(self, path, order):
235 | """ Given a path, which is a list with length N,
236 | search the link by order, which is a integer
237 | in the range [0, N-2]
238 | """
239 | if len(path) >= 2:
240 | if order >= 0 and order <= len(path) - 2:
241 | return [path[order], path[order+1]]
242 | else:
243 | raise ValueError("%d is not in the reasonale range!" % order)
244 | else:
245 | raise ValueError("%s contains only one vertex and cannot be input!" % path)
246 |
247 | def disp_links(self):
248 | ''' Print all the links in the network by order
249 | '''
250 | counter = 0
251 | for link in self.__links:
252 | print("%d : %s" % (counter, link))
253 | counter += 1
254 |
255 | def disp_paths(self):
256 | """ Print all the paths in order according to
257 | given origins and destinations
258 | """
259 | counter = 0
260 | for path in self.__paths:
261 | print("%d : %s " % (counter, path))
262 | counter += 1
263 |
264 | def LP_matrix(self):
265 | ''' Return the Link-Path matrix of
266 | current traffic network
267 | '''
268 | return self.__LP_matrix
269 |
270 | def LP_matrix_rank(self):
271 | ''' Return the rank of Link-Path matrix
272 | of current traffic network
273 | '''
274 | import numpy as np
275 | return np.linalg.matrix_rank(self.__LP_matrix)
276 |
277 | def OD_pairs(self):
278 | """ Return the origin-destination pairs of
279 | current traffic network
280 | """
281 | return self.__OD_pairs
282 |
283 | def paths_category(self):
284 | """ Return a list which implies the conjugacy
285 | between path (self.__paths) and origin-
286 | destinaiton pair (self.__OD_pairs)
287 | """
288 | return self.__paths_category
289 |
290 | def paths(self):
291 | """ Return the paths with respected to given
292 | origins and destinations
293 | """
294 | return self.__paths
--------------------------------------------------------------------------------
/main.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | import numpy as np
3 | import geatpy as ea # import geatpy
4 | from MyProblem import MyProblem # 导入自定义问题接口
5 |
6 | # Set the precision of display, which influences
7 | # only the digit of numerical component in arrays
8 | np.set_printoptions(precision=4)
9 |
10 | if __name__ == '__main__':
11 | """================================实例化问题对象==========================="""
12 | NIND = 50 # 种群规模
13 | problem = MyProblem(NIND) # 生成问题对象
14 | """==================================种群设置==============================="""
15 | Encoding = 'RI' # 编码方式
16 | Field = ea.crtfld(Encoding, problem.varTypes, problem.ranges, problem.borders) # 创建区域描述器
17 | population = ea.Population(Encoding, Field, NIND) # 实例化种群对象(此时种群还没被初始化,仅仅是完成种群对象的实例化)
18 | """================================算法参数设置============================="""
19 | myAlgorithm = ea.soea_DE_rand_1_bin_templet(problem, population) # 实例化一个算法模板对象
20 | myAlgorithm.MAXGEN = 50 # 最大进化代数
21 | myAlgorithm.mutOper.F = 0.5 # 差分进化中的参数F
22 | myAlgorithm.recOper.XOVR = 0.7 # 重组概率
23 | myAlgorithm.showCurGen = True # 显示当前进化代数
24 | """===========================调用算法模板进行种群进化======================="""
25 |
26 | res = ea.optimize(myAlgorithm, verbose=True, drawing=1, outputMsg=True, drawLog=False, saveFlag=True)
27 | print(res)
28 |
29 | # 输出最后一次的交通流分配信息
30 | problem.report()
31 |
32 |
--------------------------------------------------------------------------------
/model.py:
--------------------------------------------------------------------------------
1 | from graph import TrafficNetwork, Graph
2 | import numpy as np
3 |
4 |
5 | class TrafficFlowModel:
6 | ''' TRAFFIC FLOW ASSIGN MODEL
7 | Inside the Frank-Wolfe algorithm is given, one can use
8 | the method `solve` to compute the numerical solution of
9 | User Equilibrium problem.
10 | '''
11 | def __init__(self, graph= None, origins= [], destinations= [],
12 | demands= [], link_free_time= None, link_capacity= None):
13 |
14 | self.__network = TrafficNetwork(graph= graph, O= origins, D= destinations)
15 |
16 | # Initialization of parameters
17 | self.__link_free_time = np.array(link_free_time)
18 | self.__link_capacity = np.array(link_capacity)
19 | self.__demand = np.array(demands)
20 |
21 | # Alpha and beta (used in performance function)
22 | self._alpha = 0.15
23 | self._beta = 4
24 |
25 | # Convergent criterion
26 | self._conv_accuracy = 1e-5
27 |
28 | # Boolean varible: If true print the detail while iterations
29 | self.__detail = False
30 |
31 | # Boolean varible: If true the model is solved properly
32 | self.__solved = False
33 |
34 | # Some variables for contemporarily storing the
35 | # computation result
36 | self.__final_link_flow = None
37 | self.__iterations_times = None
38 |
39 |
40 | def __insert_links_in_order(self, links):
41 | ''' Insert the links as the expected order into the
42 | data structure `TrafficFlowModel.__network`
43 | '''
44 | first_vertice = [link[0] for link in links]
45 | for vertex in first_vertice:
46 | self.__network.add_vertex(vertex)
47 | for link in links:
48 | self.__network.add_edge(link)
49 |
50 | def solve(self):
51 | ''' Solve the traffic flow assignment model (user equilibrium)
52 | by Frank-Wolfe algorithm, all the necessary data must be
53 | properly input into the model in advance.
54 |
55 | (Implicitly) Return
56 | ------
57 | self.__solved = True
58 | '''
59 | if self.__detail:
60 | print(self.__dash_line())
61 | print("TRAFFIC FLOW ASSIGN MODEL (USER EQUILIBRIUM) \nFRANK-WOLFE ALGORITHM - DETAIL OF ITERATIONS")
62 | print(self.__dash_line())
63 | print(self.__dash_line())
64 | print("Initialization")
65 | print(self.__dash_line())
66 |
67 | # Step 0: based on the x0, generate the x1
68 | empty_flow = np.zeros(self.__network.num_of_links())
69 | link_flow = self.__all_or_nothing_assign(empty_flow)
70 |
71 | counter = 0
72 | while True:
73 |
74 | if self.__detail:
75 | print(self.__dash_line())
76 | print("Iteration %s" % counter)
77 | print(self.__dash_line())
78 | print("Current link flow:\n%s" % link_flow)
79 |
80 | # Step 1 & Step 2: Use the link flow matrix -x to generate the time, then generate the auxiliary link flow matrix -y
81 | auxiliary_link_flow = self.__all_or_nothing_assign(link_flow)
82 |
83 | # Step 3: Linear Search
84 | opt_theta = self.__golden_section(link_flow, auxiliary_link_flow)
85 |
86 | # Step 4: Using optimal theta to update the link flow matrix
87 | new_link_flow = (1 - opt_theta) * link_flow + opt_theta * auxiliary_link_flow
88 |
89 | # Print the detail if necessary
90 | if self.__detail:
91 | print("Optimal theta: %.8f" % opt_theta)
92 | print("Auxiliary link flow:\n%s" % auxiliary_link_flow)
93 |
94 | # Step 5: Check the Convergence, if FALSE, then return to Step 1
95 | if self.__is_convergent(link_flow, new_link_flow):
96 | if self.__detail:
97 | print(self.__dash_line())
98 | self.__solved = True
99 | self.__final_link_flow = new_link_flow
100 | self.__iterations_times = counter
101 | break
102 | else:
103 | link_flow = new_link_flow
104 | counter += 1
105 |
106 | def _formatted_solution(self):
107 | ''' According to the link flow we obtained in `solve`,
108 | generate a tuple which contains four elements:
109 | `link flow`, `link travel time`, `path travel time` and
110 | `link vehicle capacity ratio`. This function is exposed
111 | to users in case they need to do some extensions based
112 | on the computation result.
113 | '''
114 | if self.__solved:
115 | link_flow = self.__final_link_flow
116 | link_time = self.__link_flow_to_link_time(link_flow)
117 | path_time = self.__link_time_to_path_time(link_time)
118 | link_vc = link_flow / self.__link_capacity
119 | return link_flow, link_time, path_time, link_vc
120 | else:
121 | return None
122 |
123 | def report(self):
124 | ''' Generate the report of the result in console,
125 | this function can be invoked only after the
126 | model is solved.
127 | '''
128 | if self.__solved:
129 | # Print the input of the model
130 | print(self)
131 |
132 | # Print the report
133 |
134 | # Do the computation
135 | link_flow, link_time, path_time, link_vc = self._formatted_solution()
136 |
137 | print(self.__dash_line())
138 | print("TRAFFIC FLOW ASSIGN MODEL (USER EQUILIBRIUM) \nFRANK-WOLFE ALGORITHM - REPORT OF SOLUTION")
139 | print(self.__dash_line())
140 | print(self.__dash_line())
141 | print("TIMES OF ITERATION : %d" % self.__iterations_times)
142 | print(self.__dash_line())
143 | print(self.__dash_line())
144 | print("PERFORMANCE OF LINKS")
145 | print(self.__dash_line())
146 | for i in range(self.__network.num_of_links()):
147 | print("%2d : link= %12s, flow= %8.2f, time= %8.3f, v/c= %.3f" % (i, self.__network.edges()[i], link_flow[i], link_time[i], link_vc[i]))
148 | print(self.__dash_line())
149 | print("PERFORMANCE OF PATHS (GROUP BY ORIGIN-DESTINATION PAIR)")
150 | print(self.__dash_line())
151 | counter = 0
152 | for i in range(self.__network.num_of_paths()):
153 | if counter < self.__network.paths_category()[i]:
154 | counter = counter + 1
155 | print(self.__dash_line())
156 | print("%2d : group= %2d, time= %8.3f, path= %s" % (i, self.__network.paths_category()[i], path_time[i], self.__network.paths()[i]))
157 | print(self.__dash_line())
158 | else:
159 | raise ValueError("The report could be generated only after the model is solved!")
160 |
161 | def __all_or_nothing_assign(self, link_flow):
162 | ''' Perform the all-or-nothing assignment of
163 | Frank-Wolfe algorithm in the User Equilibrium
164 | Traffic Assignment Model.
165 | This assignment aims to assign all the traffic
166 | flow, within given origin and destination, into
167 | the least time consuming path
168 |
169 | Input: link flow -> Output: new link flow
170 | The input is an array.
171 | '''
172 | # LINK FLOW -> LINK TIME
173 | link_time = self.__link_flow_to_link_time(link_flow)
174 | # LINK TIME -> PATH TIME
175 | path_time = self.__link_time_to_path_time(link_time)
176 |
177 | # PATH TIME -> PATH FLOW
178 | # Find the minimal traveling time within group
179 | # (splited by origin - destination pairs) and
180 | # assign all the flow to that path
181 | path_flow = np.zeros(self.__network.num_of_paths())
182 | for OD_pair_index in range(self.__network.num_of_OD_pairs()):
183 | indice_grouped = []
184 | for path_index in range(self.__network.num_of_paths()):
185 | if self.__network.paths_category()[path_index] == OD_pair_index:
186 | indice_grouped.append(path_index)
187 | sub_path_time = [path_time[ind] for ind in indice_grouped]
188 | min_in_group = min(sub_path_time)
189 | ind_min = sub_path_time.index(min_in_group)
190 | target_path_ind = indice_grouped[ind_min]
191 | path_flow[target_path_ind] = self.__demand[OD_pair_index]
192 | if self.__detail:
193 | print("Link time:\n%s" % link_time)
194 | print("Path flow:\n%s" % path_flow)
195 | print("Path time:\n%s" % path_time)
196 |
197 | # PATH FLOW -> LINK FLOW
198 | new_link_flow = self.__path_flow_to_link_flow(path_flow)
199 |
200 | return new_link_flow
201 |
202 | def __link_flow_to_link_time(self, link_flow):
203 | ''' Based on current link flow, use link
204 | time performance function to compute the link
205 | traveling time.
206 | The input is an array.
207 | '''
208 | n_links = self.__network.num_of_links()
209 | link_time = np.zeros(n_links)
210 | for i in range(n_links):
211 | link_time[i] = self.__link_time_performance(link_flow[i], self.__link_free_time[i], self.__link_capacity[i])
212 | return link_time
213 |
214 | def __link_time_to_path_time(self, link_time):
215 | ''' Based on current link traveling time,
216 | use link-path incidence matrix to compute
217 | the path traveling time.
218 | The input is an array.
219 | '''
220 | path_time = link_time.dot(self.__network.LP_matrix())
221 | return path_time
222 |
223 | def __path_flow_to_link_flow(self, path_flow):
224 | ''' Based on current path flow, use link-path incidence
225 | matrix to compute the traffic flow on each link.
226 | The input is an array.
227 | '''
228 | link_flow = self.__network.LP_matrix().dot(path_flow)
229 | return link_flow
230 |
231 | def _get_path_free_time(self):
232 | ''' Only used in the final evaluation, not the recursive structure
233 | '''
234 | path_free_time = self.__link_free_time.dot(self.__network.LP_matrix())
235 | return path_free_time
236 |
237 | def __link_time_performance(self, link_flow, t0, capacity):
238 | ''' Performance function, which indicates the relationship
239 | between flows (traffic volume) and travel time on
240 | the same link. According to the suggestion from Federal
241 | Highway Administration (FHWA) of America, we could use
242 | the following function: BPR function
243 | t = t0 * (1 + alpha * (flow / capacity))^beta
244 | '''
245 | value = t0 * (1 + self._alpha * ((link_flow/capacity)**self._beta))
246 | return value
247 |
248 | def __link_time_performance_integrated(self, link_flow, t0, capacity):
249 | ''' The integrated (with repsect to link flow) form of
250 | aforementioned performance function.
251 | '''
252 | val1 = t0 * link_flow
253 | # Some optimization should be implemented for avoiding overflow
254 | val2 = (self._alpha * t0 * link_flow / (self._beta + 1)) * (link_flow / capacity)**self._beta
255 | value = val1 + val2
256 | return value
257 |
258 | def __object_function(self, mixed_flow):
259 | ''' Objective function in the linear search step
260 | of the optimization model of user equilibrium
261 | traffic assignment problem, the only variable
262 | is mixed_flow in this case.
263 | '''
264 | val = 0
265 | for i in range(self.__network.num_of_links()):
266 | val += self.__link_time_performance_integrated(link_flow= mixed_flow[i], t0= self.__link_free_time[i], capacity= self.__link_capacity[i])
267 | return val
268 |
269 | def __golden_section(self, link_flow, auxiliary_link_flow, accuracy= 1e-8):
270 | ''' The golden-section search is a technique for
271 | finding the extremum of a strictly unimodal
272 | function by successively narrowing the range
273 | of values inside which the extremum is known
274 | to exist. The accuracy is suggested to be set
275 | as 1e-8. For more details please refer to:
276 | https://en.wikipedia.org/wiki/Golden-section_search
277 | '''
278 | # Initial params, notice that in our case the
279 | # optimal theta must be in the interval [0, 1]
280 | LB = 0
281 | UB = 1
282 | goldenPoint = 0.618
283 | leftX = LB + (1 - goldenPoint) * (UB - LB)
284 | rightX = LB + goldenPoint * (UB - LB)
285 | while True:
286 | val_left = self.__object_function((1 - leftX) * link_flow + leftX * auxiliary_link_flow)
287 | val_right = self.__object_function((1 - rightX) * link_flow + rightX * auxiliary_link_flow)
288 | if val_left <= val_right:
289 | UB = rightX
290 | else:
291 | LB = leftX
292 | if abs(LB - UB) < accuracy:
293 | opt_theta = (rightX + leftX) / 2.0
294 | return opt_theta
295 | else:
296 | if val_left <= val_right:
297 | rightX = leftX
298 | leftX = LB + (1 - goldenPoint) * (UB - LB)
299 | else:
300 | leftX = rightX
301 | rightX = LB + goldenPoint*(UB - LB)
302 |
303 | def __is_convergent(self, flow1, flow2):
304 | ''' Regard those two link flows lists as the point
305 | in Euclidean space R^n, then judge the convergence
306 | under given accuracy criterion.
307 | Here the formula
308 | ERR = || x_{k+1} - x_{k} || / || x_{k} ||
309 | is recommended.
310 | '''
311 | err = np.linalg.norm(flow1 - flow2) / np.linalg.norm(flow1)
312 | if self.__detail:
313 | print("ERR: %.8f" % err)
314 | if err < self._conv_accuracy:
315 | return True
316 | else:
317 | return False
318 |
319 | def disp_detail(self):
320 | ''' Display all the numerical details of each variable
321 | during the iteritions.
322 | '''
323 | self.__detail = True
324 |
325 | def set_disp_precision(self, precision):
326 | ''' Set the precision of display, which influences only
327 | the digit of numerical component in arrays.
328 | '''
329 | np.set_printoptions(precision= precision)
330 |
331 | def __dash_line(self):
332 | ''' Return a string which consistently
333 | contains '-' with fixed length
334 | '''
335 | return "-" * 80
336 |
337 | def __str__(self):
338 | string = ""
339 | string += self.__dash_line()
340 | string += "\n"
341 | string += "TRAFFIC FLOW ASSIGN MODEL (USER EQUILIBRIUM) \nFRANK-WOLFE ALGORITHM - PARAMS OF MODEL"
342 | string += "\n"
343 | string += self.__dash_line()
344 | string += "\n"
345 | string += self.__dash_line()
346 | string += "\n"
347 | string += "LINK Information:\n"
348 | string += self.__dash_line()
349 | string += "\n"
350 | for i in range(self.__network.num_of_links()):
351 | string += "%2d : link= %s, free time= %.2f, capacity= %s \n" % (i, self.__network.edges()[i], self.__link_free_time[i], self.__link_capacity[i])
352 | string += self.__dash_line()
353 | string += "\n"
354 | string += "OD Pairs Information:\n"
355 | string += self.__dash_line()
356 | string += "\n"
357 | for i in range(self.__network.num_of_OD_pairs()):
358 | string += "%2d : OD pair= %s, demand= %d \n" % (i, self.__network.OD_pairs()[i], self.__demand[i])
359 | string += self.__dash_line()
360 | string += "\n"
361 | string += "Path Information:\n"
362 | string += self.__dash_line()
363 | string += "\n"
364 | for i in range(self.__network.num_of_paths()):
365 | string += "%2d : Conjugated OD pair= %s, Path= %s \n" % (i, self.__network.paths_category()[i], self.__network.paths()[i])
366 | string += self.__dash_line()
367 | string += "\n"
368 | string += f"Link-Path Incidence Matrix (Rank: {self.__network.LP_matrix_rank()}):\n"
369 | string += self.__dash_line()
370 | string += "\n"
371 | string += str(self.__network.LP_matrix())
372 | return string
--------------------------------------------------------------------------------
/new-2019-2020(2)拥挤网络管理与设计课程报告评分标准.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/qizidog/Traffic-Network-Design/958dd68126647056adf2933cf2328c326088e14b/new-2019-2020(2)拥挤网络管理与设计课程报告评分标准.pdf
--------------------------------------------------------------------------------
/拥挤网络课程报告.assets/Figure_130.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/qizidog/Traffic-Network-Design/958dd68126647056adf2933cf2328c326088e14b/拥挤网络课程报告.assets/Figure_130.png
--------------------------------------------------------------------------------
/拥挤网络课程报告.assets/Figure_180.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/qizidog/Traffic-Network-Design/958dd68126647056adf2933cf2328c326088e14b/拥挤网络课程报告.assets/Figure_180.png
--------------------------------------------------------------------------------
/拥挤网络课程报告.assets/Figure_65.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/qizidog/Traffic-Network-Design/958dd68126647056adf2933cf2328c326088e14b/拥挤网络课程报告.assets/Figure_65.png
--------------------------------------------------------------------------------
/拥挤网络课程报告.assets/image-20200627232335128.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/qizidog/Traffic-Network-Design/958dd68126647056adf2933cf2328c326088e14b/拥挤网络课程报告.assets/image-20200627232335128.png
--------------------------------------------------------------------------------
/拥挤网络课程报告.assets/image-20200701234939688.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/qizidog/Traffic-Network-Design/958dd68126647056adf2933cf2328c326088e14b/拥挤网络课程报告.assets/image-20200701234939688.png
--------------------------------------------------------------------------------
/拥挤网络课程报告.assets/image-20200701235619548.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/qizidog/Traffic-Network-Design/958dd68126647056adf2933cf2328c326088e14b/拥挤网络课程报告.assets/image-20200701235619548.png
--------------------------------------------------------------------------------
/拥挤网络课程报告.assets/image-20200702003840303.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/qizidog/Traffic-Network-Design/958dd68126647056adf2933cf2328c326088e14b/拥挤网络课程报告.assets/image-20200702003840303.png
--------------------------------------------------------------------------------
/拥挤网络课程报告.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/qizidog/Traffic-Network-Design/958dd68126647056adf2933cf2328c326088e14b/拥挤网络课程报告.pdf
--------------------------------------------------------------------------------