|
282 | 282 | "id": "mysterious-diamond", |
283 | 283 | "metadata": {}, |
284 | 284 | "source": [ |
285 | | - "### 3.3 Perform Path-Based UE Traffic Assignment\n", |
| 285 | + "### 3.3 Perform UE Traffic Assignment\n", |
| 286 | + "\n", |
| 287 | + "#### 3.3.1 Prerequisite on Demand\n", |
286 | 288 | "\n", |
287 | 289 | "OD demand matrix and zone information is crucial in conducting traffic assignment are essential to perform this functionality. The demand file is presumed to be given and zone information is provided along node.csv. The latter is the current design of GMNS and is endorsed in [OSM2GMNS](https://github.com/jiawlu/OSM2GMNS).\n", |
288 | 290 | "\n", |
289 | 291 | "The demand will be loaded by default via pg.read_demand(). If demand.csv is missing, pg.read_demand() will automatically conduct the following attempts.\n", |
290 | 292 | "1. try to load the synthetic demand (as syn_demand.csv and zones as syn_zone.csv).\n", |
291 | 293 | "2. synthesize demand (and zones) if the previous attempt fails.\n", |
292 | 294 | "\n", |
293 | | - "Then you can conduct traffic assignment via the following lines." |
| 295 | + "The demand file is specified in settings.yml as demand.csv (see 4.1 Sample setting.yml for details). You can change it to any demand file in your PWD. This design actually allows us to load multiple demand files simultaneously corresponding to different period and agent_type. We will elaborate it in a future release.\n", |
| 296 | + "\n", |
| 297 | + "#### 3.3.2 Path-Based UE\n", |
| 298 | + "\n", |
| 299 | + "With the required demand file, then you can conduct path-based UE traffic assignment via the following lines." |
294 | 300 | ] |
295 | 301 | }, |
296 | 302 | { |
|
323 | 329 | "id": "c2c1211e", |
324 | 330 | "metadata": {}, |
325 | 331 | "source": [ |
326 | | - "The demand file is specified in settings.yml as demand.csv (see 4.1 Sample setting.yml for details). You can change it to any demand file in your PWD. This design actually allows us to load multiple demand files simultaneously corresponding to different period and agent_type. We will elaborate it in a future release.\n", |
327 | | - "\n", |
328 | 332 | "The code snippet below demonstrates how to adaptively the UE convergency directly through rel_gap_tolerance. find_ue() will terminate when either column_upd_num or rel_gap_tolerance is reached." |
329 | 333 | ] |
330 | 334 | }, |
|
342 | 346 | "column_gen_num = 20\n", |
343 | 347 | "column_upd_num = 20\n", |
344 | 348 | "\n", |
345 | | - "# the default value of rel_gap_tolerance is 0.0001 if not specified\n", |
346 | | - "rel_gap = pg.find_ue(network, column_gen_num, column_upd_num, rel_gap_tolerance = 0.001)\n", |
| 349 | + "# the default value of rel_gap_tolerance is 1e-04 if not specified\n", |
| 350 | + "rel_gap = pg.find_ue(network, column_gen_num, column_upd_num, rel_gap_tolerance=1e-04)\n", |
347 | 351 | "print(f'the final relative UE gap is {rel_gap:.4%}')\n", |
348 | 352 | "\n", |
349 | 353 | "# if you want to include path geometry info in the output file,\n", |
|
352 | 356 | "pg.output_link_performance(network)" |
353 | 357 | ] |
354 | 358 | }, |
| 359 | + { |
| 360 | + "cell_type": "markdown", |
| 361 | + "id": "14ea3a1a", |
| 362 | + "metadata": {}, |
| 363 | + "source": [ |
| 364 | + "#### 3.3.3 Link-Based UE\n", |
| 365 | + "\n", |
| 366 | + "The link-based UE does not preserve any paths / columns but only (unique) link flows. Thus, pg.output_columns(network) is NOT available." |
| 367 | + ] |
| 368 | + }, |
| 369 | + { |
| 370 | + "cell_type": "code", |
| 371 | + "execution_count": null, |
| 372 | + "id": "4fafb09b", |
| 373 | + "metadata": {}, |
| 374 | + "outputs": [], |
| 375 | + "source": [ |
| 376 | + "network = pg.read_network()\n", |
| 377 | + "pg.read_demand(network)\n", |
| 378 | + "\n", |
| 379 | + "pg.find_ue_fw(network)\n", |
| 380 | + "pg.output_link_performance(network)\n", |
| 381 | + "\n", |
| 382 | + "# NOTE that pg.output_columns(network) is NOT available under the link-based UE!" |
| 383 | + ] |
| 384 | + }, |
| 385 | + { |
| 386 | + "cell_type": "markdown", |
| 387 | + "id": "bf333d6c", |
| 388 | + "metadata": {}, |
| 389 | + "source": [ |
| 390 | + "find_ue_fw() will terminate when it reaches the maximum number of iterations (**max_iter_num**) or the target relative gap (**rel_gap_tolerance**), whichever comes first. The default values are **40** and **1e-04**, respectively. You can adjust\n", |
| 391 | + "their values toward your own need like below." |
| 392 | + ] |
| 393 | + }, |
| 394 | + { |
| 395 | + "cell_type": "code", |
| 396 | + "execution_count": null, |
| 397 | + "id": "8cfb704d", |
| 398 | + "metadata": {}, |
| 399 | + "outputs": [], |
| 400 | + "source": [ |
| 401 | + "network = pg.read_network()\n", |
| 402 | + "pg.read_demand(network)\n", |
| 403 | + "\n", |
| 404 | + "pg.find_ue_fw(network, max_iter_num=100, rel_gap_tolerance=1e-6)\n", |
| 405 | + "pg.output_link_performance(network)\n", |
| 406 | + "\n", |
| 407 | + "# NOTE that pg.output_columns(network) is NOT available under the link-based UE!" |
| 408 | + ] |
| 409 | + }, |
355 | 410 | { |
356 | 411 | "cell_type": "markdown", |
357 | 412 | "id": "ad91ad31", |
358 | 413 | "metadata": {}, |
359 | 414 | "source": [ |
360 | 415 | "### 3.4 Conduct Dynamic Traffic Simulation\n", |
361 | 416 | "\n", |
362 | | - "Traffic simulation requires routing decision for each agent, which comes from the UE traffic assignment." |
| 417 | + "Traffic simulation requires routing decision for each agent, which comes from the **path-based UE** traffic assignment." |
363 | 418 | ] |
364 | 419 | }, |
365 | 420 | { |
|
610 | 665 | "pg.download_sample_setting_file()" |
611 | 666 | ] |
612 | 667 | }, |
613 | | - { |
614 | | - "cell_type": "markdown", |
615 | | - "id": "e631fbf5", |
616 | | - "metadata": {}, |
617 | | - "source": [] |
618 | | - }, |
619 | 668 | { |
620 | 669 | "cell_type": "markdown", |
621 | 670 | "id": "great-catholic", |
|
0 commit comments