-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path仿真对象.html
1011 lines (933 loc) · 188 KB
/
仿真对象.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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
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
525
526
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
619
620
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
795
796
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
<!doctype html>
<html>
<head>
<meta charset='UTF-8'><meta name='viewport' content='width=device-width initial-scale=1'>
<link href='https://fonts.googleapis.com/css?family=Merriweather:900,900italic,300,300italic&subset=latin-ext' rel='stylesheet' type='text/css' /><link href='https://fonts.googleapis.com/css?family=Lato:900,300&subset=latin-ext' rel='stylesheet' type='text/css' /><style type='text/css'>html {overflow-x: initial !important;}:root { --bg-color: #ffffff; --text-color: #333333; --select-text-bg-color: #B5D6FC; --select-text-font-color: auto; --monospace: "Lucida Console",Consolas,"Courier",monospace; --title-bar-height: 20px; }
.mac-os-11 { --title-bar-height: 28px; }
html { font-size: 14px; background-color: var(--bg-color); color: var(--text-color); font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; -webkit-font-smoothing: antialiased; }
h1, h2, h3, h4, h5 { white-space: pre-wrap; }
body { margin: 0px; padding: 0px; height: auto; inset: 0px; font-size: 1rem; line-height: 1.42857; overflow-x: hidden; background: inherit; }
iframe { margin: auto; }
a.url { word-break: break-all; }
a:active, a:hover { outline: 0px; }
.in-text-selection, ::selection { text-shadow: none; background: var(--select-text-bg-color); color: var(--select-text-font-color); }
#write { margin: 0px auto; height: auto; width: inherit; word-break: normal; overflow-wrap: break-word; position: relative; white-space: normal; overflow-x: visible; padding-top: 36px; }
#write.first-line-indent p { text-indent: 2em; }
#write.first-line-indent li p, #write.first-line-indent p * { text-indent: 0px; }
#write.first-line-indent li { margin-left: 2em; }
.for-image #write { padding-left: 8px; padding-right: 8px; }
body.typora-export { padding-left: 30px; padding-right: 30px; }
.typora-export .footnote-line, .typora-export li, .typora-export p { white-space: pre-wrap; }
.typora-export .task-list-item input { pointer-events: none; }
@media screen and (max-width: 500px) {
body.typora-export { padding-left: 0px; padding-right: 0px; }
#write { padding-left: 20px; padding-right: 20px; }
}
#write li > figure:last-child { margin-bottom: 0.5rem; }
#write ol, #write ul { position: relative; }
img { max-width: 100%; vertical-align: middle; image-orientation: from-image; }
button, input, select, textarea { color: inherit; font: inherit; }
input[type="checkbox"], input[type="radio"] { line-height: normal; padding: 0px; }
*, ::after, ::before { box-sizing: border-box; }
#write h1, #write h2, #write h3, #write h4, #write h5, #write h6, #write p, #write pre { width: inherit; }
#write h1, #write h2, #write h3, #write h4, #write h5, #write h6, #write p { position: relative; }
p { line-height: inherit; }
h1, h2, h3, h4, h5, h6 { break-after: avoid-page; break-inside: avoid; orphans: 4; }
p { orphans: 4; }
h1 { font-size: 2rem; }
h2 { font-size: 1.8rem; }
h3 { font-size: 1.6rem; }
h4 { font-size: 1.4rem; }
h5 { font-size: 1.2rem; }
h6 { font-size: 1rem; }
.md-math-block, .md-rawblock, h1, h2, h3, h4, h5, h6, p { margin-top: 1rem; margin-bottom: 1rem; }
.hidden { display: none; }
.md-blockmeta { color: rgb(204, 204, 204); font-weight: 700; font-style: italic; }
a { cursor: pointer; }
sup.md-footnote { padding: 2px 4px; background-color: rgba(238, 238, 238, 0.7); color: rgb(85, 85, 85); border-radius: 4px; cursor: pointer; }
sup.md-footnote a, sup.md-footnote a:hover { color: inherit; text-transform: inherit; text-decoration: inherit; }
#write input[type="checkbox"] { cursor: pointer; width: inherit; height: inherit; }
figure { overflow-x: auto; margin: 1.2em 0px; max-width: calc(100% + 16px); padding: 0px; }
figure > table { margin: 0px; }
thead, tr { break-inside: avoid; break-after: auto; }
thead { display: table-header-group; }
table { border-collapse: collapse; border-spacing: 0px; width: 100%; overflow: auto; break-inside: auto; text-align: left; }
table.md-table td { min-width: 32px; }
.CodeMirror-gutters { border-right: 0px; background-color: inherit; }
.CodeMirror-linenumber { user-select: none; }
.CodeMirror { text-align: left; }
.CodeMirror-placeholder { opacity: 0.3; }
.CodeMirror pre { padding: 0px 4px; }
.CodeMirror-lines { padding: 0px; }
div.hr:focus { cursor: none; }
#write pre { white-space: pre-wrap; }
#write.fences-no-line-wrapping pre { white-space: pre; }
#write pre.ty-contain-cm { white-space: normal; }
.CodeMirror-gutters { margin-right: 4px; }
.md-fences { font-size: 0.9rem; display: block; break-inside: avoid; text-align: left; overflow: visible; white-space: pre; background: inherit; position: relative !important; }
.md-fences-adv-panel { width: 100%; margin-top: 10px; text-align: center; padding-top: 0px; padding-bottom: 8px; overflow-x: auto; }
#write .md-fences.mock-cm { white-space: pre-wrap; }
.md-fences.md-fences-with-lineno { padding-left: 0px; }
#write.fences-no-line-wrapping .md-fences.mock-cm { white-space: pre; overflow-x: auto; }
.md-fences.mock-cm.md-fences-with-lineno { padding-left: 8px; }
.CodeMirror-line, twitterwidget { break-inside: avoid; }
svg { break-inside: avoid; }
.footnotes { opacity: 0.8; font-size: 0.9rem; margin-top: 1em; margin-bottom: 1em; }
.footnotes + .footnotes { margin-top: 0px; }
.md-reset { margin: 0px; padding: 0px; border: 0px; outline: 0px; vertical-align: top; background: 0px 0px; text-decoration: none; text-shadow: none; float: none; position: static; width: auto; height: auto; white-space: nowrap; cursor: inherit; -webkit-tap-highlight-color: transparent; line-height: normal; font-weight: 400; text-align: left; box-sizing: content-box; direction: ltr; }
li div { padding-top: 0px; }
blockquote { margin: 1rem 0px; }
li .mathjax-block, li p { margin: 0.5rem 0px; }
li blockquote { margin: 1rem 0px; }
li { margin: 0px; position: relative; }
blockquote > :last-child { margin-bottom: 0px; }
blockquote > :first-child, li > :first-child { margin-top: 0px; }
.footnotes-area { color: rgb(136, 136, 136); margin-top: 0.714rem; padding-bottom: 0.143rem; white-space: normal; }
#write .footnote-line { white-space: pre-wrap; }
@media print {
body, html { border: 1px solid transparent; height: 99%; break-after: avoid; break-before: avoid; font-variant-ligatures: no-common-ligatures; }
#write { margin-top: 0px; border-color: transparent !important; padding-top: 0px !important; padding-bottom: 0px !important; }
.typora-export * { -webkit-print-color-adjust: exact; }
.typora-export #write { break-after: avoid; }
.typora-export #write::after { height: 0px; }
.is-mac table { break-inside: avoid; }
#write > p:nth-child(1) { margin-top: 0px; }
.typora-export-show-outline .typora-export-sidebar { display: none; }
figure { overflow-x: visible; }
}
.footnote-line { margin-top: 0.714em; font-size: 0.7em; }
a img, img a { cursor: pointer; }
pre.md-meta-block { font-size: 0.8rem; min-height: 0.8rem; white-space: pre-wrap; background: rgb(204, 204, 204); display: block; overflow-x: hidden; }
p > .md-image:only-child:not(.md-img-error) img, p > img:only-child { display: block; margin: auto; }
#write.first-line-indent p > .md-image:only-child:not(.md-img-error) img { left: -2em; position: relative; }
p > .md-image:only-child { display: inline-block; width: 100%; }
#write .MathJax_Display { margin: 0.8em 0px 0px; }
.md-math-block { width: 100%; }
.md-math-block:not(:empty)::after { display: none; }
.MathJax_ref { fill: currentcolor; }
[contenteditable="true"]:active, [contenteditable="true"]:focus, [contenteditable="false"]:active, [contenteditable="false"]:focus { outline: 0px; box-shadow: none; }
.md-task-list-item { position: relative; list-style-type: none; }
.task-list-item.md-task-list-item { padding-left: 0px; }
.md-task-list-item > input { position: absolute; top: 0px; left: 0px; margin-left: -1.2em; margin-top: calc(1em - 10px); border: none; }
.math { font-size: 1rem; }
.md-toc { min-height: 3.58rem; position: relative; font-size: 0.9rem; border-radius: 10px; }
.md-toc-content { position: relative; margin-left: 0px; }
.md-toc-content::after, .md-toc::after { display: none; }
.md-toc-item { display: block; color: rgb(65, 131, 196); }
.md-toc-item a { text-decoration: none; }
.md-toc-inner:hover { text-decoration: underline; }
.md-toc-inner { display: inline-block; cursor: pointer; }
.md-toc-h1 .md-toc-inner { margin-left: 0px; font-weight: 700; }
.md-toc-h2 .md-toc-inner { margin-left: 2em; }
.md-toc-h3 .md-toc-inner { margin-left: 4em; }
.md-toc-h4 .md-toc-inner { margin-left: 6em; }
.md-toc-h5 .md-toc-inner { margin-left: 8em; }
.md-toc-h6 .md-toc-inner { margin-left: 10em; }
@media screen and (max-width: 48em) {
.md-toc-h3 .md-toc-inner { margin-left: 3.5em; }
.md-toc-h4 .md-toc-inner { margin-left: 5em; }
.md-toc-h5 .md-toc-inner { margin-left: 6.5em; }
.md-toc-h6 .md-toc-inner { margin-left: 8em; }
}
a.md-toc-inner { font-size: inherit; font-style: inherit; font-weight: inherit; line-height: inherit; }
.footnote-line a:not(.reversefootnote) { color: inherit; }
.reversefootnote { font-family: ui-monospace, sans-serif; }
.md-attr { display: none; }
.md-fn-count::after { content: "."; }
code, pre, samp, tt { font-family: var(--monospace); }
kbd { margin: 0px 0.1em; padding: 0.1em 0.6em; font-size: 0.8em; color: rgb(36, 39, 41); background: rgb(255, 255, 255); border: 1px solid rgb(173, 179, 185); border-radius: 3px; box-shadow: rgba(12, 13, 14, 0.2) 0px 1px 0px, rgb(255, 255, 255) 0px 0px 0px 2px inset; white-space: nowrap; vertical-align: middle; }
.md-comment { color: rgb(162, 127, 3); opacity: 0.6; font-family: var(--monospace); }
code { text-align: left; vertical-align: initial; }
a.md-print-anchor { white-space: pre !important; border-width: initial !important; border-style: none !important; border-color: initial !important; display: inline-block !important; position: absolute !important; width: 1px !important; right: 0px !important; outline: 0px !important; background: 0px 0px !important; text-decoration: initial !important; text-shadow: initial !important; }
.os-windows.monocolor-emoji .md-emoji { font-family: "Segoe UI Symbol", sans-serif; }
.md-diagram-panel > svg { max-width: 100%; }
[lang="flow"] svg, [lang="mermaid"] svg { max-width: 100%; height: auto; }
[lang="mermaid"] .node text { font-size: 1rem; }
table tr th { border-bottom: 0px; }
video { max-width: 100%; display: block; margin: 0px auto; }
iframe { max-width: 100%; width: 100%; border: none; }
.highlight td, .highlight tr { border: 0px; }
mark { background: rgb(255, 255, 0); color: rgb(0, 0, 0); }
.md-html-inline .md-plain, .md-html-inline strong, mark .md-inline-math, mark strong { color: inherit; }
.md-expand mark .md-meta { opacity: 0.3 !important; }
mark .md-meta { color: rgb(0, 0, 0); }
@media print {
.typora-export h1, .typora-export h2, .typora-export h3, .typora-export h4, .typora-export h5, .typora-export h6 { break-inside: avoid; }
}
.md-diagram-panel .messageText { stroke: none !important; }
.md-diagram-panel .start-state { fill: var(--node-fill); }
.md-diagram-panel .edgeLabel rect { opacity: 1 !important; }
.md-fences.md-fences-math { font-size: 1em; }
.md-fences-advanced:not(.md-focus) { padding: 0px; white-space: nowrap; border: 0px; }
.md-fences-advanced:not(.md-focus) { background: inherit; }
.typora-export-show-outline .typora-export-content { max-width: 1440px; margin: auto; display: flex; flex-direction: row; }
.typora-export-sidebar { width: 300px; font-size: 0.8rem; margin-top: 80px; margin-right: 18px; }
.typora-export-show-outline #write { --webkit-flex: 2; flex: 2 1 0%; }
.typora-export-sidebar .outline-content { position: fixed; top: 0px; max-height: 100%; overflow: hidden auto; padding-bottom: 30px; padding-top: 60px; width: 300px; }
@media screen and (max-width: 1024px) {
.typora-export-sidebar, .typora-export-sidebar .outline-content { width: 240px; }
}
@media screen and (max-width: 800px) {
.typora-export-sidebar { display: none; }
}
.outline-content li, .outline-content ul { margin-left: 0px; margin-right: 0px; padding-left: 0px; padding-right: 0px; list-style: none; overflow-wrap: anywhere; }
.outline-content ul { margin-top: 0px; margin-bottom: 0px; }
.outline-content strong { font-weight: 400; }
.outline-expander { width: 1rem; height: 1.42857rem; position: relative; display: table-cell; vertical-align: middle; cursor: pointer; padding-left: 4px; }
.outline-expander::before { content: ""; position: relative; font-family: Ionicons; display: inline-block; font-size: 8px; vertical-align: middle; }
.outline-item { padding-top: 3px; padding-bottom: 3px; cursor: pointer; }
.outline-expander:hover::before { content: ""; }
.outline-h1 > .outline-item { padding-left: 0px; }
.outline-h2 > .outline-item { padding-left: 1em; }
.outline-h3 > .outline-item { padding-left: 2em; }
.outline-h4 > .outline-item { padding-left: 3em; }
.outline-h5 > .outline-item { padding-left: 4em; }
.outline-h6 > .outline-item { padding-left: 5em; }
.outline-label { cursor: pointer; display: table-cell; vertical-align: middle; text-decoration: none; color: inherit; }
.outline-label:hover { text-decoration: underline; }
.outline-item:hover { border-color: rgb(245, 245, 245); background-color: var(--item-hover-bg-color); }
.outline-item:hover { margin-left: -28px; margin-right: -28px; border-left: 28px solid transparent; border-right: 28px solid transparent; }
.outline-item-single .outline-expander::before, .outline-item-single .outline-expander:hover::before { display: none; }
.outline-item-open > .outline-item > .outline-expander::before { content: ""; }
.outline-children { display: none; }
.info-panel-tab-wrapper { display: none; }
.outline-item-open > .outline-children { display: block; }
.typora-export .outline-item { padding-top: 1px; padding-bottom: 1px; }
.typora-export .outline-item:hover { margin-right: -8px; border-right: 8px solid transparent; }
.typora-export .outline-expander::before { content: "+"; font-family: inherit; top: -1px; }
.typora-export .outline-expander:hover::before, .typora-export .outline-item-open > .outline-item > .outline-expander::before { content: "−"; }
.typora-export-collapse-outline .outline-children { display: none; }
.typora-export-collapse-outline .outline-item-open > .outline-children, .typora-export-no-collapse-outline .outline-children { display: block; }
.typora-export-no-collapse-outline .outline-expander::before { content: "" !important; }
.typora-export-show-outline .outline-item-active > .outline-item .outline-label { font-weight: 700; }
.md-inline-math-container mjx-container { zoom: 0.95; }
mjx-container { break-inside: avoid; }
.md-alert.md-alert-note { border-left-color: rgb(9, 105, 218); }
.md-alert.md-alert-important { border-left-color: rgb(130, 80, 223); }
.md-alert.md-alert-warning { border-left-color: rgb(154, 103, 0); }
.md-alert.md-alert-tip { border-left-color: rgb(31, 136, 61); }
.md-alert.md-alert-caution { border-left-color: rgb(207, 34, 46); }
.md-alert { padding: 0px 1em; margin-bottom: 16px; color: inherit; border-left: 0.25em solid rgb(0, 0, 0); }
.md-alert-text-note { color: rgb(9, 105, 218); }
.md-alert-text-important { color: rgb(130, 80, 223); }
.md-alert-text-warning { color: rgb(154, 103, 0); }
.md-alert-text-tip { color: rgb(31, 136, 61); }
.md-alert-text-caution { color: rgb(207, 34, 46); }
.md-alert-text { font-size: 0.9rem; font-weight: 700; }
.md-alert-text svg { fill: currentcolor; position: relative; top: 0.125em; margin-right: 1ch; overflow: visible; }
.md-alert-text-container::after { content: attr(data-text); text-transform: capitalize; pointer-events: none; margin-right: 1ch; }
.CodeMirror { height: auto; }
.CodeMirror.cm-s-inner { background: inherit; }
.CodeMirror-scroll { overflow: auto hidden; z-index: 3; }
.CodeMirror-gutter-filler, .CodeMirror-scrollbar-filler { background-color: rgb(255, 255, 255); }
.CodeMirror-gutters { border-right: 1px solid rgb(221, 221, 221); background: inherit; white-space: nowrap; }
.CodeMirror-linenumber { padding: 0px 3px 0px 5px; text-align: right; color: rgb(153, 153, 153); }
.cm-s-inner .cm-keyword { color: rgb(119, 0, 136); }
.cm-s-inner .cm-atom, .cm-s-inner.cm-atom { color: rgb(34, 17, 153); }
.cm-s-inner .cm-number { color: rgb(17, 102, 68); }
.cm-s-inner .cm-def { color: rgb(0, 0, 255); }
.cm-s-inner .cm-variable { color: rgb(0, 0, 0); }
.cm-s-inner .cm-variable-2 { color: rgb(0, 85, 170); }
.cm-s-inner .cm-variable-3 { color: rgb(0, 136, 85); }
.cm-s-inner .cm-string { color: rgb(170, 17, 17); }
.cm-s-inner .cm-property { color: rgb(0, 0, 0); }
.cm-s-inner .cm-operator { color: rgb(152, 26, 26); }
.cm-s-inner .cm-comment, .cm-s-inner.cm-comment { color: rgb(170, 85, 0); }
.cm-s-inner .cm-string-2 { color: rgb(255, 85, 0); }
.cm-s-inner .cm-meta { color: rgb(85, 85, 85); }
.cm-s-inner .cm-qualifier { color: rgb(85, 85, 85); }
.cm-s-inner .cm-builtin { color: rgb(51, 0, 170); }
.cm-s-inner .cm-bracket { color: rgb(153, 153, 119); }
.cm-s-inner .cm-tag { color: rgb(17, 119, 0); }
.cm-s-inner .cm-attribute { color: rgb(0, 0, 204); }
.cm-s-inner .cm-header, .cm-s-inner.cm-header { color: rgb(0, 0, 255); }
.cm-s-inner .cm-quote, .cm-s-inner.cm-quote { color: rgb(0, 153, 0); }
.cm-s-inner .cm-hr, .cm-s-inner.cm-hr { color: rgb(153, 153, 153); }
.cm-s-inner .cm-link, .cm-s-inner.cm-link { color: rgb(0, 0, 204); }
.cm-negative { color: rgb(221, 68, 68); }
.cm-positive { color: rgb(34, 153, 34); }
.cm-header, .cm-strong { font-weight: 700; }
.cm-del { text-decoration: line-through; }
.cm-em { font-style: italic; }
.cm-link { text-decoration: underline; }
.cm-error { color: red; }
.cm-invalidchar { color: red; }
.cm-constant { color: rgb(38, 139, 210); }
.cm-defined { color: rgb(181, 137, 0); }
div.CodeMirror span.CodeMirror-matchingbracket { color: rgb(0, 255, 0); }
div.CodeMirror span.CodeMirror-nonmatchingbracket { color: rgb(255, 34, 34); }
.cm-s-inner .CodeMirror-activeline-background { background: inherit; }
.CodeMirror { position: relative; overflow: hidden; }
.CodeMirror-scroll { height: 100%; outline: 0px; position: relative; box-sizing: content-box; background: inherit; }
.CodeMirror-sizer { position: relative; }
.CodeMirror-gutter-filler, .CodeMirror-hscrollbar, .CodeMirror-scrollbar-filler, .CodeMirror-vscrollbar { position: absolute; z-index: 6; display: none; outline: 0px; }
.CodeMirror-vscrollbar { right: 0px; top: 0px; overflow: hidden; }
.CodeMirror-hscrollbar { bottom: 0px; left: 0px; overflow: auto hidden; }
.CodeMirror-scrollbar-filler { right: 0px; bottom: 0px; }
.CodeMirror-gutter-filler { left: 0px; bottom: 0px; }
.CodeMirror-gutters { position: absolute; left: 0px; top: 0px; padding-bottom: 10px; z-index: 3; overflow-y: hidden; }
.CodeMirror-gutter { white-space: normal; height: 100%; box-sizing: content-box; padding-bottom: 30px; margin-bottom: -32px; display: inline-block; }
.CodeMirror-gutter-wrapper { position: absolute; z-index: 4; background: 0px 0px !important; border: none !important; }
.CodeMirror-gutter-background { position: absolute; top: 0px; bottom: 0px; z-index: 4; }
.CodeMirror-gutter-elt { position: absolute; cursor: default; z-index: 4; }
.CodeMirror-lines { cursor: text; }
.CodeMirror pre { border-radius: 0px; border-width: 0px; background: 0px 0px; font-family: inherit; font-size: inherit; margin: 0px; white-space: pre; overflow-wrap: normal; color: inherit; z-index: 2; position: relative; overflow: visible; }
.CodeMirror-wrap pre { overflow-wrap: break-word; white-space: pre-wrap; word-break: normal; }
.CodeMirror-code pre { border-right: 30px solid transparent; width: fit-content; }
.CodeMirror-wrap .CodeMirror-code pre { border-right: none; width: auto; }
.CodeMirror-linebackground { position: absolute; inset: 0px; z-index: 0; }
.CodeMirror-linewidget { position: relative; z-index: 2; overflow: auto; }
.CodeMirror-wrap .CodeMirror-scroll { overflow-x: hidden; }
.CodeMirror-measure { position: absolute; width: 100%; height: 0px; overflow: hidden; visibility: hidden; }
.CodeMirror-measure pre { position: static; }
.CodeMirror div.CodeMirror-cursor { position: absolute; visibility: hidden; border-right: none; width: 0px; }
.CodeMirror div.CodeMirror-cursor { visibility: hidden; }
.CodeMirror-focused div.CodeMirror-cursor { visibility: inherit; }
.cm-searching { background: rgba(255, 255, 0, 0.4); }
span.cm-underlined { text-decoration: underline; }
span.cm-strikethrough { text-decoration: line-through; }
.cm-tw-syntaxerror { color: rgb(255, 255, 255); background-color: rgb(153, 0, 0); }
.cm-tw-deleted { text-decoration: line-through; }
.cm-tw-header5 { font-weight: 700; }
.cm-tw-listitem:first-child { padding-left: 10px; }
.cm-tw-box { border-style: solid; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-color: inherit; border-top-width: 0px !important; }
.cm-tw-underline { text-decoration: underline; }
@media print {
.CodeMirror div.CodeMirror-cursor { visibility: hidden; }
}
@include-when-export url(https://fonts.googleapis.com/css?family=Merriweather:900,900italic,300,300italic&subset=latin-ext);
@include-when-export url(https://fonts.googleapis.com/css?family=Lato:900,300&subset=latin-ext);
:root {
--control-text-color: #777;
}
/**
* forked from pixyll.com
* MIT license
*/
h1,
.h1,
.f1 {
font-size: 2rem;
line-height: 2.5rem;
}
h2,
.h2,
.f2 {
font-size: 1.5rem;
line-height: 2rem;
}
h3,
.h3,
.f3 {
font-size: 1.25rem;
line-height: 1.5rem;
}
p,
.p,
.f4,
h4,
h5,
h6,
dl,
ol,
ul,
pre[cid],
div[cid],
#typora-source {
font-size: 1.125rem;
line-height: 1.5rem;
}
h4 {
font-size: 1.13rem;
}
/*
Pixyll
A simple, beautiful theme for Jekyll that emphasizes content rather than aesthetic fluff.
Best served with BASSCSS (http://jxnblk.github.io/basscss)
Crafted with <3 by John Otander (@4lpine) - ©2015 John Otander MIT License http://opensource.org/licenses/MIT
*/
body {
font-family: "Merriweather", "PT Serif", Georgia, "Times New Roman", "STSong", 'Segoe UI Emoji', Serif;
line-height: 1.5rem;
font-weight: 400;
}
#write {
max-width: 914px;
color: #333;
}
@media only screen and (min-width: 1400px) {
#write {
max-width: 1100px;
}
}
@media only screen and (min-width: 1700px) {
#write {
max-width: 1200px;
}
}
img {
width: auto;
max-width: 100%;
}
body {
font-size: 1.5rem;
box-sizing: border-box;
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
}
.ty-table-edit {
background: #ededed;
}
table {
width: 100%;
font-size: 1.125rem;
}
table > thead > tr > th,
table > thead > tr > td,
table > tbody > tr > th,
table > tbody > tr > td,
table > tfoot > tr > th,
table > tfoot > tr > td {
padding: 12px;
line-height: 1.2;
vertical-align: top;
border-top: 1px solid #333;
}
table > thead > tr > th {
vertical-align: bottom;
border-bottom: 2px solid #333;
}
table > caption + thead > tr:first-child > th,
table > caption + thead > tr:first-child > td,
table > colgroup + thead > tr:first-child > th,
table > colgroup + thead > tr:first-child > td,
table > thead:first-child > tr:first-child > th,
table > thead:first-child > tr:first-child > td {
border-top: 0;
}
table > tbody + tbody {
border-top: 2px solid #333;
}
p {
font-weight: 300;
line-height: 1.5;
}
abbr {
border-bottom: 1px black dotted;
cursor: help;
}
pre,
code {
font-family: Menlo, Monaco, "Courier New", monospace;
}
code,
.md-fences {
color: #7a7a7a;
}
.md-fences {
padding: 1.125em;
margin-bottom: 0.88em;
font-size: 1rem;
border: 1px solid #7a7a7a;
padding-bottom: 0.5rem;
padding-top: 0.5rem;
}
blockquote {
padding: 1.33em;
font-style: italic;
border-left: 5px solid #7a7a7a;
color: #555;
}
blockquote em {
color: #000;
}
blockquote footer {
font-size: .85rem;
font-style: normal;
background-color: #fff;
color: #7a7a7a;
border-color: transparent;
}
h1,
.h1,
h2,
.h2,
h3,
.h3,
h4,
.h4,
h5,
.h5,
h6,
.h6 {
font-family: "Lato", 'Helvetica Neue', Helvetica, sans-serif;
font-weight: bold;
line-height: 1.2;
margin: 1em 0 0.5em;
}
@media screen and (min-width: 48em) {
.h1,
h1 {
font-size: 3.250rem;
}
.h2,
h2 {
font-size: 2.298rem;
}
.h3,
h3 {
font-size: 1.625rem;
}
.h4,
h4 {
font-size: 1.3rem;
}
#write>h4.md-focus:before,
#write>h5.md-focus:before,
#write>h6.md-focus:before{
top: 1px;
}
.p,
p,
li {
font-size: 1.25rem;
line-height: 1.8;
}
table {
font-size: 1.25rem;
}
}
@media (max-width: 48em) {
blockquote {
margin-left: 1rem;
margin-right: 0;
padding: 0.5em;
}
.h1,
h1 {
font-size: 2.827rem;
}
.h2,
h2 {
font-size: 1.999rem;
}
.h3,
h3 {
font-size: 1.413rem;
}
.h4,
h4 {
font-size: 1.3rem;
}
}
@media screen and (min-width: 64em) {
.h1,
h1 {
font-size: 4.498rem;
}
.h2,
h2 {
font-size: 2.29rem;
}
.h3,
h3 {
font-size: 1.9rem;
}
.h4,
h4 {
font-size: 1.591rem;
}
#write>h4.md-focus:before{
top:4px;
}
}
a {
color: #463F5C;
text-decoration: underline;
}
#write {
padding-top: 2rem;
}
#write pre.md-meta-block {
min-height: 35px;
padding: 0.5em 1em;
white-space: pre;
border: 0px;
border-left: 30px #f8f8f8 solid;
border-right: 30px #f8f8f8 solid;
width: 100vw;
max-width: calc(100% + 60px);
margin-left: -30px;
margin-bottom: 2em;
margin-top: -2010px;
padding-top: 2000px;
padding-bottom: 10px;
line-height: 1.5em;
color: #7a7a7a;
background-color: #fafafa;
font-family: 'Lato', 'Helvetica Neue', Helvetica, sans-serif;
font-weight: 300;
clear: both;
padding-left: 0;
font-size:1.125rem;
}
.md-image>.md-meta {
color: #463F5C
}
.footnotes {
font-size:1.1rem;
}
.md-tag {
font-family: 'Lato', 'Helvetica Neue', Helvetica, sans-serif;
}
.code-tooltip {
background: white;
}
.code-tooltip-content {
font-size: 1.1rem;
}
.task-list{
padding-left: 0;
}
.md-task-list-item {
padding-left:34px;
}
.md-task-list-item > input{
width: 1.25rem;
height: 1.25rem;
display: block;
-webkit-appearance: initial;
top: -0.2rem;
margin-left: -1.6em;
margin-top: calc(1rem - 7px);
border: none;
}
.md-task-list-item > input:focus{
outline: none;
box-shadow: none;
}
.md-task-list-item > input:before{
border: 1px solid #555;
border-radius: 1.5rem;
width: 1.5rem;
height: 1.5rem;
background: #fff;
content: ' ';
transition: background-color 200ms ease-in-out;
display: block;
}
.md-task-list-item > input:checked:before,
.md-task-list-item > input[checked]:before{
background: #333;
border-width: 2px;
display:inline-block;
transition: background-color 200ms ease-in-out;
}
.md-task-list-item > input:checked:after,
.md-task-list-item > input[checked]:after {
opacity: 1;
}
.md-task-list-item > input:after {
opacity: 1;
-webkit-transition: opacity 0.05s ease-in-out;
-moz-transition: opacity 0.05s ease-in-out;
transition: opacity 0.05s ease-in-out;
-webkit-transform: rotate(-45deg);
-moz-transform: rotate(-45deg);
transform: rotate(-45deg);
position: absolute;
top: 0.4375rem;
left: 0.28125rem;
width: 0.9375rem;
height: 0.5rem;
border: 3px solid #fff;
border-top: 0;
border-right: 0;
content: ' ';
opacity: 0;
}
.md-tag {
color:inherit;
}
.md-toc:focus .md-toc-content{
margin-top: 19px;
}
#typora-sidebar {
font-size:1rem !important;
}
.html-for-mac #typora-sidebar {
background-color:white;
}
.outline-content li, .outline-content ul {
font-size:1rem !important;
}
.outline-title {
line-height: inherit;
margin-top: 10px;
}
.outline-expander {
width: 18px;
}
.outline-expander:before {
content: "+";
font-family: inherit;
color: rgb(108, 108, 108);
font-size: 1.5rem;
top: -0.1rem;
}
.outline-expander:hover:before {
content: "+";
}
.outline-item-open>.outline-item>.outline-expander:before{
content: "-";
}
/** source code mode */
#typora-source {
font-family: Courier, monospace;
color: #6A6A6A;
}
.os-windows #typora-source {
font-family: inherit;
}
.cm-s-typora-default .cm-header,
.cm-s-typora-default .cm-property,
.CodeMirror.cm-s-typora-default div.CodeMirror-cursor {
color: #428bca;
}
.cm-s-typora-default .cm-atom, .cm-s-typora-default .cm-number {
color: #777777;
}
.md-diagram-panel {
margin-top: 24px;
margin-left: -1.2em;
}
.md-mathjax-midline {
background: #fafafa;
}
.enable-diagrams pre.md-fences[lang="sequence"] .code-tooltip,
.enable-diagrams pre.md-fences[lang="flow"] .code-tooltip,
.enable-diagrams pre.md-fences[lang="mermaid"] .code-tooltip {
bottom: -3.4em;
}
.dropdown-menu .divider {
border-color: #e5e5e5;
}
li {
margin: 0.5rem 0;
}
li > *:last-child {
margin-bottom: 0;
}
mjx-container[jax="SVG"] {
direction: ltr;
}
mjx-container[jax="SVG"] > svg {
overflow: visible;
min-height: 1px;
min-width: 1px;
}
mjx-container[jax="SVG"] > svg a {
fill: blue;
stroke: blue;
}
mjx-assistive-mml {
position: absolute !important;
top: 0px;
left: 0px;
clip: rect(1px, 1px, 1px, 1px);
padding: 1px 0px 0px 0px !important;
border: 0px !important;
display: block !important;
width: auto !important;
overflow: hidden !important;
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
mjx-assistive-mml[display="block"] {
width: 100% !important;
}
mjx-container[jax="SVG"][display="true"] {
display: block;
text-align: center;
margin: 1em 0;
}
mjx-container[jax="SVG"][display="true"][width="full"] {
display: flex;
}
mjx-container[jax="SVG"][justify="left"] {
text-align: left;
}
mjx-container[jax="SVG"][justify="right"] {
text-align: right;
}
g[data-mml-node="merror"] > g {
fill: red;
stroke: red;
}
g[data-mml-node="merror"] > rect[data-background] {
fill: yellow;
stroke: none;
}
g[data-mml-node="mtable"] > line[data-line], svg[data-table] > g > line[data-line] {
stroke-width: 70px;
fill: none;
}
g[data-mml-node="mtable"] > rect[data-frame], svg[data-table] > g > rect[data-frame] {
stroke-width: 70px;
fill: none;
}
g[data-mml-node="mtable"] > .mjx-dashed, svg[data-table] > g > .mjx-dashed {
stroke-dasharray: 140;
}
g[data-mml-node="mtable"] > .mjx-dotted, svg[data-table] > g > .mjx-dotted {
stroke-linecap: round;
stroke-dasharray: 0,140;
}
g[data-mml-node="mtable"] > g > svg {
overflow: visible;
}
[jax="SVG"] mjx-tool {
display: inline-block;
position: relative;
width: 0;
height: 0;
}
[jax="SVG"] mjx-tool > mjx-tip {
position: absolute;
top: 0;
left: 0;
}
mjx-tool > mjx-tip {
display: inline-block;
padding: .2em;
border: 1px solid #888;
font-size: 70%;
background-color: #F8F8F8;
color: black;
box-shadow: 2px 2px 5px #AAAAAA;
}
g[data-mml-node="maction"][data-toggle] {
cursor: pointer;
}
mjx-status {
display: block;
position: fixed;
left: 1em;
bottom: 1em;
min-width: 25%;
padding: .2em .4em;
border: 1px solid #888;
font-size: 90%;
background-color: #F8F8F8;
color: black;
}
foreignObject[data-mjx-xml] {
font-family: initial;
line-height: normal;
overflow: visible;
}
mjx-container[jax="SVG2"] path[data-c], mjx-container[jax="SVG2"] use[data-c] {
stroke-width: 3;
}
g[data-mml-node="xypic"] path {
stroke-width: inherit;
}
.MathJax g[data-mml-node="xypic"] path {
stroke-width: inherit;
}
mjx-container[jax="SVG"] path[data-c], mjx-container[jax="SVG"] use[data-c] {
stroke-width: 0;
}
</style><title>仿真对象</title>
</head>
<body class='typora-export os-windows'><div class='typora-export-content'>
<div id='write' class=''><h1 id='1--数值仿真对象'><span>1. 数值仿真对象</span></h1><h2 id='11-仿真对象1---hammerstein系统'><span>1.1 仿真对象1 - Hammerstein系统</span></h2><p><span>K. Huang, K. Wei, F. Li, C. Yang and W. Gui, "LSTM-MPC: A Deep Learning Based Predictive Control Method for Multimode Process Control," in IEEE Transactions on Industrial Electronics, vol. 70, no. 11, pp. 11544-11554, Nov. 2023, doi: 10.1109/TIE.2022.3229323.</span></p><h3 id='111-系统描述'><span>1.1.1 系统描述</span></h3><p><span>在本研究中,选择Hammerstein系统来研究不同控制方法的性能。Hammerstein系统的数学模型如下(StateSpace):</span></p><div contenteditable="false" spellcheck="false" class="mathjax-block md-end-block md-math-block md-rawblock" id="mathjax-n87" cid="n87" mdtype="math_block" data-math-tag-before="0" data-math-tag-after="0" data-math-labels="[]"><div class="md-math-container"><mjx-container class="MathJax" jax="SVG" display="true" style="position: relative;"><svg xmlns="http://www.w3.org/2000/svg" width="63.678ex" height="5.428ex" role="img" focusable="false" viewBox="0 -1449.5 28145.7 2399" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" style="vertical-align: -2.148ex;" class=""><defs><path id="MJX-24-TEX-S3-7B" d="M618 -943L612 -949H582L568 -943Q472 -903 411 -841T332 -703Q327 -682 327 -653T325 -350Q324 -28 323 -18Q317 24 301 61T264 124T221 171T179 205T147 225T132 234Q130 238 130 250Q130 255 130 258T131 264T132 267T134 269T139 272T144 275Q207 308 256 367Q310 436 323 519Q324 529 325 851Q326 1124 326 1154T332 1205Q369 1358 566 1443L582 1450H612L618 1444V1429Q618 1413 616 1411L608 1406Q599 1402 585 1393T552 1372T515 1343T479 1305T449 1257T429 1200Q425 1180 425 1152T423 851Q422 579 422 549T416 498Q407 459 388 424T346 364T297 318T250 284T214 264T197 254L188 251L205 242Q290 200 345 138T416 3Q421 -18 421 -48T423 -349Q423 -397 423 -472Q424 -677 428 -694Q429 -697 429 -699Q434 -722 443 -743T465 -782T491 -816T519 -845T548 -868T574 -886T595 -899T610 -908L616 -910Q618 -912 618 -928V-943Z"></path><path id="MJX-24-TEX-I-1D465" d="M52 289Q59 331 106 386T222 442Q257 442 286 424T329 379Q371 442 430 442Q467 442 494 420T522 361Q522 332 508 314T481 292T458 288Q439 288 427 299T415 328Q415 374 465 391Q454 404 425 404Q412 404 406 402Q368 386 350 336Q290 115 290 78Q290 50 306 38T341 26Q378 26 414 59T463 140Q466 150 469 151T485 153H489Q504 153 504 145Q504 144 502 134Q486 77 440 33T333 -11Q263 -11 227 52Q186 -10 133 -10H127Q78 -10 57 16T35 71Q35 103 54 123T99 143Q142 143 142 101Q142 81 130 66T107 46T94 41L91 40Q91 39 97 36T113 29T132 26Q168 26 194 71Q203 87 217 139T245 247T261 313Q266 340 266 352Q266 380 251 392T217 404Q177 404 142 372T93 290Q91 281 88 280T72 278H58Q52 284 52 289Z"></path><path id="MJX-24-TEX-N-28" d="M94 250Q94 319 104 381T127 488T164 576T202 643T244 695T277 729T302 750H315H319Q333 750 333 741Q333 738 316 720T275 667T226 581T184 443T167 250T184 58T225 -81T274 -167T316 -220T333 -241Q333 -250 318 -250H315H302L274 -226Q180 -141 137 -14T94 250Z"></path><path id="MJX-24-TEX-I-1D458" d="M121 647Q121 657 125 670T137 683Q138 683 209 688T282 694Q294 694 294 686Q294 679 244 477Q194 279 194 272Q213 282 223 291Q247 309 292 354T362 415Q402 442 438 442Q468 442 485 423T503 369Q503 344 496 327T477 302T456 291T438 288Q418 288 406 299T394 328Q394 353 410 369T442 390L458 393Q446 405 434 405H430Q398 402 367 380T294 316T228 255Q230 254 243 252T267 246T293 238T320 224T342 206T359 180T365 147Q365 130 360 106T354 66Q354 26 381 26Q429 26 459 145Q461 153 479 153H483Q499 153 499 144Q499 139 496 130Q455 -11 378 -11Q333 -11 305 15T277 90Q277 108 280 121T283 145Q283 167 269 183T234 206T200 217T182 220H180Q168 178 159 139T145 81T136 44T129 20T122 7T111 -2Q98 -11 83 -11Q66 -11 57 -1T48 16Q48 26 85 176T158 471L195 616Q196 629 188 632T149 637H144Q134 637 131 637T124 640T121 647Z"></path><path id="MJX-24-TEX-N-29" d="M60 749L64 750Q69 750 74 750H86L114 726Q208 641 251 514T294 250Q294 182 284 119T261 12T224 -76T186 -143T145 -194T113 -227T90 -246Q87 -249 86 -250H74Q66 -250 63 -250T58 -247T55 -238Q56 -237 66 -225Q221 -64 221 250T66 725Q56 737 55 738Q55 746 60 749Z"></path><path id="MJX-24-TEX-N-3D" d="M56 347Q56 360 70 367H707Q722 359 722 347Q722 336 708 328L390 327H72Q56 332 56 347ZM56 153Q56 168 72 173H708Q722 163 722 153Q722 140 707 133H70Q56 140 56 153Z"></path><path id="MJX-24-TEX-I-1D44E" d="M33 157Q33 258 109 349T280 441Q331 441 370 392Q386 422 416 422Q429 422 439 414T449 394Q449 381 412 234T374 68Q374 43 381 35T402 26Q411 27 422 35Q443 55 463 131Q469 151 473 152Q475 153 483 153H487Q506 153 506 144Q506 138 501 117T481 63T449 13Q436 0 417 -8Q409 -10 393 -10Q359 -10 336 5T306 36L300 51Q299 52 296 50Q294 48 292 46Q233 -10 172 -10Q117 -10 75 30T33 157ZM351 328Q351 334 346 350T323 385T277 405Q242 405 210 374T160 293Q131 214 119 129Q119 126 119 118T118 106Q118 61 136 44T179 26Q217 26 254 59T298 110Q300 114 325 217T351 328Z"></path><path id="MJX-24-TEX-I-1D462" d="M21 287Q21 295 30 318T55 370T99 420T158 442Q204 442 227 417T250 358Q250 340 216 246T182 105Q182 62 196 45T238 27T291 44T328 78L339 95Q341 99 377 247Q407 367 413 387T427 416Q444 431 463 431Q480 431 488 421T496 402L420 84Q419 79 419 68Q419 43 426 35T447 26Q469 29 482 57T512 145Q514 153 532 153Q551 153 551 144Q550 139 549 130T540 98T523 55T498 17T462 -8Q454 -10 438 -10Q372 -10 347 46Q345 45 336 36T318 21T296 6T267 -6T233 -11Q189 -11 155 7Q103 38 103 113Q103 170 138 262T173 379Q173 380 173 381Q173 390 173 393T169 400T158 404H154Q131 404 112 385T82 344T65 302T57 280Q55 278 41 278H27Q21 284 21 287Z"></path><path id="MJX-24-TEX-N-2212" d="M84 237T84 250T98 270H679Q694 262 694 250T679 230H98Q84 237 84 250Z"></path><path id="MJX-24-TEX-I-1D44F" d="M73 647Q73 657 77 670T89 683Q90 683 161 688T234 694Q246 694 246 685T212 542Q204 508 195 472T180 418L176 399Q176 396 182 402Q231 442 283 442Q345 442 383 396T422 280Q422 169 343 79T173 -11Q123 -11 82 27T40 150V159Q40 180 48 217T97 414Q147 611 147 623T109 637Q104 637 101 637H96Q86 637 83 637T76 640T73 647ZM336 325V331Q336 405 275 405Q258 405 240 397T207 376T181 352T163 330L157 322L136 236Q114 150 114 114Q114 66 138 42Q154 26 178 26Q211 26 245 58Q270 81 285 114T318 219Q336 291 336 325Z"></path><path id="MJX-24-TEX-N-32" d="M109 429Q82 429 66 447T50 491Q50 562 103 614T235 666Q326 666 387 610T449 465Q449 422 429 383T381 315T301 241Q265 210 201 149L142 93L218 92Q375 92 385 97Q392 99 409 186V189H449V186Q448 183 436 95T421 3V0H50V19V31Q50 38 56 46T86 81Q115 113 136 137Q145 147 170 174T204 211T233 244T261 278T284 308T305 340T320 369T333 401T340 431T343 464Q343 527 309 573T212 619Q179 619 154 602T119 569T109 550Q109 549 114 549Q132 549 151 535T170 489Q170 464 154 447T109 429Z"></path><path id="MJX-24-TEX-N-2B" d="M56 237T56 250T70 270H369V420L370 570Q380 583 389 583Q402 583 409 568V270H707Q722 262 722 250T707 230H409V-68Q401 -82 391 -82H389H387Q375 -82 369 -68V230H70Q56 237 56 250Z"></path><path id="MJX-24-TEX-N-30" d="M96 585Q152 666 249 666Q297 666 345 640T423 548Q460 465 460 320Q460 165 417 83Q397 41 362 16T301 -15T250 -22Q224 -22 198 -16T137 16T82 83Q39 165 39 320Q39 494 96 585ZM321 597Q291 629 250 629Q208 629 178 597Q153 571 145 525T137 333Q137 175 145 125T181 46Q209 16 250 16Q290 16 318 46Q347 76 354 130T362 333Q362 478 354 524T321 597Z"></path><path id="MJX-24-TEX-N-2E" d="M78 60Q78 84 95 102T138 120Q162 120 180 104T199 61Q199 36 182 18T139 0T96 17T78 60Z"></path><path id="MJX-24-TEX-N-35" d="M164 157Q164 133 148 117T109 101H102Q148 22 224 22Q294 22 326 82Q345 115 345 210Q345 313 318 349Q292 382 260 382H254Q176 382 136 314Q132 307 129 306T114 304Q97 304 95 310Q93 314 93 485V614Q93 664 98 664Q100 666 102 666Q103 666 123 658T178 642T253 634Q324 634 389 662Q397 666 402 666Q410 666 410 648V635Q328 538 205 538Q174 538 149 544L139 546V374Q158 388 169 396T205 412T256 420Q337 420 393 355T449 201Q449 109 385 44T229 -22Q148 -22 99 32T50 154Q50 178 61 192T84 210T107 214Q132 214 148 197T164 157Z"></path><path id="MJX-24-TEX-N-33" d="M127 463Q100 463 85 480T69 524Q69 579 117 622T233 665Q268 665 277 664Q351 652 390 611T430 522Q430 470 396 421T302 350L299 348Q299 347 308 345T337 336T375 315Q457 262 457 175Q457 96 395 37T238 -22Q158 -22 100 21T42 130Q42 158 60 175T105 193Q133 193 151 175T169 130Q169 119 166 110T159 94T148 82T136 74T126 70T118 67L114 66Q165 21 238 21Q293 21 321 74Q338 107 338 175V195Q338 290 274 322Q259 328 213 329L171 330L168 332Q166 335 166 348Q166 366 174 366Q202 366 232 371Q266 376 294 413T322 525V533Q322 590 287 612Q265 626 240 626Q208 626 181 615T143 592T132 580H135Q138 579 143 578T153 573T165 566T175 555T183 540T186 520Q186 498 172 481T127 463Z"></path><path id="MJX-24-TEX-I-1D466" d="M21 287Q21 301 36 335T84 406T158 442Q199 442 224 419T250 355Q248 336 247 334Q247 331 231 288T198 191T182 105Q182 62 196 45T238 27Q261 27 281 38T312 61T339 94Q339 95 344 114T358 173T377 247Q415 397 419 404Q432 431 462 431Q475 431 483 424T494 412T496 403Q496 390 447 193T391 -23Q363 -106 294 -155T156 -205Q111 -205 77 -183T43 -117Q43 -95 50 -80T69 -58T89 -48T106 -45Q150 -45 150 -87Q150 -107 138 -122T115 -142T102 -147L99 -148Q101 -153 118 -160T152 -167H160Q177 -167 186 -165Q219 -156 247 -127T290 -65T313 -9T321 21L315 17Q309 13 296 6T270 -6Q250 -11 231 -11Q185 -11 150 11T104 82Q103 89 103 113Q103 170 138 262T173 379Q173 380 173 381Q173 390 173 393T169 400T158 404H154Q131 404 112 385T82 344T65 302T57 280Q55 278 41 278H27Q21 284 21 287Z"></path><path id="MJX-24-TEX-N-31" d="M213 578L200 573Q186 568 160 563T102 556H83V602H102Q149 604 189 617T245 641T273 663Q275 666 285 666Q294 666 302 660V361L303 61Q310 54 315 52T339 48T401 46H427V0H416Q395 3 257 3Q121 3 100 0H88V46H114Q136 46 152 46T177 47T193 50T201 52T207 57T213 61V578Z"></path><path id="MJX-24-TEX-N-36" d="M42 313Q42 476 123 571T303 666Q372 666 402 630T432 550Q432 525 418 510T379 495Q356 495 341 509T326 548Q326 592 373 601Q351 623 311 626Q240 626 194 566Q147 500 147 364L148 360Q153 366 156 373Q197 433 263 433H267Q313 433 348 414Q372 400 396 374T435 317Q456 268 456 210V192Q456 169 451 149Q440 90 387 34T253 -22Q225 -22 199 -14T143 16T92 75T56 172T42 313ZM257 397Q227 397 205 380T171 335T154 278T148 216Q148 133 160 97T198 39Q222 21 251 21Q302 21 329 59Q342 77 347 104T352 209Q352 289 347 316T329 361Q302 397 257 397Z"></path><path id="MJX-24-TEX-I-1D463" d="M173 380Q173 405 154 405Q130 405 104 376T61 287Q60 286 59 284T58 281T56 279T53 278T49 278T41 278H27Q21 284 21 287Q21 294 29 316T53 368T97 419T160 441Q202 441 225 417T249 361Q249 344 246 335Q246 329 231 291T200 202T182 113Q182 86 187 69Q200 26 250 26Q287 26 319 60T369 139T398 222T409 277Q409 300 401 317T383 343T365 361T357 383Q357 405 376 424T417 443Q436 443 451 425T467 367Q467 340 455 284T418 159T347 40T241 -11Q177 -11 139 22Q102 54 102 117Q102 148 110 181T151 298Q173 362 173 380Z"></path></defs><g stroke="currentColor" fill="currentColor" stroke-width="0" transform="scale(1,-1)"><g data-mml-node="math"><g data-mml-node="mrow"><g data-mml-node="mo" transform="translate(0 -0.5)"><use data-c="7B" xlink:href="#MJX-24-TEX-S3-7B"></use></g><g data-mml-node="mtable" transform="translate(750,0)"><g data-mml-node="mtr" transform="translate(0,558)"><g data-mml-node="mtd"><g data-mml-node="mi"><use data-c="1D465" xlink:href="#MJX-24-TEX-I-1D465"></use></g><g data-mml-node="mo" transform="translate(572,0)"><use data-c="28" xlink:href="#MJX-24-TEX-N-28"></use></g><g data-mml-node="mi" transform="translate(961,0)"><use data-c="1D458" xlink:href="#MJX-24-TEX-I-1D458"></use></g><g data-mml-node="mo" transform="translate(1482,0)"><use data-c="29" xlink:href="#MJX-24-TEX-N-29"></use></g><g data-mml-node="mo" transform="translate(2148.8,0)"><use data-c="3D" xlink:href="#MJX-24-TEX-N-3D"></use></g><g data-mml-node="mi" transform="translate(3204.6,0)"><use data-c="1D44E" xlink:href="#MJX-24-TEX-I-1D44E"></use></g><g data-mml-node="mi" transform="translate(3733.6,0)"><use data-c="1D462" xlink:href="#MJX-24-TEX-I-1D462"></use></g><g data-mml-node="mo" transform="translate(4305.6,0)"><use data-c="28" xlink:href="#MJX-24-TEX-N-28"></use></g><g data-mml-node="mi" transform="translate(4694.6,0)"><use data-c="1D458" xlink:href="#MJX-24-TEX-I-1D458"></use></g><g data-mml-node="mo" transform="translate(5215.6,0)"><use data-c="29" xlink:href="#MJX-24-TEX-N-29"></use></g><g data-mml-node="mo" transform="translate(5826.8,0)"><use data-c="2212" xlink:href="#MJX-24-TEX-N-2212"></use></g><g data-mml-node="mi" transform="translate(6827,0)"><use data-c="1D44F" xlink:href="#MJX-24-TEX-I-1D44F"></use></g><g data-mml-node="mi" transform="translate(7256,0)"><use data-c="1D462" xlink:href="#MJX-24-TEX-I-1D462"></use></g><g data-mml-node="mo" transform="translate(7828,0)"><use data-c="28" xlink:href="#MJX-24-TEX-N-28"></use></g><g data-mml-node="mi" transform="translate(8217,0)"><use data-c="1D458" xlink:href="#MJX-24-TEX-I-1D458"></use></g><g data-mml-node="msup" transform="translate(8738,0)"><g data-mml-node="mo"><use data-c="29" xlink:href="#MJX-24-TEX-N-29"></use></g><g data-mml-node="mn" transform="translate(422,363) scale(0.707)"><use data-c="32" xlink:href="#MJX-24-TEX-N-32"></use></g></g><g data-mml-node="mo" transform="translate(9785.8,0)"><use data-c="2B" xlink:href="#MJX-24-TEX-N-2B"></use></g><g data-mml-node="mn" transform="translate(10786,0)"><use data-c="30" xlink:href="#MJX-24-TEX-N-30"></use><use data-c="2E" xlink:href="#MJX-24-TEX-N-2E" transform="translate(500,0)"></use><use data-c="35" xlink:href="#MJX-24-TEX-N-35" transform="translate(778,0)"></use></g><g data-mml-node="mi" transform="translate(12064,0)"><use data-c="1D462" xlink:href="#MJX-24-TEX-I-1D462"></use></g><g data-mml-node="mo" transform="translate(12636,0)"><use data-c="28" xlink:href="#MJX-24-TEX-N-28"></use></g><g data-mml-node="mi" transform="translate(13025,0)"><use data-c="1D458" xlink:href="#MJX-24-TEX-I-1D458"></use></g><g data-mml-node="msup" transform="translate(13546,0)"><g data-mml-node="mo"><use data-c="29" xlink:href="#MJX-24-TEX-N-29"></use></g><g data-mml-node="mn" transform="translate(422,363) scale(0.707)"><use data-c="33" xlink:href="#MJX-24-TEX-N-33"></use></g></g></g></g><g data-mml-node="mtr" transform="translate(0,-642)"><g data-mml-node="mtd"><g data-mml-node="mi"><use data-c="1D466" xlink:href="#MJX-24-TEX-I-1D466"></use></g><g data-mml-node="mo" transform="translate(490,0)"><use data-c="28" xlink:href="#MJX-24-TEX-N-28"></use></g><g data-mml-node="mi" transform="translate(879,0)"><use data-c="1D458" xlink:href="#MJX-24-TEX-I-1D458"></use></g><g data-mml-node="mo" transform="translate(1622.2,0)"><use data-c="2B" xlink:href="#MJX-24-TEX-N-2B"></use></g><g data-mml-node="mn" transform="translate(2622.4,0)"><use data-c="31" xlink:href="#MJX-24-TEX-N-31"></use></g><g data-mml-node="mo" transform="translate(3122.4,0)"><use data-c="29" xlink:href="#MJX-24-TEX-N-29"></use></g><g data-mml-node="mo" transform="translate(3789.2,0)"><use data-c="3D" xlink:href="#MJX-24-TEX-N-3D"></use></g><g data-mml-node="mn" transform="translate(4845,0)"><use data-c="30" xlink:href="#MJX-24-TEX-N-30"></use><use data-c="2E" xlink:href="#MJX-24-TEX-N-2E" transform="translate(500,0)"></use><use data-c="36" xlink:href="#MJX-24-TEX-N-36" transform="translate(778,0)"></use></g><g data-mml-node="mi" transform="translate(6123,0)"><use data-c="1D466" xlink:href="#MJX-24-TEX-I-1D466"></use></g><g data-mml-node="mo" transform="translate(6613,0)"><use data-c="28" xlink:href="#MJX-24-TEX-N-28"></use></g><g data-mml-node="mi" transform="translate(7002,0)"><use data-c="1D458" xlink:href="#MJX-24-TEX-I-1D458"></use></g><g data-mml-node="mo" transform="translate(7523,0)"><use data-c="29" xlink:href="#MJX-24-TEX-N-29"></use></g><g data-mml-node="mo" transform="translate(8134.2,0)"><use data-c="2212" xlink:href="#MJX-24-TEX-N-2212"></use></g><g data-mml-node="mn" transform="translate(9134.4,0)"><use data-c="30" xlink:href="#MJX-24-TEX-N-30"></use><use data-c="2E" xlink:href="#MJX-24-TEX-N-2E" transform="translate(500,0)"></use><use data-c="31" xlink:href="#MJX-24-TEX-N-31" transform="translate(778,0)"></use></g><g data-mml-node="mi" transform="translate(10412.4,0)"><use data-c="1D466" xlink:href="#MJX-24-TEX-I-1D466"></use></g><g data-mml-node="mo" transform="translate(10902.4,0)"><use data-c="28" xlink:href="#MJX-24-TEX-N-28"></use></g><g data-mml-node="mi" transform="translate(11291.4,0)"><use data-c="1D458" xlink:href="#MJX-24-TEX-I-1D458"></use></g><g data-mml-node="mo" transform="translate(12034.7,0)"><use data-c="2212" xlink:href="#MJX-24-TEX-N-2212"></use></g><g data-mml-node="mn" transform="translate(13034.9,0)"><use data-c="31" xlink:href="#MJX-24-TEX-N-31"></use></g><g data-mml-node="mo" transform="translate(13534.9,0)"><use data-c="29" xlink:href="#MJX-24-TEX-N-29"></use></g><g data-mml-node="mo" transform="translate(14146.1,0)"><use data-c="2B" xlink:href="#MJX-24-TEX-N-2B"></use></g><g data-mml-node="mn" transform="translate(15146.3,0)"><use data-c="31" xlink:href="#MJX-24-TEX-N-31"></use><use data-c="2E" xlink:href="#MJX-24-TEX-N-2E" transform="translate(500,0)"></use><use data-c="32" xlink:href="#MJX-24-TEX-N-32" transform="translate(778,0)"></use></g><g data-mml-node="mi" transform="translate(16424.3,0)"><use data-c="1D465" xlink:href="#MJX-24-TEX-I-1D465"></use></g><g data-mml-node="mo" transform="translate(16996.3,0)"><use data-c="28" xlink:href="#MJX-24-TEX-N-28"></use></g><g data-mml-node="mi" transform="translate(17385.3,0)"><use data-c="1D458" xlink:href="#MJX-24-TEX-I-1D458"></use></g><g data-mml-node="mo" transform="translate(17906.3,0)"><use data-c="29" xlink:href="#MJX-24-TEX-N-29"></use></g><g data-mml-node="mo" transform="translate(18517.6,0)"><use data-c="2212" xlink:href="#MJX-24-TEX-N-2212"></use></g><g data-mml-node="mn" transform="translate(19517.8,0)"><use data-c="30" xlink:href="#MJX-24-TEX-N-30"></use><use data-c="2E" xlink:href="#MJX-24-TEX-N-2E" transform="translate(500,0)"></use><use data-c="31" xlink:href="#MJX-24-TEX-N-31" transform="translate(778,0)"></use></g><g data-mml-node="mi" transform="translate(20795.8,0)"><use data-c="1D465" xlink:href="#MJX-24-TEX-I-1D465"></use></g><g data-mml-node="mo" transform="translate(21367.8,0)"><use data-c="28" xlink:href="#MJX-24-TEX-N-28"></use></g><g data-mml-node="mi" transform="translate(21756.8,0)"><use data-c="1D458" xlink:href="#MJX-24-TEX-I-1D458"></use></g><g data-mml-node="mo" transform="translate(22500,0)"><use data-c="2212" xlink:href="#MJX-24-TEX-N-2212"></use></g><g data-mml-node="mn" transform="translate(23500.2,0)"><use data-c="31" xlink:href="#MJX-24-TEX-N-31"></use></g><g data-mml-node="mo" transform="translate(24000.2,0)"><use data-c="29" xlink:href="#MJX-24-TEX-N-29"></use></g><g data-mml-node="mo" transform="translate(24611.4,0)"><use data-c="2B" xlink:href="#MJX-24-TEX-N-2B"></use></g><g data-mml-node="mi" transform="translate(25611.7,0)"><use data-c="1D463" xlink:href="#MJX-24-TEX-I-1D463"></use></g><g data-mml-node="mo" transform="translate(26096.7,0)"><use data-c="28" xlink:href="#MJX-24-TEX-N-28"></use></g><g data-mml-node="mi" transform="translate(26485.7,0)"><use data-c="1D458" xlink:href="#MJX-24-TEX-I-1D458"></use></g><g data-mml-node="mo" transform="translate(27006.7,0)"><use data-c="29" xlink:href="#MJX-24-TEX-N-29"></use></g></g></g></g><g data-mml-node="mo" transform="translate(28145.7,0) translate(0 250)"></g></g></g></g></svg><mjx-assistive-mml unselectable="on" display="block"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mrow data-mjx-texclass="INNER"><mo data-mjx-texclass="OPEN">{</mo><mtable columnalign="left left" columnspacing="1em" rowspacing=".2em"><mtr><mtd><mi>x</mi><mo stretchy="false">(</mo><mi>k</mi><mo stretchy="false">)</mo><mo>=</mo><mi>a</mi><mi>u</mi><mo stretchy="false">(</mo><mi>k</mi><mo stretchy="false">)</mo><mo>−</mo><mi>b</mi><mi>u</mi><mo stretchy="false">(</mo><mi>k</mi><msup><mo stretchy="false">)</mo><mn>2</mn></msup><mo>+</mo><mn>0.5</mn><mi>u</mi><mo stretchy="false">(</mo><mi>k</mi><msup><mo stretchy="false">)</mo><mn>3</mn></msup></mtd></mtr><mtr><mtd><mi>y</mi><mo stretchy="false">(</mo><mi>k</mi><mo>+</mo><mn>1</mn><mo stretchy="false">)</mo><mo>=</mo><mn>0.6</mn><mi>y</mi><mo stretchy="false">(</mo><mi>k</mi><mo stretchy="false">)</mo><mo>−</mo><mn>0.1</mn><mi>y</mi><mo stretchy="false">(</mo><mi>k</mi><mo>−</mo><mn>1</mn><mo stretchy="false">)</mo><mo>+</mo><mn>1.2</mn><mi>x</mi><mo stretchy="false">(</mo><mi>k</mi><mo stretchy="false">)</mo><mo>−</mo><mn>0.1</mn><mi>x</mi><mo stretchy="false">(</mo><mi>k</mi><mo>−</mo><mn>1</mn><mo stretchy="false">)</mo><mo>+</mo><mi>v</mi><mo stretchy="false">(</mo><mi>k</mi><mo stretchy="false">)</mo></mtd></mtr></mtable><mo data-mjx-texclass="CLOSE" fence="true" stretchy="true" symmetric="true"></mo></mrow></math></mjx-assistive-mml></mjx-container></div></div><p><span>其中 </span><mjx-container class="MathJax" jax="SVG" style="position: relative;"><svg xmlns="http://www.w3.org/2000/svg" width="4.036ex" height="2.262ex" role="img" focusable="false" viewBox="0 -750 1784 1000" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" style="vertical-align: -0.566ex;"><defs><path id="MJX-4-TEX-I-1D463" d="M173 380Q173 405 154 405Q130 405 104 376T61 287Q60 286 59 284T58 281T56 279T53 278T49 278T41 278H27Q21 284 21 287Q21 294 29 316T53 368T97 419T160 441Q202 441 225 417T249 361Q249 344 246 335Q246 329 231 291T200 202T182 113Q182 86 187 69Q200 26 250 26Q287 26 319 60T369 139T398 222T409 277Q409 300 401 317T383 343T365 361T357 383Q357 405 376 424T417 443Q436 443 451 425T467 367Q467 340 455 284T418 159T347 40T241 -11Q177 -11 139 22Q102 54 102 117Q102 148 110 181T151 298Q173 362 173 380Z"></path><path id="MJX-4-TEX-N-28" d="M94 250Q94 319 104 381T127 488T164 576T202 643T244 695T277 729T302 750H315H319Q333 750 333 741Q333 738 316 720T275 667T226 581T184 443T167 250T184 58T225 -81T274 -167T316 -220T333 -241Q333 -250 318 -250H315H302L274 -226Q180 -141 137 -14T94 250Z"></path><path id="MJX-4-TEX-I-1D458" d="M121 647Q121 657 125 670T137 683Q138 683 209 688T282 694Q294 694 294 686Q294 679 244 477Q194 279 194 272Q213 282 223 291Q247 309 292 354T362 415Q402 442 438 442Q468 442 485 423T503 369Q503 344 496 327T477 302T456 291T438 288Q418 288 406 299T394 328Q394 353 410 369T442 390L458 393Q446 405 434 405H430Q398 402 367 380T294 316T228 255Q230 254 243 252T267 246T293 238T320 224T342 206T359 180T365 147Q365 130 360 106T354 66Q354 26 381 26Q429 26 459 145Q461 153 479 153H483Q499 153 499 144Q499 139 496 130Q455 -11 378 -11Q333 -11 305 15T277 90Q277 108 280 121T283 145Q283 167 269 183T234 206T200 217T182 220H180Q168 178 159 139T145 81T136 44T129 20T122 7T111 -2Q98 -11 83 -11Q66 -11 57 -1T48 16Q48 26 85 176T158 471L195 616Q196 629 188 632T149 637H144Q134 637 131 637T124 640T121 647Z"></path><path id="MJX-4-TEX-N-29" d="M60 749L64 750Q69 750 74 750H86L114 726Q208 641 251 514T294 250Q294 182 284 119T261 12T224 -76T186 -143T145 -194T113 -227T90 -246Q87 -249 86 -250H74Q66 -250 63 -250T58 -247T55 -238Q56 -237 66 -225Q221 -64 221 250T66 725Q56 737 55 738Q55 746 60 749Z"></path></defs><g stroke="currentColor" fill="currentColor" stroke-width="0" transform="scale(1,-1)"><g data-mml-node="math"><g data-mml-node="mi"><use data-c="1D463" xlink:href="#MJX-4-TEX-I-1D463"></use></g><g data-mml-node="mo" transform="translate(485,0)"><use data-c="28" xlink:href="#MJX-4-TEX-N-28"></use></g><g data-mml-node="mi" transform="translate(874,0)"><use data-c="1D458" xlink:href="#MJX-4-TEX-I-1D458"></use></g><g data-mml-node="mo" transform="translate(1395,0)"><use data-c="29" xlink:href="#MJX-4-TEX-N-29"></use></g></g></g></svg><mjx-assistive-mml unselectable="on" display="inline"><math xmlns="http://www.w3.org/1998/Math/MathML"><mi>v</mi><mo stretchy="false">(</mo><mi>k</mi><mo stretchy="false">)</mo></math></mjx-assistive-mml></mjx-container><script type="math/tex">v(k) </script><span>表示均值为0、标准差为0.01的高斯白噪声输出。通过改变系统参数建立了三种不同的操作模式,并在u随机输入的情况下分别采集10000条数据。具体参数设置如下:Mode 1 的参数为 </span><span>(</span><span> a = 1.5, b = 1.5 </span><span>)</span><span>,Mode 2 的参数为 </span><span>(</span><span> a = 1, b = 1 </span><span>)</span><span>,Mode 3 的参数为 </span><span>(</span><span> a = 0.5, b = 0.5 </span><span>)</span><span>。系统输入范围为 </span><mjx-container class="MathJax" jax="SVG" style="position: relative;"><svg xmlns="http://www.w3.org/2000/svg" width="10.849ex" height="2.262ex" role="img" focusable="false" viewBox="0 -750 4795.2 1000" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" style="vertical-align: -0.566ex;"><defs><path id="MJX-21-TEX-I-1D462" d="M21 287Q21 295 30 318T55 370T99 420T158 442Q204 442 227 417T250 358Q250 340 216 246T182 105Q182 62 196 45T238 27T291 44T328 78L339 95Q341 99 377 247Q407 367 413 387T427 416Q444 431 463 431Q480 431 488 421T496 402L420 84Q419 79 419 68Q419 43 426 35T447 26Q469 29 482 57T512 145Q514 153 532 153Q551 153 551 144Q550 139 549 130T540 98T523 55T498 17T462 -8Q454 -10 438 -10Q372 -10 347 46Q345 45 336 36T318 21T296 6T267 -6T233 -11Q189 -11 155 7Q103 38 103 113Q103 170 138 262T173 379Q173 380 173 381Q173 390 173 393T169 400T158 404H154Q131 404 112 385T82 344T65 302T57 280Q55 278 41 278H27Q21 284 21 287Z"></path><path id="MJX-21-TEX-N-2208" d="M84 250Q84 372 166 450T360 539Q361 539 377 539T419 540T469 540H568Q583 532 583 520Q583 511 570 501L466 500Q355 499 329 494Q280 482 242 458T183 409T147 354T129 306T124 272V270H568Q583 262 583 250T568 230H124V228Q124 207 134 177T167 112T231 48T328 7Q355 1 466 0H570Q583 -10 583 -20Q583 -32 568 -40H471Q464 -40 446 -40T417 -41Q262 -41 172 45Q84 127 84 250Z"></path><path id="MJX-21-TEX-N-28" d="M94 250Q94 319 104 381T127 488T164 576T202 643T244 695T277 729T302 750H315H319Q333 750 333 741Q333 738 316 720T275 667T226 581T184 443T167 250T184 58T225 -81T274 -167T316 -220T333 -241Q333 -250 318 -250H315H302L274 -226Q180 -141 137 -14T94 250Z"></path><path id="MJX-21-TEX-N-2212" d="M84 237T84 250T98 270H679Q694 262 694 250T679 230H98Q84 237 84 250Z"></path><path id="MJX-21-TEX-N-31" d="M213 578L200 573Q186 568 160 563T102 556H83V602H102Q149 604 189 617T245 641T273 663Q275 666 285 666Q294 666 302 660V361L303 61Q310 54 315 52T339 48T401 46H427V0H416Q395 3 257 3Q121 3 100 0H88V46H114Q136 46 152 46T177 47T193 50T201 52T207 57T213 61V578Z"></path><path id="MJX-21-TEX-N-2C" d="M78 35T78 60T94 103T137 121Q165 121 187 96T210 8Q210 -27 201 -60T180 -117T154 -158T130 -185T117 -194Q113 -194 104 -185T95 -172Q95 -168 106 -156T131 -126T157 -76T173 -3V9L172 8Q170 7 167 6T161 3T152 1T140 0Q113 0 96 17Z"></path><path id="MJX-21-TEX-N-29" d="M60 749L64 750Q69 750 74 750H86L114 726Q208 641 251 514T294 250Q294 182 284 119T261 12T224 -76T186 -143T145 -194T113 -227T90 -246Q87 -249 86 -250H74Q66 -250 63 -250T58 -247T55 -238Q56 -237 66 -225Q221 -64 221 250T66 725Q56 737 55 738Q55 746 60 749Z"></path></defs><g stroke="currentColor" fill="currentColor" stroke-width="0" transform="scale(1,-1)"><g data-mml-node="math"><g data-mml-node="mi"><use data-c="1D462" xlink:href="#MJX-21-TEX-I-1D462"></use></g><g data-mml-node="mo" transform="translate(849.8,0)"><use data-c="2208" xlink:href="#MJX-21-TEX-N-2208"></use></g><g data-mml-node="mo" transform="translate(1794.6,0)"><use data-c="28" xlink:href="#MJX-21-TEX-N-28"></use></g><g data-mml-node="mo" transform="translate(2183.6,0)"><use data-c="2212" xlink:href="#MJX-21-TEX-N-2212"></use></g><g data-mml-node="mn" transform="translate(2961.6,0)"><use data-c="31" xlink:href="#MJX-21-TEX-N-31"></use></g><g data-mml-node="mo" transform="translate(3461.6,0)"><use data-c="2C" xlink:href="#MJX-21-TEX-N-2C"></use></g><g data-mml-node="mn" transform="translate(3906.2,0)"><use data-c="31" xlink:href="#MJX-21-TEX-N-31"></use></g><g data-mml-node="mo" transform="translate(4406.2,0)"><use data-c="29" xlink:href="#MJX-21-TEX-N-29"></use></g></g></g></svg><mjx-assistive-mml unselectable="on" display="inline"><math xmlns="http://www.w3.org/1998/Math/MathML"><mi>u</mi><mo>∈</mo><mo stretchy="false">(</mo><mo>−</mo><mn>1</mn><mo>,</mo><mn>1</mn><mo stretchy="false">)</mo></math></mjx-assistive-mml></mjx-container><script type="math/tex">u \in (-1, 1)</script><span>。</span></p><figure class='table-figure'><table><thead><tr><th><span>Operation state</span></th><th style='text-align:right;' ><span>Mode 1</span></th><th><span>Mode 2</span></th><th><span>Mode 3</span></th></tr></thead><tbody><tr><td><span>System Parameter</span></td><td style='text-align:right;' ><span>(</span><span> a = 1.5, b = 1.5 </span><span>)</span></td><td><span>(</span><span> a = 1, b = 1 </span><span>)</span></td><td><span>(</span><span> a = 0.5, b = 0.5 </span><span>)</span></td></tr></tbody></table></figure><h3 id='112--代码'><span>1.1.2 代码 </span></h3><pre class="md-fences md-end-block ty-contain-cm modeLoaded" spellcheck="false" lang="python" style="break-inside: unset;"><div class="CodeMirror cm-s-inner cm-s-null-scroll CodeMirror-wrap" lang="python"><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 8.5px; left: 4px;"><textarea autocorrect="off" autocapitalize="off" spellcheck="false" tabindex="0" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; outline: none;"></textarea></div><div class="CodeMirror-scrollbar-filler" cm-not-content="true"></div><div class="CodeMirror-gutter-filler" cm-not-content="true"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; margin-bottom: 0px; border-right-width: 0px; padding-right: 0px; padding-bottom: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines" role="presentation"><div role="presentation" style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code" role="presentation" style=""><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><div class="CodeMirror-gutter-background CodeMirror-activeline-gutter" style="left: 0px; width: 0px;"></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-comment"># StateSpace.py</span></span></pre></div><div class="" style="position: relative;"><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span cm-text="" cm-zwsp="">
</span></span></pre></div><div class="" style="position: relative;"><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-keyword">import</span> <span class="cm-variable">numpy</span> <span class="cm-keyword">as</span> <span class="cm-variable">np</span></span></pre></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-keyword">import</span> <span class="cm-variable">matplotlib</span>.<span class="cm-property">pyplot</span> <span class="cm-keyword">as</span> <span class="cm-variable">plt</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span cm-text="" cm-zwsp="">
</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-string">'''</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-string">K. Huang, K. Wei, F. Li, C. Yang and W. Gui, "LSTM-MPC: A Deep Learning Based Predictive Control Method for Multimode Process Control," </span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-string">in IEEE Transactions on Industrial Electronics, vol. 70, no. 11, pp. 11544-11554, Nov. 2023, doi: 10.1109/TIE.2022.3229323.</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span cm-text="" cm-zwsp="">
</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-string">在本研究中,选择Hammerstein系统来研究不同控制方法的性能。Hammerstein系统的数学模型如下(SystemPlant):</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span cm-text="" cm-zwsp="">
</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-string">$$</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-string">\begin{cases}</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-string">x(k) = au(k) - bu(k)^2 + 0.5u(k)^3 \\</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-string">y(k+1) = 0.6y(k) - 0.1y(k-1) + 1.2x(k) - 0.1x(k-1) + v(k)</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-string">\end{cases}</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-string">$$</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span cm-text="" cm-zwsp="">
</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-string">其中 $v(k)$ 表示均值为0、标准差为0.01的高斯白噪声输出。通过改变系统参数建立了三种不同的操作模式,并在 $u$ 随机输入的情况下分别采集10000条数据。</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-string">具体参数设置如下:Mode 1 的参数为 $a = 1.5, b = 1.5$,Mode 2 的参数为 $a = 1, b = 1$,Mode 3 的参数为 $a = 0.5, b = 0.5$。</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-string">系统输入范围为 $u \in (-1, 1)$。</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span cm-text="" cm-zwsp="">
</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-string">| Operation state | Mode 1 | Mode 2 | Mode 3 |</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-string">| ---------------- | ---------------------: | ------------------ | ---------------------- |</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-string">| System Parameter | $ a = 1.5, b = 1.5 $ | $ a = 1, b = 1 $ | $ a = 0.5, b = 0.5 $ |</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-string">'''</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span cm-text="" cm-zwsp="">
</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span cm-text="" cm-zwsp="">
</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-keyword">class</span> <span class="cm-def">SystemPlant</span>:</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-keyword">def</span> <span class="cm-def">__init__</span>(<span class="cm-variable-2">self</span>, <span class="cm-variable">initial_state</span><span class="cm-operator">=</span><span class="cm-keyword">None</span>, <span class="cm-variable">initial_input</span><span class="cm-operator">=</span><span class="cm-keyword">None</span>, <span class="cm-variable">noise_amplitude</span><span class="cm-operator">=</span><span class="cm-number">0.01</span>, <span class="cm-variable">mode</span><span class="cm-operator">=</span><span class="cm-string">'Mode 1'</span>):</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-comment"># 初始化状态和输入</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-variable-2">self</span>.<span class="cm-property">initial_state</span> <span class="cm-operator">=</span> <span class="cm-variable">initial_state</span> <span class="cm-keyword">if</span> <span class="cm-variable">initial_state</span> <span class="cm-keyword">is</span> <span class="cm-keyword">not</span> <span class="cm-keyword">None</span> <span class="cm-keyword">else</span> <span class="cm-variable">np</span>.<span class="cm-property">zeros</span>((<span class="cm-number">2</span>,))</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-variable-2">self</span>.<span class="cm-property">initial_input</span> <span class="cm-operator">=</span> <span class="cm-variable">initial_input</span> <span class="cm-keyword">if</span> <span class="cm-variable">initial_input</span> <span class="cm-keyword">is</span> <span class="cm-keyword">not</span> <span class="cm-keyword">None</span> <span class="cm-keyword">else</span> <span class="cm-variable">np</span>.<span class="cm-property">zeros</span>(<span class="cm-number">2</span>)</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-variable-2">self</span>.<span class="cm-property">noise_amplitude</span> <span class="cm-operator">=</span> <span class="cm-variable">noise_amplitude</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-variable-2">self</span>.<span class="cm-property">mode_params</span> <span class="cm-operator">=</span> {<span class="cm-string">'Mode 1'</span>: {<span class="cm-string">'a'</span>: <span class="cm-number">1.5</span>, <span class="cm-string">'b'</span>: <span class="cm-number">1.5</span>},</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-string">'Mode 2'</span>: {<span class="cm-string">'a'</span>: <span class="cm-number">1</span>, <span class="cm-string">'b'</span>: <span class="cm-number">1</span>},</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-string">'Mode 3'</span>: {<span class="cm-string">'a'</span>: <span class="cm-number">0.5</span>, <span class="cm-string">'b'</span>: <span class="cm-number">0.5</span>}}</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-variable-2">self</span>.<span class="cm-property">a</span> <span class="cm-operator">=</span> <span class="cm-variable-2">self</span>.<span class="cm-property">mode_params</span>[<span class="cm-variable">mode</span>][<span class="cm-string">'a'</span>]</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-variable-2">self</span>.<span class="cm-property">b</span> <span class="cm-operator">=</span> <span class="cm-variable-2">self</span>.<span class="cm-property">mode_params</span>[<span class="cm-variable">mode</span>][<span class="cm-string">'b'</span>]</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-variable-2">self</span>.<span class="cm-property">y</span> <span class="cm-operator">=</span> <span class="cm-keyword">None</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-variable-2">self</span>.<span class="cm-property">u</span> <span class="cm-operator">=</span> <span class="cm-keyword">None</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-variable-2">self</span>.<span class="cm-property">x</span> <span class="cm-operator">=</span> <span class="cm-keyword">None</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span cm-text="" cm-zwsp="">
</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-keyword">def</span> <span class="cm-def">plant</span>(<span class="cm-variable-2">self</span>, <span class="cm-variable">u</span>, <span class="cm-variable">y</span>, <span class="cm-variable">x_prev</span>):</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-string">'''</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-string"> :param u: 当前时刻的输入u(k)</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-string"> :param x_prev: 上一时刻的内部状态x(k-1)</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-string"> :return: 更新后的内部状态x(k) 和 输出y(k+1)</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-string"> '''</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-variable">a</span>, <span class="cm-variable">b</span> <span class="cm-operator">=</span> <span class="cm-variable-2">self</span>.<span class="cm-property">a</span>, <span class="cm-variable-2">self</span>.<span class="cm-property">b</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-variable">x</span> <span class="cm-operator">=</span> <span class="cm-variable">a</span> <span class="cm-operator">*</span> <span class="cm-variable">u</span> <span class="cm-operator">-</span> <span class="cm-variable">b</span> <span class="cm-operator">*</span> <span class="cm-variable">u</span> <span class="cm-operator">**</span> <span class="cm-number">2</span> <span class="cm-operator">+</span> <span class="cm-number">0.5</span> <span class="cm-operator">*</span> <span class="cm-variable">u</span> <span class="cm-operator">**</span> <span class="cm-number">3</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-variable">y_next</span> <span class="cm-operator">=</span> <span class="cm-number">0.6</span> <span class="cm-operator">*</span> <span class="cm-variable">y</span>[<span class="cm-operator">-</span><span class="cm-number">1</span>] <span class="cm-operator">-</span> <span class="cm-number">0.1</span> <span class="cm-operator">*</span> <span class="cm-variable">y</span>[<span class="cm-operator">-</span><span class="cm-number">2</span>] <span class="cm-operator">+</span> <span class="cm-number">1.2</span> <span class="cm-operator">*</span> <span class="cm-variable">x</span> <span class="cm-operator">-</span> <span class="cm-number">0.1</span> <span class="cm-operator">*</span> <span class="cm-variable">x_prev</span> <span class="cm-operator">+</span> <span class="cm-variable">np</span>.<span class="cm-property">random</span>.<span class="cm-property">normal</span>(<span class="cm-number">0</span>,<span class="cm-variable-2">self</span>.<span class="cm-property">noise_amplitude</span>)</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-keyword">return</span> <span class="cm-variable">x</span>, <span class="cm-variable">y_next</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span cm-text="" cm-zwsp="">
</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-keyword">def</span> <span class="cm-def">generate_data</span>(<span class="cm-variable-2">self</span>, <span class="cm-variable">n_samples</span>):</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-comment"># 初始化系统状态</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-variable-2">self</span>.<span class="cm-property">y</span> <span class="cm-operator">=</span> <span class="cm-variable">np</span>.<span class="cm-property">zeros</span>(<span class="cm-variable">n_samples</span>) <span class="cm-comment"># 系统输出</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-variable-2">self</span>.<span class="cm-property">u</span> <span class="cm-operator">=</span> <span class="cm-variable">np</span>.<span class="cm-property">zeros</span>(<span class="cm-variable">n_samples</span>) <span class="cm-comment"># 控制输入</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-variable-2">self</span>.<span class="cm-property">x</span> <span class="cm-operator">=</span> <span class="cm-variable">np</span>.<span class="cm-property">zeros</span>(<span class="cm-variable">n_samples</span>) <span class="cm-comment"># 内部状态</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span cm-text="" cm-zwsp="">
</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-comment"># 初始化前两个样本的状态和输入(假设初始状态为0)</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-keyword">for</span> <span class="cm-variable">i</span> <span class="cm-keyword">in</span> <span class="cm-builtin">range</span>(<span class="cm-number">2</span>):</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-variable-2">self</span>.<span class="cm-property">y</span>[<span class="cm-variable">i</span>] <span class="cm-operator">=</span> <span class="cm-variable-2">self</span>.<span class="cm-property">initial_state</span>[<span class="cm-variable">i</span>]</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-variable-2">self</span>.<span class="cm-property">u</span>[<span class="cm-variable">i</span>] <span class="cm-operator">=</span> <span class="cm-variable-2">self</span>.<span class="cm-property">initial_input</span>[<span class="cm-variable">i</span>]</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-variable-2">self</span>.<span class="cm-property">x</span>[<span class="cm-variable">i</span>] <span class="cm-operator">=</span> <span class="cm-variable-2">self</span>.<span class="cm-property">a</span> <span class="cm-operator">*</span> <span class="cm-variable-2">self</span>.<span class="cm-property">u</span>[<span class="cm-variable">i</span>] <span class="cm-operator">-</span> <span class="cm-variable-2">self</span>.<span class="cm-property">b</span> <span class="cm-operator">*</span> <span class="cm-variable-2">self</span>.<span class="cm-property">u</span>[<span class="cm-variable">i</span>] <span class="cm-operator">**</span> <span class="cm-number">2</span> <span class="cm-operator">+</span> <span class="cm-number">0.5</span> <span class="cm-operator">*</span> <span class="cm-variable-2">self</span>.<span class="cm-property">u</span>[<span class="cm-variable">i</span>] <span class="cm-operator">**</span> <span class="cm-number">3</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span cm-text="" cm-zwsp="">
</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-keyword">for</span> <span class="cm-variable">k</span> <span class="cm-keyword">in</span> <span class="cm-builtin">range</span>(<span class="cm-number">2</span>, <span class="cm-variable">n_samples</span>):</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-comment"># 随机生成控制输入</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-variable-2">self</span>.<span class="cm-property">u</span>[<span class="cm-variable">k</span>] <span class="cm-operator">=</span> <span class="cm-variable">np</span>.<span class="cm-property">random</span>.<span class="cm-property">uniform</span>(<span class="cm-operator">-</span><span class="cm-number">1</span>, <span class="cm-number">1</span>)</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-comment"># 计算系统内部状态和输出</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-variable-2">self</span>.<span class="cm-property">x</span>[<span class="cm-variable">k</span>], <span class="cm-variable-2">self</span>.<span class="cm-property">y</span>[<span class="cm-variable">k</span>] <span class="cm-operator">=</span> <span class="cm-variable-2">self</span>.<span class="cm-property">plant</span>(<span class="cm-variable-2">self</span>.<span class="cm-property">u</span>[<span class="cm-variable">k</span>], <span class="cm-variable-2">self</span>.<span class="cm-property">y</span>[<span class="cm-variable">k</span><span class="cm-operator">-</span><span class="cm-number">2</span>:<span class="cm-variable">k</span>],<span class="cm-variable-2">self</span>.<span class="cm-property">x</span>[<span class="cm-variable">k</span> <span class="cm-operator">-</span> <span class="cm-number">1</span>])</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-keyword">return</span> <span class="cm-variable-2">self</span>.<span class="cm-property">y</span>, <span class="cm-variable-2">self</span>.<span class="cm-property">u</span>, <span class="cm-variable-2">self</span>.<span class="cm-property">x</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span cm-text="" cm-zwsp="">
</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-keyword">def</span> <span class="cm-def">plot_results</span>(<span class="cm-variable-2">self</span>, <span class="cm-variable">mode_title</span><span class="cm-operator">=</span><span class="cm-string">"Simulation Mode"</span>):</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-keyword">if</span> <span class="cm-variable-2">self</span>.<span class="cm-property">y</span> <span class="cm-keyword">is</span> <span class="cm-keyword">None</span> <span class="cm-keyword">or</span> <span class="cm-variable-2">self</span>.<span class="cm-property">u</span> <span class="cm-keyword">is</span> <span class="cm-keyword">None</span> <span class="cm-keyword">or</span> <span class="cm-variable-2">self</span>.<span class="cm-property">x</span> <span class="cm-keyword">is</span> <span class="cm-keyword">None</span>:</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-keyword">raise</span> <span class="cm-variable">ValueError</span>(<span class="cm-string">"Simulation data has not been generated."</span>)</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span cm-text="" cm-zwsp="">
</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-comment"># 设置字体为 Times New Roman,并支持LaTeX渲染</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-variable">plt</span>.<span class="cm-property">rcParams</span>[<span class="cm-string">'font.family'</span>] <span class="cm-operator">=</span> <span class="cm-string">'serif'</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-variable">plt</span>.<span class="cm-property">rcParams</span>[<span class="cm-string">'font.serif'</span>] <span class="cm-operator">=</span> [<span class="cm-string">'Times New Roman'</span>]</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-comment"># plt.rcParams['text.usetex'] = True # 启用LaTeX渲染文本</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span cm-text="" cm-zwsp="">
</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-variable">plt</span>.<span class="cm-property">figure</span>(<span class="cm-variable">figsize</span><span class="cm-operator">=</span>(<span class="cm-number">12</span>, <span class="cm-number">10</span>))</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span cm-text="" cm-zwsp="">
</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-variable">labels</span> <span class="cm-operator">=</span> [<span class="cm-string">r'$u$'</span>, <span class="cm-string">r'$x$'</span>, <span class="cm-string">r'$y$'</span>] <span class="cm-comment"># LaTeX格式的标签</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-variable">titles</span> <span class="cm-operator">=</span> [<span class="cm-string">'Control Input'</span>, <span class="cm-string">'Internal State'</span>, <span class="cm-string">'System Output'</span>]</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-variable">datas</span> <span class="cm-operator">=</span> [<span class="cm-variable-2">self</span>.<span class="cm-property">u</span>, <span class="cm-variable-2">self</span>.<span class="cm-property">x</span>, <span class="cm-variable-2">self</span>.<span class="cm-property">y</span>]</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span cm-text="" cm-zwsp="">
</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-keyword">for</span> <span class="cm-variable">idx</span>, (<span class="cm-variable">data</span>, <span class="cm-variable">label</span>, <span class="cm-variable">title</span>) <span class="cm-keyword">in</span> <span class="cm-builtin">enumerate</span>(<span class="cm-builtin">zip</span>(<span class="cm-variable">datas</span>, <span class="cm-variable">labels</span>, <span class="cm-variable">titles</span>)):</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-variable">plt</span>.<span class="cm-property">subplot</span>(<span class="cm-number">3</span>, <span class="cm-number">1</span>, <span class="cm-variable">idx</span> <span class="cm-operator">+</span> <span class="cm-number">1</span>)</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-variable">plt</span>.<span class="cm-property">plot</span>(<span class="cm-variable">data</span>, <span class="cm-variable">label</span><span class="cm-operator">=</span><span class="cm-variable">label</span>)</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span cm-text="" cm-zwsp="">
</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-comment"># 设置y轴范围为数据最大最小值的1.5倍</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-variable">ymin</span> <span class="cm-operator">=</span> <span class="cm-builtin">min</span>(<span class="cm-variable">data</span>) <span class="cm-operator">*</span> <span class="cm-number">1.2</span> <span class="cm-keyword">if</span> <span class="cm-builtin">min</span>(<span class="cm-variable">data</span>) <span class="cm-operator"><</span> <span class="cm-number">0</span> <span class="cm-keyword">else</span> <span class="cm-builtin">min</span>(<span class="cm-variable">data</span>) <span class="cm-operator">/</span> <span class="cm-number">1.5</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-variable">ymax</span> <span class="cm-operator">=</span> <span class="cm-builtin">max</span>(<span class="cm-variable">data</span>) <span class="cm-operator">*</span> <span class="cm-number">1.5</span> <span class="cm-keyword">if</span> <span class="cm-builtin">max</span>(<span class="cm-variable">data</span>) <span class="cm-operator">></span> <span class="cm-number">0</span> <span class="cm-keyword">else</span> <span class="cm-builtin">max</span>(<span class="cm-variable">data</span>) <span class="cm-operator">/</span> <span class="cm-number">1.5</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-variable">plt</span>.<span class="cm-property">ylim</span>(<span class="cm-variable">ymin</span>, <span class="cm-variable">ymax</span>)</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span cm-text="" cm-zwsp="">
</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-variable">plt</span>.<span class="cm-property">title</span>(<span class="cm-variable">title</span>)</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-variable">plt</span>.<span class="cm-property">ylabel</span>(<span class="cm-string">f'Value of </span>{<span class="cm-variable">label</span>}<span class="cm-string">'</span>) <span class="cm-comment"># 使用LaTeX格式的y轴标签</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-variable">plt</span>.<span class="cm-property">legend</span>(<span class="cm-variable">loc</span><span class="cm-operator">=</span><span class="cm-string">'upper right'</span>) <span class="cm-comment"># 图例位于右上角</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span cm-text="" cm-zwsp="">
</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-variable">plt</span>.<span class="cm-property">suptitle</span>(<span class="cm-variable">mode_title</span>, <span class="cm-variable">fontsize</span><span class="cm-operator">=</span><span class="cm-number">16</span>) <span class="cm-comment"># 添加一个总标题,描述模式</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-variable">plt</span>.<span class="cm-property">tight_layout</span>(<span class="cm-variable">rect</span><span class="cm-operator">=</span>[<span class="cm-number">0</span>, <span class="cm-number">0.03</span>, <span class="cm-number">1</span>, <span class="cm-number">0.95</span>]) <span class="cm-comment"># 调整布局以适应总标题</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-variable">plt</span>.<span class="cm-property">show</span>()</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span cm-text="" cm-zwsp="">
</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-keyword">def</span> <span class="cm-def">plot_scatter</span>(<span class="cm-variable-2">self</span>, <span class="cm-variable">all_data_frames</span>, <span class="cm-variable">save_path</span><span class="cm-operator">=</span><span class="cm-keyword">None</span>):</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-comment"># 设置字体为 Times New Roman</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-variable">plt</span>.<span class="cm-property">rcParams</span>[<span class="cm-string">'font.family'</span>] <span class="cm-operator">=</span> <span class="cm-string">'serif'</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-variable">plt</span>.<span class="cm-property">rcParams</span>[<span class="cm-string">'font.serif'</span>] <span class="cm-operator">=</span> [<span class="cm-string">'Times New Roman'</span>]</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span cm-text="" cm-zwsp="">
</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-variable">plt</span>.<span class="cm-property">figure</span>(<span class="cm-variable">figsize</span><span class="cm-operator">=</span>(<span class="cm-number">8</span>, <span class="cm-number">6</span>))</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span cm-text="" cm-zwsp="">
</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-variable">colors</span> <span class="cm-operator">=</span> [<span class="cm-string">'blue'</span>, <span class="cm-string">'green'</span>, <span class="cm-string">'red'</span>]</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-variable">labels</span> <span class="cm-operator">=</span> [<span class="cm-string">'Mode 1'</span>, <span class="cm-string">'Mode 2'</span>, <span class="cm-string">'Mode 3'</span>]</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span cm-text="" cm-zwsp="">
</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-keyword">for</span> <span class="cm-variable">idx</span>, (<span class="cm-variable">mode</span>, <span class="cm-variable">df</span>) <span class="cm-keyword">in</span> <span class="cm-builtin">enumerate</span>(<span class="cm-variable">all_data_frames</span>.<span class="cm-property">items</span>()):</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-variable">plt</span>.<span class="cm-property">scatter</span>(<span class="cm-variable">df</span>[<span class="cm-string">'u'</span>], <span class="cm-variable">df</span>[<span class="cm-string">'y'</span>], <span class="cm-variable">s</span><span class="cm-operator">=</span><span class="cm-number">2</span>, <span class="cm-variable">alpha</span><span class="cm-operator">=</span><span class="cm-number">0.5</span>, <span class="cm-variable">c</span><span class="cm-operator">=</span><span class="cm-variable">colors</span>[<span class="cm-variable">idx</span>], <span class="cm-variable">label</span><span class="cm-operator">=</span><span class="cm-variable">labels</span>[<span class="cm-variable">idx</span>])</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span cm-text="" cm-zwsp="">
</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-variable">plt</span>.<span class="cm-property">title</span>(<span class="cm-string">'Scatter Plot of Control Input (u) vs System Output (y)'</span>)</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-variable">plt</span>.<span class="cm-property">xlabel</span>(<span class="cm-string">'Control Input (u)'</span>)</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-variable">plt</span>.<span class="cm-property">ylabel</span>(<span class="cm-string">'System Output (y)'</span>)</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-variable">plt</span>.<span class="cm-property">legend</span>(<span class="cm-variable">loc</span><span class="cm-operator">=</span><span class="cm-string">'upper right'</span>)</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-variable">plt</span>.<span class="cm-property">tight_layout</span>()</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span cm-text="" cm-zwsp="">
</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-keyword">if</span> <span class="cm-variable">save_path</span>:</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-variable">plt</span>.<span class="cm-property">savefig</span>(<span class="cm-variable">save_path</span>, <span class="cm-builtin">format</span><span class="cm-operator">=</span><span class="cm-string">'png'</span>, <span class="cm-variable">dpi</span><span class="cm-operator">=</span><span class="cm-number">300</span>)</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-builtin">print</span>(<span class="cm-string">f"Scatter plot saved to </span>{<span class="cm-variable">save_path</span>}<span class="cm-string">"</span>)</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span cm-text="" cm-zwsp="">
</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-variable">plt</span>.<span class="cm-property">show</span>()</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span cm-text="" cm-zwsp="">
</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span cm-text="" cm-zwsp="">
</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-keyword">def</span> <span class="cm-def">plot_time_series_by_mode</span>(<span class="cm-variable">all_data</span>, <span class="cm-variable">modes</span>, <span class="cm-variable">variables</span><span class="cm-operator">=</span>[<span class="cm-string">'u'</span>, <span class="cm-string">'x'</span>, <span class="cm-string">'y'</span>], <span class="cm-variable">n_samples_per_mode</span><span class="cm-operator">=</span><span class="cm-number">10000</span>):</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-string">"""</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-string"> 按照时间顺序分段展示不同模式下的时间序列图。</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span cm-text="" cm-zwsp="">
</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-string"> 参数:</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-string"> all_data (dict): 包含所有模式数据的字典,键为模式名,值为对应模式的数据字典。</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-string"> modes (list): 包含模式名称的列表。</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-string"> variables (list): 需要绘制的时间序列变量,默认为 ['u', 'x', 'y']。</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-string"> n_samples_per_mode (int): 每个模式的数据样本数量,默认为 10000。</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-string"> """</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-comment"># 定义每种模式的时间区间</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-variable">time_intervals</span> <span class="cm-operator">=</span> {<span class="cm-variable">mode</span>: (<span class="cm-variable">i</span> <span class="cm-operator">*</span> <span class="cm-variable">n_samples_per_mode</span>, (<span class="cm-variable">i</span> <span class="cm-operator">+</span> <span class="cm-number">1</span>) <span class="cm-operator">*</span> <span class="cm-variable">n_samples_per_mode</span>) <span class="cm-keyword">for</span> <span class="cm-variable">i</span>, <span class="cm-variable">mode</span> <span class="cm-keyword">in</span> <span class="cm-builtin">enumerate</span>(<span class="cm-variable">modes</span>)}</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span cm-text="" cm-zwsp="">
</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-keyword">for</span> <span class="cm-variable">variable</span> <span class="cm-keyword">in</span> <span class="cm-variable">variables</span>:</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-variable">plt</span>.<span class="cm-property">figure</span>(<span class="cm-variable">figsize</span><span class="cm-operator">=</span>(<span class="cm-number">15</span>, <span class="cm-number">6</span>)) <span class="cm-comment"># 调整图表大小以适应更多内容</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span cm-text="" cm-zwsp="">
</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-keyword">for</span> <span class="cm-variable">mode</span> <span class="cm-keyword">in</span> <span class="cm-variable">modes</span>:</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-variable">start</span>, <span class="cm-variable">end</span> <span class="cm-operator">=</span> <span class="cm-variable">time_intervals</span>[<span class="cm-variable">mode</span>]</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-variable">time_range</span> <span class="cm-operator">=</span> <span class="cm-variable">np</span>.<span class="cm-property">arange</span>(<span class="cm-variable">start</span>, <span class="cm-variable">end</span>) <span class="cm-comment"># 创建对应的时间范围</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span cm-text="" cm-zwsp="">
</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-comment"># 绘制当前模式的数据</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-variable">plt</span>.<span class="cm-property">plot</span>(<span class="cm-variable">time_range</span>, <span class="cm-variable">all_data</span>[<span class="cm-variable">mode</span>][<span class="cm-variable">variable</span>], <span class="cm-variable">label</span><span class="cm-operator">=</span><span class="cm-variable">mode</span>, <span class="cm-variable">linewidth</span><span class="cm-operator">=</span><span class="cm-number">1</span>)</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span cm-text="" cm-zwsp="">
</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-comment"># 可选:在模式之间添加垂直线来明确区分不同的模式</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-keyword">if</span> <span class="cm-variable">mode</span> <span class="cm-operator">!=</span> <span class="cm-variable">modes</span>[<span class="cm-operator">-</span><span class="cm-number">1</span>]: <span class="cm-comment"># 不在最后一个模式后画线</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-variable">plt</span>.<span class="cm-property">axvline</span>(<span class="cm-variable">x</span><span class="cm-operator">=</span><span class="cm-variable">end</span>, <span class="cm-variable">color</span><span class="cm-operator">=</span><span class="cm-string">'black'</span>, <span class="cm-variable">linestyle</span><span class="cm-operator">=</span><span class="cm-string">'--'</span>, <span class="cm-variable">linewidth</span><span class="cm-operator">=</span><span class="cm-number">0.8</span>)</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span cm-text="" cm-zwsp="">
</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-variable">plt</span>.<span class="cm-property">title</span>(<span class="cm-string">f'Time Series of </span>{<span class="cm-variable">variable</span>}<span class="cm-string">'</span>)</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-variable">plt</span>.<span class="cm-property">xlabel</span>(<span class="cm-string">'Time Step'</span>)</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-variable">plt</span>.<span class="cm-property">ylabel</span>(<span class="cm-string">f'Value of </span>{<span class="cm-variable">variable</span>}<span class="cm-string">'</span>)</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-variable">plt</span>.<span class="cm-property">legend</span>()</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-variable">plt</span>.<span class="cm-property">grid</span>(<span class="cm-keyword">True</span>) <span class="cm-comment"># 添加网格线使图表更易读</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-variable">plt</span>.<span class="cm-property">tight_layout</span>() <span class="cm-comment"># 自动调整子图参数,使之填充整个图像区域</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-variable">plt</span>.<span class="cm-property">show</span>()</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span cm-text="" cm-zwsp="">
</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span cm-text="" cm-zwsp="">
</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-keyword">def</span> <span class="cm-def">plot_scatter_matrix_or_parallel_coords</span>(<span class="cm-variable">all_data</span>, <span class="cm-variable">modes</span>, <span class="cm-variable">plot_type</span><span class="cm-operator">=</span><span class="cm-string">'scatter_matrix'</span>, <span class="cm-variable">save_path</span><span class="cm-operator">=</span><span class="cm-keyword">None</span>):</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-string">"""</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-string"> 创建散点图矩阵或平行坐标图以展示不同模式下的数据关系,遵循SCI学术论文规范。</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span cm-text="" cm-zwsp="">
</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-string"> 参数:</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-string"> all_data (dict): 包含所有模式数据的字典。</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-string"> modes (list): 模式名称列表。</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-string"> plot_type (str): 可选值 'scatter_matrix' 或 'parallel_coords',默认为 'scatter_matrix'。</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-string"> save_path (str, optional): 如果提供,则将图表保存到指定路径,默认不保存。</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-string"> """</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-comment"># 设置全局绘图参数</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-variable">plt</span>.<span class="cm-property">rcParams</span>.<span class="cm-property">update</span>({</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-string">'font.size'</span>: <span class="cm-number">14</span>,</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-string">'font.family'</span>: <span class="cm-string">'Arial'</span>, <span class="cm-comment"># 使用衬线字体,适合与 LaTeX 配合使用</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-string">'axes.titlesize'</span>: <span class="cm-number">14</span>,</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-string">'axes.labelsize'</span>: <span class="cm-number">14</span>,</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-string">'xtick.labelsize'</span>: <span class="cm-number">14</span>,</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-string">'ytick.labelsize'</span>: <span class="cm-number">14</span>,</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-string">'legend.fontsize'</span>: <span class="cm-number">14</span>,</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-string">'figure.dpi'</span>: <span class="cm-number">300</span>, <span class="cm-comment"># 高分辨率输出</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-string">'text.usetex'</span>: <span class="cm-keyword">False</span>, <span class="cm-comment"># 启用 LaTeX 渲染文本</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-string">'axes.spines.right'</span>: <span class="cm-keyword">True</span>, <span class="cm-comment"># 显示右侧边框</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-string">'axes.spines.top'</span>: <span class="cm-keyword">True</span>, <span class="cm-comment"># 显示顶部边框</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-string">'xtick.direction'</span>: <span class="cm-string">'in'</span>, <span class="cm-comment"># 刻度线向内</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-string">'ytick.direction'</span>: <span class="cm-string">'in'</span>, <span class="cm-comment"># 刻度线向内</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-string">'legend.loc'</span>: <span class="cm-string">'lower center'</span>, <span class="cm-comment"># 图例位置</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-string">'axes.edgecolor'</span>: <span class="cm-string">'black'</span>, <span class="cm-comment"># 子图边框颜色</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-comment"># 'axes.linewidth': 0.7, # 子图边框宽度</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> })</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span cm-text="" cm-zwsp="">
</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-variable">all_df</span> <span class="cm-operator">=</span> <span class="cm-variable">pd</span>.<span class="cm-property">concat</span>([<span class="cm-variable">pd</span>.<span class="cm-property">DataFrame</span>(<span class="cm-variable">all_data</span>[<span class="cm-variable">mode</span>]).<span class="cm-property">assign</span>(<span class="cm-variable">Mode</span><span class="cm-operator">=</span><span class="cm-variable">mode</span>) <span class="cm-keyword">for</span> <span class="cm-variable">mode</span> <span class="cm-keyword">in</span> <span class="cm-variable">modes</span>])</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span cm-text="" cm-zwsp="">
</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-keyword">if</span> <span class="cm-variable">plot_type</span> <span class="cm-operator">==</span> <span class="cm-string">'scatter_matrix'</span>:</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-variable">g</span> <span class="cm-operator">=</span> <span class="cm-variable">sns</span>.<span class="cm-property">PairGrid</span>(<span class="cm-variable">all_df</span>, <span class="cm-variable">hue</span><span class="cm-operator">=</span><span class="cm-string">'Mode'</span>)</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-variable">g</span> <span class="cm-operator">=</span> <span class="cm-variable">g</span>.<span class="cm-property">map_diag</span>(<span class="cm-variable">sns</span>.<span class="cm-property">kdeplot</span>, <span class="cm-variable">fill</span><span class="cm-operator">=</span><span class="cm-keyword">True</span>)</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-variable">g</span> <span class="cm-operator">=</span> <span class="cm-variable">g</span>.<span class="cm-property">map_offdiag</span>(<span class="cm-variable">plt</span>.<span class="cm-property">scatter</span>, <span class="cm-variable">alpha</span><span class="cm-operator">=</span><span class="cm-number">1</span>, <span class="cm-variable">s</span><span class="cm-operator">=</span><span class="cm-number">30</span>, <span class="cm-variable">edgecolor</span><span class="cm-operator">=</span><span class="cm-string">'w'</span>)</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-variable">g</span>.<span class="cm-property">fig</span>.<span class="cm-property">set_size_inches</span>(<span class="cm-number">8</span>, <span class="cm-number">9</span>) <span class="cm-comment"># 修改这里的尺寸</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span cm-text="" cm-zwsp="">
</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-comment"># # 手动设置右边框和顶部边框</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-comment"># for ax in g.axes.flatten():</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-comment"># ax.spines['right'].set_visible(True)</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-comment"># ax.spines['top'].set_visible(True)</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span cm-text="" cm-zwsp="">
</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-comment"># 添加主标题</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-variable">g</span>.<span class="cm-property">fig</span>.<span class="cm-property">suptitle</span>(<span class="cm-string">r'Scatter Plot Matrix of Different Modes'</span>, <span class="cm-variable">y</span><span class="cm-operator">=</span><span class="cm-number">1</span>)</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span cm-text="" cm-zwsp="">
</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-comment"># 添加总的图例外部单行显示</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-variable">g</span>.<span class="cm-property">add_legend</span>(<span class="cm-variable">loc</span><span class="cm-operator">=</span><span class="cm-string">'upper center'</span>, <span class="cm-variable">ncol</span><span class="cm-operator">=</span><span class="cm-builtin">len</span>(<span class="cm-variable">modes</span>)) <span class="cm-comment"># bbox_to_anchor=(0.5, -0.05),</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-comment"># 调整布局,给图例留出空间</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-variable">g</span>.<span class="cm-property">fig</span>.<span class="cm-property">tight_layout</span>(<span class="cm-variable">rect</span><span class="cm-operator">=</span>[<span class="cm-number">0</span>, <span class="cm-number">0.03</span>, <span class="cm-number">1</span>, <span class="cm-number">0.95</span>])</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-keyword">if</span> <span class="cm-variable">save_path</span>:</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-variable">g</span>.<span class="cm-property">fig</span>.<span class="cm-property">savefig</span>(<span class="cm-variable">save_path</span> <span class="cm-operator">+</span> <span class="cm-string">'_scatter_matrix.png'</span>, <span class="cm-builtin">format</span><span class="cm-operator">=</span><span class="cm-string">'png'</span>, <span class="cm-variable">bbox_inches</span><span class="cm-operator">=</span><span class="cm-string">'tight'</span>)</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-keyword">else</span>:</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-variable">plt</span>.<span class="cm-property">show</span>()</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span cm-text="" cm-zwsp="">
</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-comment"># # 散点图矩阵</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-comment"># scatter_matrix = sns.pairplot(</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-comment"># all_df.sample(1000), hue='Mode', diag_kind='kde',</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-comment"># plot_kws={'alpha': 0.8, 's': 30, 'edgecolor': 'w'},</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-comment"># diag_kws={'fill': True}</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-comment"># )</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-comment"># scatter_matrix.fig.suptitle(r'Scatter Plot Matrix of Different Modes', y=1.02)</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-comment"># scatter_matrix.fig.tight_layout(rect=[0, 0.03, 1, 0.95])</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-comment"># plt.show()</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span cm-text="" cm-zwsp="">
</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span cm-text="" cm-zwsp="">
</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-keyword">elif</span> <span class="cm-variable">plot_type</span> <span class="cm-operator">==</span> <span class="cm-string">'parallel_coords'</span>:</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-comment"># 平行坐标图</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-variable">fig</span>, <span class="cm-variable">ax</span> <span class="cm-operator">=</span> <span class="cm-variable">plt</span>.<span class="cm-property">subplots</span>(<span class="cm-variable">figsize</span><span class="cm-operator">=</span>(<span class="cm-number">10</span>, <span class="cm-number">6</span>))</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-variable">parallel_coordinates</span>(<span class="cm-variable">all_df</span>.<span class="cm-property">sample</span>(<span class="cm-number">1000</span>), <span class="cm-string">'Mode'</span>, <span class="cm-variable">color</span><span class="cm-operator">=</span><span class="cm-variable">sns</span>.<span class="cm-property">color_palette</span>(<span class="cm-string">"husl"</span>, <span class="cm-builtin">len</span>(<span class="cm-variable">modes</span>)), <span class="cm-variable">ax</span><span class="cm-operator">=</span><span class="cm-variable">ax</span>)</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-variable">ax</span>.<span class="cm-property">set_title</span>(<span class="cm-string">r'Parallel Coordinates Plot of Different Modes'</span>, <span class="cm-variable">pad</span><span class="cm-operator">=</span><span class="cm-number">20</span>)</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-variable">ax</span>.<span class="cm-property">set_xlabel</span>(<span class="cm-string">r'\textbf{Variables}'</span>)</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-variable">ax</span>.<span class="cm-property">set_ylabel</span>(<span class="cm-string">r'\textbf{Scaled Values}'</span>)</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-variable">ax</span>.<span class="cm-property">legend</span>(<span class="cm-variable">bbox_to_anchor</span><span class="cm-operator">=</span>(<span class="cm-number">0.5</span>, <span class="cm-operator">-</span><span class="cm-number">0.2</span>), <span class="cm-variable">loc</span><span class="cm-operator">=</span><span class="cm-string">'upper center'</span>, <span class="cm-variable">ncol</span><span class="cm-operator">=</span><span class="cm-builtin">len</span>(<span class="cm-variable">modes</span>))</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-variable">ax</span>.<span class="cm-property">grid</span>(<span class="cm-keyword">True</span>)</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-variable">plt</span>.<span class="cm-property">tight_layout</span>()</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span cm-text="" cm-zwsp="">
</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-keyword">if</span> <span class="cm-variable">save_path</span>:</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-variable">plt</span>.<span class="cm-property">savefig</span>(<span class="cm-variable">save_path</span> <span class="cm-operator">+</span> <span class="cm-string">'_parallel_coords.png'</span>, <span class="cm-builtin">format</span><span class="cm-operator">=</span><span class="cm-string">'png'</span>, <span class="cm-variable">bbox_inches</span><span class="cm-operator">=</span><span class="cm-string">'tight'</span>)</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-keyword">else</span>:</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-variable">plt</span>.<span class="cm-property">show</span>()</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span cm-text="" cm-zwsp="">
</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span cm-text="" cm-zwsp="">
</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-keyword">def</span> <span class="cm-def">plot_distribution_plots</span>(<span class="cm-variable">all_data</span>, <span class="cm-variable">modes</span>, <span class="cm-variable">variables</span><span class="cm-operator">=</span>[<span class="cm-string">'u'</span>, <span class="cm-string">'x'</span>, <span class="cm-string">'y'</span>], <span class="cm-variable">plot_type</span><span class="cm-operator">=</span><span class="cm-string">'violin'</span>):</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-string">"""</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-string"> 针对每个变量绘制箱形图或小提琴图以显示不同模式下的分布情况。</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span cm-text="" cm-zwsp="">
</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-string"> 参数:</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-string"> all_data (dict): 包含所有模式数据的字典。</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-string"> modes (list): 模式名称列表。</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-string"> variables (list): 需要绘制的时间序列变量,默认为 ['u', 'x', 'y']。</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-string"> plot_type (str): 可选值 'box' 或 'violin',默认为 'violin'。</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-string"> """</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-variable">all_df</span> <span class="cm-operator">=</span> <span class="cm-variable">pd</span>.<span class="cm-property">concat</span>([<span class="cm-variable">pd</span>.<span class="cm-property">DataFrame</span>(<span class="cm-variable">all_data</span>[<span class="cm-variable">mode</span>]).<span class="cm-property">assign</span>(<span class="cm-variable">Mode</span><span class="cm-operator">=</span><span class="cm-variable">mode</span>) <span class="cm-keyword">for</span> <span class="cm-variable">mode</span> <span class="cm-keyword">in</span> <span class="cm-variable">modes</span>])</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span cm-text="" cm-zwsp="">
</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-keyword">for</span> <span class="cm-variable">variable</span> <span class="cm-keyword">in</span> <span class="cm-variable">variables</span>:</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-variable">plt</span>.<span class="cm-property">figure</span>(<span class="cm-variable">figsize</span><span class="cm-operator">=</span>(<span class="cm-number">8</span>, <span class="cm-number">6</span>))</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-keyword">if</span> <span class="cm-variable">plot_type</span> <span class="cm-operator">==</span> <span class="cm-string">'violin'</span>:</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-variable">sns</span>.<span class="cm-property">violinplot</span>(<span class="cm-variable">x</span><span class="cm-operator">=</span><span class="cm-string">'Mode'</span>, <span class="cm-variable">y</span><span class="cm-operator">=</span><span class="cm-variable">variable</span>, <span class="cm-variable">data</span><span class="cm-operator">=</span><span class="cm-variable">all_df</span>)</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-variable">plt</span>.<span class="cm-property">title</span>(<span class="cm-string">f'Violin Plot of </span>{<span class="cm-variable">variable</span>}<span class="cm-string"> Across Modes'</span>)</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-keyword">elif</span> <span class="cm-variable">plot_type</span> <span class="cm-operator">==</span> <span class="cm-string">'box'</span>:</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-variable">sns</span>.<span class="cm-property">boxplot</span>(<span class="cm-variable">x</span><span class="cm-operator">=</span><span class="cm-string">'Mode'</span>, <span class="cm-variable">y</span><span class="cm-operator">=</span><span class="cm-variable">variable</span>, <span class="cm-variable">data</span><span class="cm-operator">=</span><span class="cm-variable">all_df</span>)</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-variable">plt</span>.<span class="cm-property">title</span>(<span class="cm-string">f'Box Plot of </span>{<span class="cm-variable">variable</span>}<span class="cm-string"> Across Modes'</span>)</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-variable">plt</span>.<span class="cm-property">tight_layout</span>()</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-variable">plt</span>.<span class="cm-property">show</span>()</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span cm-text="" cm-zwsp="">
</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-keyword">def</span> <span class="cm-def">plot_tsne_or_umap</span>(<span class="cm-variable">all_data</span>, <span class="cm-variable">modes</span>, <span class="cm-variable">variables</span><span class="cm-operator">=</span>[<span class="cm-string">'u'</span>, <span class="cm-string">'x'</span>, <span class="cm-string">'y'</span>], <span class="cm-variable">method</span><span class="cm-operator">=</span><span class="cm-string">'tsne'</span>):</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-string">"""</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-string"> 使用 t-SNE 或 UMAP 进行降维,并绘制降维后的散点图。</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span cm-text="" cm-zwsp="">
</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-string"> 参数:</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-string"> all_data (dict): 包含所有模式数据的字典。</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-string"> modes (list): 模式名称列表。</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-string"> variables (list): 需要降维的时间序列变量,默认为 ['u', 'x', 'y']。</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-string"> method (str): 可选值 'tsne' 或 'umap',默认为 'tsne'。</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-string"> """</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-variable">all_df</span> <span class="cm-operator">=</span> <span class="cm-variable">pd</span>.<span class="cm-property">concat</span>([<span class="cm-variable">pd</span>.<span class="cm-property">DataFrame</span>(<span class="cm-variable">all_data</span>[<span class="cm-variable">mode</span>]).<span class="cm-property">assign</span>(<span class="cm-variable">Mode</span><span class="cm-operator">=</span><span class="cm-variable">mode</span>) <span class="cm-keyword">for</span> <span class="cm-variable">mode</span> <span class="cm-keyword">in</span> <span class="cm-variable">modes</span>])</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-variable">data_for_reduction</span> <span class="cm-operator">=</span> <span class="cm-variable">all_df</span>[<span class="cm-variable">variables</span>].<span class="cm-property">values</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-variable">mode_labels</span> <span class="cm-operator">=</span> <span class="cm-variable">all_df</span>[<span class="cm-string">'Mode'</span>].<span class="cm-property">values</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span cm-text="" cm-zwsp="">
</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-keyword">if</span> <span class="cm-variable">method</span> <span class="cm-operator">==</span> <span class="cm-string">'tsne'</span>:</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-variable">reducer</span> <span class="cm-operator">=</span> <span class="cm-variable">TSNE</span>(<span class="cm-variable">n_components</span><span class="cm-operator">=</span><span class="cm-number">2</span>, <span class="cm-variable">random_state</span><span class="cm-operator">=</span><span class="cm-number">42</span>)</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-keyword">elif</span> <span class="cm-variable">method</span> <span class="cm-operator">==</span> <span class="cm-string">'umap'</span>:</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-variable">reducer</span> <span class="cm-operator">=</span> <span class="cm-variable">UMAP</span>(<span class="cm-variable">n_components</span><span class="cm-operator">=</span><span class="cm-number">2</span>, <span class="cm-variable">random_state</span><span class="cm-operator">=</span><span class="cm-number">42</span>)</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span cm-text="" cm-zwsp="">
</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-variable">embedded_data</span> <span class="cm-operator">=</span> <span class="cm-variable">reducer</span>.<span class="cm-property">fit_transform</span>(<span class="cm-variable">data_for_reduction</span>)</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span cm-text="" cm-zwsp="">
</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-variable">plt</span>.<span class="cm-property">figure</span>(<span class="cm-variable">figsize</span><span class="cm-operator">=</span>(<span class="cm-number">8</span>, <span class="cm-number">6</span>))</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-keyword">for</span> <span class="cm-variable">mode</span> <span class="cm-keyword">in</span> <span class="cm-variable">np</span>.<span class="cm-property">unique</span>(<span class="cm-variable">mode_labels</span>):</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-variable">mask</span> <span class="cm-operator">=</span> <span class="cm-variable">mode_labels</span> <span class="cm-operator">==</span> <span class="cm-variable">mode</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-variable">plt</span>.<span class="cm-property">scatter</span>(<span class="cm-variable">embedded_data</span>[<span class="cm-variable">mask</span>, <span class="cm-number">0</span>], <span class="cm-variable">embedded_data</span>[<span class="cm-variable">mask</span>, <span class="cm-number">1</span>], <span class="cm-variable">alpha</span><span class="cm-operator">=</span><span class="cm-number">1</span>, <span class="cm-variable">edgecolor</span><span class="cm-operator">=</span><span class="cm-string">'w'</span>, <span class="cm-variable">label</span><span class="cm-operator">=</span><span class="cm-variable">mode</span>)</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-variable">plt</span>.<span class="cm-property">title</span>(<span class="cm-string">f'</span>{<span class="cm-variable">method</span>.<span class="cm-property">upper</span>()}<span class="cm-string"> Visualization of Different Modes'</span>)</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-variable">plt</span>.<span class="cm-property">legend</span>()</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-variable">plt</span>.<span class="cm-property">tight_layout</span>()</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-variable">plt</span>.<span class="cm-property">show</span>()</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span cm-text="" cm-zwsp="">
</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-keyword">def</span> <span class="cm-def">plot_combined_scatter_and_parallel_coords</span>(<span class="cm-variable">all_data</span>, <span class="cm-variable">modes</span>):</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-string">"""</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-string"> 创建一个包含散点图矩阵和平行坐标图的组合图表。</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span cm-text="" cm-zwsp="">
</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-string"> 参数:</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-string"> all_data (dict): 包含所有模式数据的字典。</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-string"> modes (list): 模式名称列表。</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-string"> """</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-variable">all_df</span> <span class="cm-operator">=</span> <span class="cm-variable">pd</span>.<span class="cm-property">concat</span>([<span class="cm-variable">pd</span>.<span class="cm-property">DataFrame</span>(<span class="cm-variable">all_data</span>[<span class="cm-variable">mode</span>]).<span class="cm-property">assign</span>(<span class="cm-variable">Mode</span><span class="cm-operator">=</span><span class="cm-variable">mode</span>) <span class="cm-keyword">for</span> <span class="cm-variable">mode</span> <span class="cm-keyword">in</span> <span class="cm-variable">modes</span>])</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span cm-text="" cm-zwsp="">
</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-comment"># 使用 GridSpec 创建自定义布局</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-variable">fig</span> <span class="cm-operator">=</span> <span class="cm-variable">plt</span>.<span class="cm-property">figure</span>(<span class="cm-variable">figsize</span><span class="cm-operator">=</span>(<span class="cm-number">18</span>, <span class="cm-number">6</span>))</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-variable">gs</span> <span class="cm-operator">=</span> <span class="cm-variable">GridSpec</span>(<span class="cm-number">1</span>, <span class="cm-number">2</span>, <span class="cm-variable">figure</span><span class="cm-operator">=</span><span class="cm-variable">fig</span>)</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span cm-text="" cm-zwsp="">
</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-comment"># 散点图矩阵</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-variable">scatter_matrix</span> <span class="cm-operator">=</span> <span class="cm-variable">sns</span>.<span class="cm-property">pairplot</span>(<span class="cm-variable">all_df</span>.<span class="cm-property">sample</span>(<span class="cm-number">1000</span>), <span class="cm-variable">hue</span><span class="cm-operator">=</span><span class="cm-string">'Mode'</span>, <span class="cm-variable">diag_kind</span><span class="cm-operator">=</span><span class="cm-string">'kde'</span>)</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-variable">scatter_matrix</span>.<span class="cm-property">fig</span>.<span class="cm-property">suptitle</span>(<span class="cm-string">'Scatter Plot Matrix of Different Modes'</span>)</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-variable">scatter_matrix</span>.<span class="cm-property">fig</span>.<span class="cm-property">tight_layout</span>(<span class="cm-variable">rect</span><span class="cm-operator">=</span>[<span class="cm-number">0</span>, <span class="cm-number">0.03</span>, <span class="cm-number">1</span>, <span class="cm-number">0.95</span>])</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span cm-text="" cm-zwsp="">
</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-comment"># 使用 BytesIO 在内存中保存图像</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-variable">buf</span> <span class="cm-operator">=</span> <span class="cm-variable">BytesIO</span>()</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-variable">scatter_matrix</span>.<span class="cm-property">fig</span>.<span class="cm-property">savefig</span>(<span class="cm-variable">buf</span>, <span class="cm-builtin">format</span><span class="cm-operator">=</span><span class="cm-string">'png'</span>, <span class="cm-variable">bbox_inches</span><span class="cm-operator">=</span><span class="cm-string">'tight'</span>)</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-variable">plt</span>.<span class="cm-property">close</span>(<span class="cm-variable">scatter_matrix</span>.<span class="cm-property">fig</span>) <span class="cm-comment"># 关闭散点图矩阵的图形对象以释放内存</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span cm-text="" cm-zwsp="">
</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-variable">buf</span>.<span class="cm-property">seek</span>(<span class="cm-number">0</span>)</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-variable">scatter_img</span> <span class="cm-operator">=</span> <span class="cm-variable">plt</span>.<span class="cm-property">imread</span>(<span class="cm-variable">buf</span>)</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-variable">ax1</span> <span class="cm-operator">=</span> <span class="cm-variable">fig</span>.<span class="cm-property">add_subplot</span>(<span class="cm-variable">gs</span>[<span class="cm-number">0</span>, <span class="cm-number">0</span>])</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-variable">ax1</span>.<span class="cm-property">imshow</span>(<span class="cm-variable">scatter_img</span>)</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-variable">ax1</span>.<span class="cm-property">axis</span>(<span class="cm-string">'off'</span>) <span class="cm-comment"># 关闭轴线</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span cm-text="" cm-zwsp="">
</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-comment"># 平行坐标图</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-variable">ax2</span> <span class="cm-operator">=</span> <span class="cm-variable">fig</span>.<span class="cm-property">add_subplot</span>(<span class="cm-variable">gs</span>[<span class="cm-number">0</span>, <span class="cm-number">1</span>])</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-variable">parallel_coordinates</span>(<span class="cm-variable">all_df</span>.<span class="cm-property">sample</span>(<span class="cm-number">500</span>), <span class="cm-string">'Mode'</span>, <span class="cm-variable">ax</span><span class="cm-operator">=</span><span class="cm-variable">ax2</span>)</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-variable">ax2</span>.<span class="cm-property">set_title</span>(<span class="cm-string">'Parallel Coordinates Plot'</span>)</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-variable">ax2</span>.<span class="cm-property">set_xlabel</span>(<span class="cm-string">'Variables'</span>)</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-variable">ax2</span>.<span class="cm-property">set_ylabel</span>(<span class="cm-string">'Scaled Values'</span>)</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-variable">ax2</span>.<span class="cm-property">legend</span>(<span class="cm-variable">title</span><span class="cm-operator">=</span><span class="cm-string">'Mode'</span>)</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-variable">ax2</span>.<span class="cm-property">grid</span>(<span class="cm-keyword">True</span>)</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span cm-text="" cm-zwsp="">
</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-variable">plt</span>.<span class="cm-property">tight_layout</span>()</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-variable">plt</span>.<span class="cm-property">show</span>()</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span cm-text="" cm-zwsp="">
</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span cm-text="" cm-zwsp="">
</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-keyword">def</span> <span class="cm-def">plot_combined_time_series_and_distribution</span>(<span class="cm-variable">all_data</span>, <span class="cm-variable">modes</span>, <span class="cm-variable">variable</span><span class="cm-operator">=</span><span class="cm-string">'y'</span>, <span class="cm-variable">distribution_type</span><span class="cm-operator">=</span><span class="cm-string">'violin'</span>):</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-string">"""</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-string"> 在同一图表中绘制时间序列图和分布图(如小提琴图或箱形图)。</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span cm-text="" cm-zwsp="">
</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-string"> 参数:</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-string"> all_data (dict): 包含所有模式数据的字典。</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-string"> modes (list): 模式名称列表。</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-string"> variable (str): 需要绘制的时间序列变量,默认为 'y'。</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-string"> distribution_type (str): 分布图类型,可选值 'violin' 或 'box',默认为 'violin'。</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-string"> """</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-variable">all_df</span> <span class="cm-operator">=</span> <span class="cm-variable">pd</span>.<span class="cm-property">concat</span>([<span class="cm-variable">pd</span>.<span class="cm-property">DataFrame</span>(<span class="cm-variable">all_data</span>[<span class="cm-variable">mode</span>]).<span class="cm-property">assign</span>(<span class="cm-variable">Mode</span><span class="cm-operator">=</span><span class="cm-variable">mode</span>) <span class="cm-keyword">for</span> <span class="cm-variable">mode</span> <span class="cm-keyword">in</span> <span class="cm-variable">modes</span>])</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span cm-text="" cm-zwsp="">
</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-comment"># 创建子图网格</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-variable">fig</span>, (<span class="cm-variable">ax1</span>, <span class="cm-variable">ax2</span>) <span class="cm-operator">=</span> <span class="cm-variable">plt</span>.<span class="cm-property">subplots</span>(<span class="cm-number">2</span>, <span class="cm-number">1</span>, <span class="cm-variable">figsize</span><span class="cm-operator">=</span>(<span class="cm-number">12</span>, <span class="cm-number">10</span>), <span class="cm-variable">gridspec_kw</span><span class="cm-operator">=</span>{<span class="cm-string">'height_ratios'</span>: [<span class="cm-number">3</span>, <span class="cm-number">1</span>]})</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span cm-text="" cm-zwsp="">
</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-comment"># 时间序列图</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-keyword">for</span> <span class="cm-variable">mode</span> <span class="cm-keyword">in</span> <span class="cm-variable">modes</span>:</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-variable">ax1</span>.<span class="cm-property">plot</span>(<span class="cm-variable">all_df</span>[<span class="cm-variable">all_df</span>[<span class="cm-string">'Mode'</span>] <span class="cm-operator">==</span> <span class="cm-variable">mode</span>][<span class="cm-variable">variable</span>], <span class="cm-variable">label</span><span class="cm-operator">=</span><span class="cm-variable">mode</span>)</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-variable">ax1</span>.<span class="cm-property">set_title</span>(<span class="cm-string">f'Time Series and Distribution of </span>{<span class="cm-variable">variable</span>}<span class="cm-string">'</span>)</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-variable">ax1</span>.<span class="cm-property">set_xlabel</span>(<span class="cm-string">'Time Step'</span>)</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-variable">ax1</span>.<span class="cm-property">set_ylabel</span>(<span class="cm-string">f'Value of </span>{<span class="cm-variable">variable</span>}<span class="cm-string">'</span>)</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-variable">ax1</span>.<span class="cm-property">legend</span>()</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-variable">ax1</span>.<span class="cm-property">grid</span>(<span class="cm-keyword">True</span>)</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span cm-text="" cm-zwsp="">
</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-comment"># 分布图</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-keyword">if</span> <span class="cm-variable">distribution_type</span> <span class="cm-operator">==</span> <span class="cm-string">'violin'</span>:</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-variable">sns</span>.<span class="cm-property">violinplot</span>(<span class="cm-variable">x</span><span class="cm-operator">=</span><span class="cm-string">'Mode'</span>, <span class="cm-variable">y</span><span class="cm-operator">=</span><span class="cm-variable">variable</span>, <span class="cm-variable">data</span><span class="cm-operator">=</span><span class="cm-variable">all_df</span>, <span class="cm-variable">ax</span><span class="cm-operator">=</span><span class="cm-variable">ax2</span>)</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-keyword">elif</span> <span class="cm-variable">distribution_type</span> <span class="cm-operator">==</span> <span class="cm-string">'box'</span>:</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-variable">sns</span>.<span class="cm-property">boxplot</span>(<span class="cm-variable">x</span><span class="cm-operator">=</span><span class="cm-string">'Mode'</span>, <span class="cm-variable">y</span><span class="cm-operator">=</span><span class="cm-variable">variable</span>, <span class="cm-variable">data</span><span class="cm-operator">=</span><span class="cm-variable">all_df</span>, <span class="cm-variable">ax</span><span class="cm-operator">=</span><span class="cm-variable">ax2</span>)</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-variable">ax2</span>.<span class="cm-property">set_xlabel</span>(<span class="cm-string">'Mode'</span>)</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-variable">ax2</span>.<span class="cm-property">set_ylabel</span>(<span class="cm-string">f'Distribution of </span>{<span class="cm-variable">variable</span>}<span class="cm-string">'</span>)</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span cm-text="" cm-zwsp="">
</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-variable">plt</span>.<span class="cm-property">tight_layout</span>()</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-variable">plt</span>.<span class="cm-property">show</span>()</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span cm-text="" cm-zwsp="">
</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span cm-text="" cm-zwsp="">
</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-comment"># 使用类</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-keyword">if</span> <span class="cm-variable">__name__</span> <span class="cm-operator">==</span> <span class="cm-string">'__main__'</span>:</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-keyword">import</span> <span class="cm-variable">pandas</span> <span class="cm-keyword">as</span> <span class="cm-variable">pd</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-keyword">import</span> <span class="cm-variable">seaborn</span> <span class="cm-keyword">as</span> <span class="cm-variable">sns</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-keyword">from</span> <span class="cm-variable">pandas</span>.<span class="cm-property">plotting</span> <span class="cm-keyword">import</span> <span class="cm-variable">parallel_coordinates</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-keyword">from</span> <span class="cm-variable">sklearn</span>.<span class="cm-property">manifold</span> <span class="cm-keyword">import</span> <span class="cm-variable">TSNE</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-keyword">from</span> <span class="cm-variable">umap</span> <span class="cm-keyword">import</span> <span class="cm-variable">UMAP</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-keyword">from</span> <span class="cm-variable">io</span> <span class="cm-keyword">import</span> <span class="cm-variable">BytesIO</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-keyword">from</span> <span class="cm-variable">matplotlib</span>.<span class="cm-property">gridspec</span> <span class="cm-keyword">import</span> <span class="cm-variable">GridSpec</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span cm-text="" cm-zwsp="">
</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-variable">all_data</span> <span class="cm-operator">=</span> {}</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-variable">all_data_frames</span> <span class="cm-operator">=</span> {}</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-comment"># 定义三种模式的数据采集</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-variable">modes</span> <span class="cm-operator">=</span> [<span class="cm-string">'Mode 1'</span>, <span class="cm-string">'Mode 2'</span>, <span class="cm-string">'Mode 3'</span>]</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-keyword">for</span> <span class="cm-variable">mode</span> <span class="cm-keyword">in</span> <span class="cm-variable">modes</span>:</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-comment"># 初始化系统状态</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-variable">initial_state</span> <span class="cm-operator">=</span> <span class="cm-variable">np</span>.<span class="cm-property">array</span>([<span class="cm-number">0</span>, <span class="cm-number">0</span>]) <span class="cm-comment"># 初始状态可以自定义</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-variable">initial_input</span> <span class="cm-operator">=</span> <span class="cm-variable">np</span>.<span class="cm-property">array</span>([<span class="cm-number">0</span>,<span class="cm-number">0</span>]) <span class="cm-comment"># 初始输入可以自定义</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-variable">simulation</span> <span class="cm-operator">=</span> <span class="cm-variable">SystemPlant</span>(<span class="cm-variable">initial_state</span>, <span class="cm-variable">initial_input</span>, <span class="cm-variable">noise_amplitude</span><span class="cm-operator">=</span><span class="cm-number">0.01</span>, <span class="cm-variable">mode</span><span class="cm-operator">=</span><span class="cm-variable">mode</span>)</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-variable">y</span>, <span class="cm-variable">u</span>, <span class="cm-variable">x</span> <span class="cm-operator">=</span> <span class="cm-variable">simulation</span>.<span class="cm-property">generate_data</span>(<span class="cm-number">10000</span>)</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-variable">all_data</span>[<span class="cm-variable">mode</span>] <span class="cm-operator">=</span> {<span class="cm-string">'y'</span>: <span class="cm-variable">y</span>, <span class="cm-string">'u'</span>: <span class="cm-variable">u</span>, <span class="cm-string">'x'</span>: <span class="cm-variable">x</span>}</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-comment"># simulation.plot_results(mode_title=f"Simulation {mode}")</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-builtin">print</span>(<span class="cm-string">f"Data collection completed for </span>{<span class="cm-variable">mode</span>}<span class="cm-string">."</span>)</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-variable">df</span> <span class="cm-operator">=</span> <span class="cm-variable">pd</span>.<span class="cm-property">DataFrame</span>(<span class="cm-variable">all_data</span>[<span class="cm-variable">mode</span>])</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-comment"># df.to_excel(f'{mode}.xlsx', index=False)</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span cm-text="" cm-zwsp="">