States
BaseState
Abstract base class for states.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Name of the state |
required |
is_actionable
|
bool
|
If |
False
|
is_observable
|
bool
|
If |
True
|
exception_on_nan
|
bool
|
If |
False
|
Source code in lineflow/simulation/states.py
value
property
The (scalar) value of the state.
apply(value)
Should be called from a policy to change the value of the state
assert_valid(value)
reverse(series)
update(value)
Should be called from a lineflow.simulation.base.LineObject to change the value
of the state
CountState
Bases: NumericState
State to count discrete events.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Name of the state |
required |
vmin
|
float
|
The allowed minimal value the state accepts |
0
|
vmax
|
float
|
The allowed maximal value the state accepts |
inf
|
is_actionable
|
bool
|
If |
False
|
is_observable
|
bool
|
If |
True
|
exception_on_nan
|
bool
|
If |
False
|
Source code in lineflow/simulation/states.py
Data
Bases: object
Source code in lineflow/simulation/states.py
get_modes(lookback=None)
Returns the percent of working mode of the cells of a line over the lookback period
get_observations(lookback=None, include_time=True)
Here, only observable values are returned
Source code in lineflow/simulation/states.py
get_uptime(lookback=None)
Returns the percentage of the station being in working mode (mode=0) over the lookback period
Source code in lineflow/simulation/states.py
DiscreteState
Bases: BaseState
State to handle discrete states, like integer numbers or categories.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Name of the state |
required |
categories
|
list
|
List of values this state can take. |
required |
is_actionable
|
bool
|
If |
False
|
is_observable
|
bool
|
If |
True
|
exception_on_nan
|
bool
|
If |
False
|
Source code in lineflow/simulation/states.py
LineStates
Bases: object
Bag of all ObjectStates of all LineObjectss of a line.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
objects
|
dict
|
Dict where keys are the object name and the value are of type
|
required |
Source code in lineflow/simulation/states.py
375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 | |
df(reverse=True, lookback=None)
This function is expensive in time and should only be called after simulation is finished
Source code in lineflow/simulation/states.py
get_actions()
Returns a list of actions for policies to design valid outputs
Source code in lineflow/simulation/states.py
NumericState
Bases: BaseState
State to handle numeric values.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Name of the state |
required |
vmin
|
float
|
The allowed minimal value the state accepts |
-inf
|
vmax
|
float
|
The allowed maximal value the state accepts |
inf
|
is_actionable
|
bool
|
If |
False
|
is_observable
|
bool
|
If |
True
|
exception_on_nan
|
bool
|
If |
False
|
Source code in lineflow/simulation/states.py
decrement()
ObjectStates
Bases: object
Bag of all states of a LineObject
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
states
|
list
|
List of |
()
|
Source code in lineflow/simulation/states.py
apply(values)
Applies the values to all states
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
values
|
dict
|
Dict where the keys are the names of the internal states and the values are the values to be applied. |
required |
Source code in lineflow/simulation/states.py
update(values)
Updates the values of all states
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
values
|
dict
|
Dict where the keys are the names of the internal states and the values are the values to be updated. |
required |
Source code in lineflow/simulation/states.py
TokenState
Bases: BaseState
State to handle discrete objects where its not clear from the begining which and how many objects need to be tracked.
Source code in lineflow/simulation/states.py
Simulation
Line
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
realtime
|
bool
|
Only if |
False
|
factor
|
float
|
visualization speed |
0.5
|
info
|
list
|
A list of line data that is retrivable over the get_info() method.
That is |
None
|
Source code in lineflow/simulation/line.py
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 | |
build()
get_n_parts_produced()
get_n_scrap_parts()
get_observations(object_name=None)
Source code in lineflow/simulation/line.py
get_uptime(lookback=None)
info()
Returns additional Information about the line
Source code in lineflow/simulation/line.py
reset(random_state=None)
Resets the simulation.
Source code in lineflow/simulation/line.py
run(simulation_end, agent=None, show_status=True, visualize=False, capture_screen=False)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
simulation_end
|
float
|
Time until the simulation stops |
required |
agent
|
agents
|
An Agent that interacts with a line. Can also be just a policy if an call method exists like in the BaseAgent class. |
None
|
show_status
|
bool
|
Show progress bar for each simulation episode |
True
|
visualize
|
bool
|
If true, line visualization is opened |
False
|
capture_screen
|
bool
|
Captures last Time frame when screen should be recorded |
False
|
Source code in lineflow/simulation/line.py
step(simulation_end=None)
Step to the next state of the line Args: simulation_end (int): Time until terminated flag is returned as True. If None terminated is always False.
Source code in lineflow/simulation/line.py
step_event()
Ensures that there is an Event scheduled for self.step_size intervals
The step function is only able to stop the simulation if an Event is scheduled.
Source code in lineflow/simulation/line.py
Assembly
Bases: Station
Assembly takes a carrier from buffer_in and buffer_component, puts the parts of the component
carrier on the carrier that came from buffer_in, and pushes that carrier to buffer_out and
pushes the component carrier to buffer_return if a buffer return exists, otherwise these
carriers are lost.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Name of the station |
required |
processing_time
|
float
|
Time until parts are moved from component carrier to main carrier |
5
|
position
|
tuple
|
X and Y position in the visualization |
None
|
buffer_return
|
Buffer
|
The buffer to put the old component carriers on |
None
|
processing_std
|
float
|
The standard deviation of the processing time |
None
|
Source code in lineflow/simulation/stations.py
344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 | |
Magazine
Bases: Station
Magazine station manages carriers.
The Magazine gets carriers from buffer_in and stores them in the magazine. Afterwards it takes a carrier from its magazine and pushes the carrier to buffer_out. If unlimited_carriers is True no buffer_in is needed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
unlimited_carriers
|
bool
|
If True, the Magazine will have an unlimited amount of carriers available |
True
|
carriers_in_magazine
|
int
|
Number of carriers in the magazine |
0
|
carrier_getting_time
|
float
|
Time to get a carrier from the magazine |
2
|
actionable_magazine
|
bool
|
If True, carriers in the magazine is in an actionable state |
True
|
carrier_capacity
|
int
|
Defines how many parts can be assembled on a carrier. If set to default (infinity) or > 15, carrier will be visualized with one part. |
inf
|
Source code in lineflow/simulation/stations.py
1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 | |
Process
Bases: Station
Process stations take a carrier as input, process the carrier, and push it onto buffer_out
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Name of the station |
required |
buffer_in
|
Buffer
|
Buffer in |
None
|
buffer_out
|
Buffer
|
Buffer out |
None
|
processing_time
|
float
|
Time it takes to process the carrier (carrier needs to be available) |
5
|
processing_std
|
float
|
Standard deviation of the processing time |
None
|
rework_probability
|
float
|
Probability of a carrier to be reworked (takes 2x the time) |
0
|
position
|
tuple
|
X and Y position in visualization |
None
|
worker_pool
|
WorkerPool
|
Worker pool to |
None
|
Source code in lineflow/simulation/stations.py
527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 | |
SequentialProcess
Bases: Process
SequentialProcess stations take a carrier as input, process each part on the carrier sequentially, and push the carrier onto buffer_out. The processing time of each part can be different and is determined by the part specifications. If a part does not fulfill the assembly condition, it is scrapped and the carrier is reworked (takes 2x the time). If connected to a worker pool, workers are released and requested for each part on the carrier.
The processing time for each part is the sum of the processing time of the station (which is 0
by default) and the additional processing time specified in the part specifications for this
station. The standard deviation of the processing time is determined by the processing_std
attribute of the station and is applied to the total processing time of the part.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Name of the station |
required |
buffer_in
|
Buffer
|
Buffer in |
None
|
buffer_out
|
Buffer
|
Buffer out |
None
|
processing_time
|
float
|
Time it takes to process each part on the carrier |
0
|
processing_std
|
float
|
Standard deviation of the processing time |
0.1
|
position
|
tuple
|
X and Y position in visualization |
None
|
worker_pool
|
WorkerPool
|
Worker pool to |
None
|
Example:
Assume a source produces carriers of type Type_A with two parts Part1 and Part2 that have the
following specifications:
carrier_specs = {
'Type_A': {
'Part1': {
'Process1': {
'extra_processing_time': 20,
'error_probability': 0.0,
'error_time': 0,
},
'Process2': {
'extra_processing_time': 5,
'error_probability': 0.0,
'error_time': 0,
}
},
'Part2': {
'Process2': {
'extra_processing_time': 8,
'error_probability': 0.5,
'error_time': 10,
}
}
},
}
Assume the processes are initialized as follows:
p1 = SequentialProcess(
name='Process1',
processing_time=0,
processing_std=0.1,
rework_probability=0.5,
)
p2 = SequentialProcess(
name='Process2',
processing_time=10,
processing_std=0.1,
rework_probability=0.5,
)
Both processes process all parts.
At Process1, a carrier of type Type_A with a processing time of
At Process2, a carrier of type Type_A with a processing time of
Source code in lineflow/simulation/stations.py
621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 | |
Sink
Bases: Station
The Sink takes carriers from buffer_in. It removes the parts of the carrier and either destroys it or puts them to buffer_out if one exists.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
processing_std
|
float
|
The standard deviation of the processing time. |
None
|
position
|
tuple
|
X and Y position in the visualization. |
None
|
Source code in lineflow/simulation/stations.py
1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 | |
Source
Bases: Station
Source station generating parts on carriers.
The Source takes carriers from buffer_in, creates a part, places that part onto the carrier, and pushes the carrier onto the buffer_out. If unlimited carriers is True, no buffer_in is needed and no magazine.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Name of the Cell |
required |
carrier_specs
|
dict
|
Nested dict. Top level descripes carrier types, each consists of a
dict specifying different parts setup on the carrier at the source. The part level
specifies how the part behaves at future processes along the layout. For instance a spec
|
None
|
buffer_in
|
Buffer
|
Buffer in |
None
|
buffer_out
|
obj
|
Buffer out |
None
|
processing_time
|
float
|
Time it takes to put part on carrier (carrier needs to be available) |
2
|
processing_std
|
float
|
Standard deviation of processing time |
None
|
waiting_time
|
float
|
Time to wait between pushing a carrier out and taking the next one |
0
|
position
|
tuple
|
X and Y position in visualization |
None
|
unlimited_carriers
|
bool
|
If source has the ability to create unlimited carriers |
False
|
carrier_capacity
|
int
|
Defines how many parts can be assembled on a carrier. If set to default (infinity) or > 15, carrier will be visualized with one part. |
inf
|
nok_probability
|
float
|
Between 0 and 1, probability of a part on the carrier being labled as nok |
0.0
|
carrier_min_creation
|
int
|
Minimum number of carriers of same spec created subsequentially |
1
|
carrier_max_creation
|
int
|
Maximum number of carriers of same spec created subsequentially |
None
|
Source code in lineflow/simulation/stations.py
797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 | |
assemble_parts_on_carrier(carrier, parts)
create_parts(carrier, carrier_spec)
Creates the parts based on the part_specs attribute For each dict in the part_specs list one part is created
Source code in lineflow/simulation/stations.py
Station
Bases: StationaryObject
Source code in lineflow/simulation/stations.py
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 | |
release_workers()
Releases the worker, to they may follow a new assignment
Source code in lineflow/simulation/stations.py
request_workers()
Requests (and blocks) the worker for the process coming up.
Source code in lineflow/simulation/stations.py
Switch
Bases: Station
A Switch distributes carriers onto buffer outs. In and out buffers can be provided to
the constructor but can also be added to a switch using the connect_to_input and connect_to_output
methods.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
buffers_in
|
list
|
A list of buffers that lead into the Switch. |
None
|
buffers_out
|
list
|
A list of buffers that lead away from the Switch. |
None
|
position
|
tuple
|
X and Y position in the visualization. |
None
|
alternate
|
bool
|
If True, the Switch switches between the buffers_out; else, only one buffer_out is used. |
False
|
Source code in lineflow/simulation/stations.py
1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 | |
look_in()
Checks if part at current buffer_in is available
Source code in lineflow/simulation/stations.py
look_out()
Checks if space at current buffer_out is available
Source code in lineflow/simulation/stations.py
WorkerPool
Bases: StationaryObject
Source code in lineflow/simulation/stations.py
apply(actions)
This should just update the state of the workers
Buffer
Bases: Connector
Element that connects two different types of stations.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Name of the station |
required |
capacity
|
int
|
Number of slots the buffer can hold |
2
|
transition_time
|
float
|
Time carriers need to traverse the full buffer |
10
|
put_time
|
float
|
Time the buffer needs to hand over a carrier to the next element |
1
|
get_time
|
float
|
Time the buffer needs to get a carrier to the previous element |
1
|
Source code in lineflow/simulation/connectors.py
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 | |
Carrier
Bases: MovableObject
Source code in lineflow/simulation/movable_objects.py
159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 | |
move(position)
Source code in lineflow/simulation/movable_objects.py
Part
Bases: MovableObject
Source code in lineflow/simulation/movable_objects.py
is_valid_for_assembly(station_name)
If the part has an assembly_condition in its specification, then it checks whether the
time between its creation and now is smaller than this condition. Otherwise it will just
return true.
Source code in lineflow/simulation/movable_objects.py
Worker
Bases: object
Source code in lineflow/simulation/movable_objects.py
assign(station)
StationaryObject
Source code in lineflow/simulation/stationary_objects.py
init(random)
Function that is called after line is built, so all available information is present
This file is a wrapper around our simulation such that it is compatible with the stable-baselines repo
LineSimulation
Bases: Env
A Gym-compatible environment for simulating production lines using LineFlow.
This environment wraps a LineFlow production line into a reinforcement learning setup, where agents can interact with stations via actions at discrete decision points, while the underlying process unfolds in continuous time using discrete-event simulation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
line
|
Line
|
A LineFlow |
required |
simulation_end
|
int
|
The simulation end time (in simulation time units). |
required |
reward
|
str
|
The reward signal to use. Options are "parts" (default) for counting produced parts, or "uptime" for average utilization. |
'parts'
|
part_reward_lookback
|
int
|
Time window for computing average uptime-based rewards
(used only if reward= |
0
|
render_mode
|
str or None
|
Optional rendering mode. Currently supports "human" for visual rendering or None. |
None
|
Source code in lineflow/simulation/environment.py
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 | |
increase_scrap_factor(factor=0.1)
Sets the scrap penalty factor in the reward function.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
factor
|
float
|
The multiplier applied to scrap parts in the parts-based reward. |
0.1
|
Source code in lineflow/simulation/environment.py
step(actions)
Advances the simulation by one environment step.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
actions
|
list or array
|
A list of agent actions corresponding to actionable features. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
observation |
ndarray
|
Observation tensor representing the current state. |
reward |
float
|
The computed reward for the current step. |
terminated |
bool
|
Whether the episode has ended. |
truncated |
bool
|
Whether the episode ended due to an internal error or simulation limit. |
info |
dict
|
Additional diagnostic information. |
Source code in lineflow/simulation/environment.py
Reinforcement Learning
train(config)
Function that handles RL training
Args:
- train: Scores from the model update phase
- rollout: Scores when a policy is rolled out to gather new experiences.
- eval: Scores when a policy is evaluated on a separate environment
Notes
Size of rollout-buffer: n_steps*n_envs, then an model-update is done
Source code in scripts/train.py
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 | |
CurriculumLearningCallback
Bases: BaseCallback
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
look_back
|
int
|
Number of last evaluations that should be used to check if task is solved |
5
|
factor_max
|
float
|
Factor with which the threshold is multiplied to get new threshold |
inf
|
Source code in lineflow/learning/curriculum.py
Examples
PartDependentProcessLine
Bases: Line
Example implementation of a line with part-dependent processing times. The source creates carriers of two types (Type_A and Type_B), each containing two parts (Part1 and Part2). The processing times for each process depend on the type of carrier and the parts it contains. The line consists of three processes (P1, P2, P3) and a sink. The processing times for each process are defined in the carrier_specs of the source, where extra processing time is added based on the type of carrier and the parts it contains.
Source code in lineflow/examples/part_dependence.py
WTAssembly
Bases: Assembly
Source code in lineflow/examples/waiting_time.py
init(random)
Function that is called after line is built, so all available information is present
MultiSink
Bases: Line
Assembly line with two sources a switch and a sink
Source code in lineflow/examples/multi_sink.py
MultiProcess
Bases: Line
Assembly line with two sources a switch and a sink