File size: 24,803 Bytes
484e3bc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
"""
Taiwan Situation Room - GeoBot 2.0 Analytical Framework Demo

Comprehensive demonstration of GeoBot 2.0 analytical capabilities applied
to Taiwan Strait scenario analysis. Integrates:

- GeoBot 2.0 analytical lenses (Governance, Logistics, Corruption, Non-Western)
- Bayesian forecasting and belief updating
- Structural causal models for intervention analysis
- Hawkes processes for escalation dynamics

Scenario: Rising tensions in Taiwan Strait with potential for
military escalation. Analysis evaluates PRC capabilities, deterrence
credibility, and intervention outcomes.
"""


import numpy as np
from datetime import datetime

# GeoBot 2.0 Analytical Framework
from geobot.analysis import (
    AnalyticalEngine,
    GovernanceType,
    CorruptionType,
    AnalyticalLenses
)

# Bayesian Forecasting (if numpy available)
try:
    from geobot.bayes import (
        BayesianForecaster,
        GeopoliticalPrior,
        PriorType,
        EvidenceUpdate,
        EvidenceType
    )
    BAYES_AVAILABLE = True
except ImportError:
    BAYES_AVAILABLE = False
    print("Note: Bayesian forecasting requires numpy - skipping Bayesian analysis")

# Causal Models (if numpy/networkx available)
try:
    from geobot.causal import (
        StructuralCausalModel,
        StructuralEquation,
        Intervention,
        Counterfactual
    )
    CAUSAL_AVAILABLE = True
except ImportError:
    CAUSAL_AVAILABLE = False
    print("Note: Causal models require numpy/networkx - skipping causal analysis")

# Hawkes processes (if scipy available)
try:
    from geobot.simulation.hawkes import (
        HawkesSimulator,
        quick_conflict_contagion_analysis
    )
    HAWKES_AVAILABLE = True
except ImportError:
    HAWKES_AVAILABLE = False
    print("Note: Hawkes processes require scipy - skipping escalation dynamics")


def print_header(title):
    """Print formatted section header."""
    print("\n" + "=" * 80)
    print(f"  {title}")
    print("=" * 80 + "\n")


def print_subheader(title):
    """Print formatted subsection header."""
    print("\n" + "-" * 80)
    print(f"  {title}")
    print("-" * 80 + "\n")


# ============================================================================
# Part 1: GeoBot 2.0 Core Analysis
# ============================================================================

def part1_geobot_core_analysis():
    """
    Apply GeoBot 2.0 analytical framework to Taiwan scenario.
    """
    print_header("Part 1: GeoBot 2.0 Analytical Framework - Taiwan Scenario")

    engine = AnalyticalEngine()

    # Scenario context
    query = """PRC conducts large-scale military exercises around Taiwan,
including live-fire drills and simulated blockade operations. US conducts
freedom of navigation operations in Taiwan Strait. What are the escalation
risks and intervention outcomes?"""

    print(f"QUERY: {query}\n")

    # Build comprehensive context
    context = {
        'governance_type': GovernanceType.AUTHORITARIAN_CENTRALIZED,
        'corruption_type': CorruptionType.MANAGED_BOUNDED,
        'military_system': 'Chinese PLA',
        'scenario_description': 'PRC military exercises and potential Taiwan contingency',
        'operational_context': 'High-intensity joint operations in near-seas environment',

        'summary': """PRC demonstrates improving capability for joint operations in Taiwan
Strait, but faces significant logistical and operational challenges for sustained
high-intensity operations. Authoritarian governance enables rapid mobilization but
information flow problems could create coordination failures under stress.""",

        'logistics_assessment': """PRC Eastern Theater Command has concentrated logistics
infrastructure supporting Taiwan contingency. Civil-military fusion enables rapid resource
mobilization. However, sustained amphibious/air assault operations would stress logistics
systems untested in combat. Key constraints: sealift capacity, contested logistics under
US/allied interdiction, ammunition sustainment for high-intensity operations.""",

        # Scenarios with probabilities
        'scenarios': [
            {
                'name': 'Coercive demonstration without escalation',
                'probability': 0.55,
                'description': 'Exercises conclude after demonstrating capability and resolve'
            },
            {
                'name': 'Graduated escalation (quarantine/blockade)',
                'probability': 0.30,
                'description': 'PRC implements quarantine, testing US/allied response'
            },
            {
                'name': 'Limited kinetic action',
                'probability': 0.10,
                'description': 'Strikes on Taiwan military targets, no invasion'
            },
            {
                'name': 'Full-scale invasion attempt',
                'probability': 0.05,
                'description': 'Amphibious/airborne assault on Taiwan'
            }
        ],

        # Uncertainty factors
        'uncertainty_factors': [
            'PRC leadership risk tolerance and decision calculus',
            'Taiwan domestic political response and resolve',
            'US extended deterrence credibility perception',
            'PLA actual readiness vs. reported readiness (information distortion risk)',
            'Third-party actions (Japan, Australia, regional states)',
            'Economic interdependence constraints on escalation'
        ],

        # Signals to watch
        'signals_to_watch': [
            'PLA logistics mobilization (satellite-observable sealift, air transport concentration)',
            'Rocket Force alert status and deployment patterns',
            'PLAN submarine deployments',
            'Civilian shipping disruptions (clearance of civilian vessels from exercise areas)',
            'PRC domestic propaganda shifts (priming for kinetic action vs. victorious conclusion)',
            'US carrier strike group deployments and readiness status',
            'Taiwan reserve mobilization signals',
            'Japanese Self-Defense Force posture changes'
        ],

        # Comparative notes
        'comparative_notes': """Unlike Russia-Ukraine, PRC faces amphibious/air assault across
defended strait with peer/near-peer opposition (US, Japan, Australia). PLA has not conducted
combat operations since 1979, vs. Russia's experience in Syria, Georgia, Ukraine. However,
PRC has advantage of proximity, massive firepower overmatch against Taiwan alone, and
authoritarian ability to sustain economic costs."""
    }

    # Add governance-specific analysis
    context['governance_context'] = {
        'trade_off': """Authoritarian governance enables PRC to:
        - Rapidly mobilize resources without legislative approval
        - Sustain operations despite economic costs and casualties
        - Conduct strategic surprise without public debate

        But creates risks:
        - Information distortion about PLA readiness/capabilities
        - Over-confidence in leadership due to filtered reporting
        - Inflexible response to unexpected battlefield developments""",

        'context_specific_advantage': """In crisis initiation and short, sharp operations,
authoritarian system has decision-speed advantage. In sustained operations requiring
adaptation, democratic information flow advantages become more important. Key question:
Can PRC achieve fait accompli before US/allied decision-making concludes?"""
    }

    # Add corruption context
    context['corruption_details'] = {
        'evidence': """Post-2012 anti-corruption campaigns have reduced parasitic corruption
in PLA, especially after 2017 Rocket Force purges. However, managed corruption model means:
        - Procurement still involves kickbacks, but constrained to avoid readiness impact
        - Promotion decisions still involve patronage, affecting command quality
        - Readiness reporting still subject to careerism incentives""",

        'risk_assessment': """Corruption less likely to cause catastrophic equipment failures
(cf. Russian logistics in Ukraine), but could create:
        - Over-estimation of PLA capabilities by leadership
        - Coordination problems from patronage-based command appointments
        - Supply chain inefficiencies under stress"""
    }

    # Add non-Western analysis
    context['non_western_context'] = {
        'analysis_framework': """PLA operational culture emphasizes:
        - Centralized planning with detailed pre-scripted operations
        - Heavy firepower preparation before maneuver
        - Political control through party committee system
        - Joint operations still developing (improving but not NATO-level)

        This creates both capabilities and constraints different from Western assumptions.""",

        'key_distinction': """Western analysis often assumes PLA would operate like NATO forces.
In reality, PLA would likely emphasize:
        - Overwhelming initial firepower (missiles, air strikes) to create shock
        - Rapid fait accompli before US can intervene
        - Accepting higher casualties than Western forces
        - Using information operations and political warfare alongside kinetic

        These reflect Chinese strategic culture and organizational strengths, not deficiencies."""
    }

    # Perform analysis
    print_subheader("GeoBot 2.0 Analytical Output")
    analysis = engine.analyze(query, context)
    print(analysis)


# ============================================================================
# Part 2: Bayesian Belief Updating
# ============================================================================

def part2_bayesian_analysis():
    """
    Bayesian belief updating as new intelligence arrives.
    """
    if not BAYES_AVAILABLE:
        print_header("Part 2: Bayesian Analysis - SKIPPED (numpy not available)")
        return

    print_header("Part 2: Bayesian Belief Updating - Intelligence Integration")

    forecaster = BayesianForecaster()

    # Set prior on PRC invasion probability within 12 months
    invasion_prior = GeopoliticalPrior(
        parameter_name="invasion_probability_12mo",
        prior_type=PriorType.BETA,
        parameters={'alpha': 2.0, 'beta': 18.0},  # Prior mean ~0.10
        description="Probability of PRC invasion attempt within 12 months"
    )

    forecaster.set_prior(invasion_prior)

    print("PRIOR BELIEF:")
    print(f"  Distribution: Beta(α=2.0, β=18.0)")
    print(f"  Prior mean: ~0.10 (10% chance)")
    print(f"  This reflects baseline assessment before current crisis\n")

    # Evidence 1: Satellite imagery shows sealift mobilization
    print_subheader("Evidence Update 1: Satellite Imagery")
    print("Satellite imagery shows increased sealift concentration in Fujian ports")
    print("Assessing impact on invasion probability...\n")

    def sealift_likelihood(p):
        # If invasion likely, sealift mobilization is very likely
        # If invasion unlikely, some mobilization still possible (exercises)
        return p * 0.9 + (1 - p) * 0.2

    evidence1 = EvidenceUpdate(
        evidence_type=EvidenceType.SATELLITE_IMAGERY,
        observation="sealift_mobilization",
        likelihood_function=sealift_likelihood,
        reliability=0.95,
        source="Commercial satellite analysis"
    )

    belief1 = forecaster.update_belief(
        "invasion_probability_12mo",
        evidence1,
        n_samples=10000
    )

    print(f"Updated belief after satellite evidence:")
    print(f"  Mean: {belief1.mean():.3f}")
    print(f"  Median: {belief1.median():.3f}")
    print(f"  95% CI: {belief1.credible_interval(0.05)}")
    print(f"  P(invasion > 0.20): {belief1.probability_greater_than(0.20):.2f}\n")

    # Evidence 2: HUMINT reports purges in Taiwan Affairs Office
    print_subheader("Evidence Update 2: HUMINT Report")
    print("HUMINT reports internal purges in Taiwan Affairs Office leadership")
    print("Interpretation: Could indicate pre-operation security tightening OR internal dysfunction\n")

    def purge_likelihood(p):
        # Purges could indicate either preparation or problems
        # Moderate signal
        return p * 0.6 + (1 - p) * 0.4

    evidence2 = EvidenceUpdate(
        evidence_type=EvidenceType.INTELLIGENCE_REPORT,
        observation="tao_purges",
        likelihood_function=purge_likelihood,
        reliability=0.70,  # HUMINT less reliable than satellite
        source="HUMINT Taiwan Affairs Office"
    )

    belief2 = forecaster.update_belief(
        "invasion_probability_12mo",
        evidence2,
        n_samples=10000
    )

    print(f"Updated belief after HUMINT evidence:")
    print(f"  Mean: {belief2.mean():.3f}")
    print(f"  Median: {belief2.median():.3f}")
    print(f"  95% CI: {belief2.credible_interval(0.05)}")
    print(f"  P(invasion > 0.20): {belief2.probability_greater_than(0.20):.2f}\n")

    # Evidence 3: Economic data shows continued deep integration
    print_subheader("Evidence Update 3: Economic Data")
    print("Economic data shows continued deep PRC-Taiwan trade integration, no decoupling")
    print("Interpretation: Reduces likelihood of near-term kinetic action\n")

    def economic_likelihood(p):
        # Continued integration suggests not preparing for war
        return p * 0.3 + (1 - p) * 0.8

    evidence3 = EvidenceUpdate(
        evidence_type=EvidenceType.ECONOMIC_DATA,
        observation="continued_integration",
        likelihood_function=economic_likelihood,
        reliability=1.0,  # Economic data highly reliable
        source="Trade statistics"
    )

    belief3 = forecaster.update_belief(
        "invasion_probability_12mo",
        evidence3,
        n_samples=10000
    )

    print(f"Final belief after all evidence:")
    print(f"  Mean: {belief3.mean():.3f}")
    print(f"  Median: {belief3.median():.3f}")
    print(f"  95% CI: {belief3.credible_interval(0.05)}")
    print(f"  P(invasion > 0.20): {belief3.probability_greater_than(0.20):.2f}")
    print(f"  P(invasion > 0.30): {belief3.probability_greater_than(0.30):.2f}")

    # Summary
    summary = forecaster.get_belief_summary("invasion_probability_12mo")
    print(f"\nBelief Summary:")
    print(f"  Evidence updates: {summary['n_evidence_updates']}")
    print(f"  Evidence types: {summary['evidence_types']}")
    print(f"  Final assessment: {summary['mean']:.1%} probability within 12 months")


# ============================================================================
# Part 3: Causal Intervention Analysis
# ============================================================================

def part3_causal_intervention_analysis():
    """
    Use structural causal models to evaluate intervention outcomes.
    """
    if not CAUSAL_AVAILABLE:
        print_header("Part 3: Causal Analysis - SKIPPED (dependencies not available)")
        return

    print_header("Part 3: Causal Intervention Analysis - Policy Counterfactuals")

    # Build SCM for Taiwan deterrence
    print("Building Structural Causal Model for Taiwan deterrence dynamics...\n")

    scm = StructuralCausalModel(name="TaiwanDeterrenceSCM")

    noise_dist = lambda n: np.random.randn(n) * 0.05

    # US military presence -> PRC perception of US resolve
    scm.add_equation(StructuralEquation(
        variable="prc_perceived_us_resolve",
        parents=["us_military_presence"],
        function=lambda p: 0.3 + 0.6 * p["us_military_presence"],
        noise_dist=noise_dist,
        description="US military presence increases PRC perception of US resolve"
    ))

    # Taiwan defense spending -> Taiwan military capability
    scm.add_equation(StructuralEquation(
        variable="taiwan_military_capability",
        parents=["taiwan_defense_spending"],
        function=lambda p: 0.4 + 0.5 * p["taiwan_defense_spending"],
        noise_dist=noise_dist,
        description="Taiwan defense spending improves military capability"
    ))

    # PRC perceived costs = f(US resolve, Taiwan capability)
    scm.add_equation(StructuralEquation(
        variable="prc_perceived_costs",
        parents=["prc_perceived_us_resolve", "taiwan_military_capability"],
        function=lambda p: (0.4 * p["prc_perceived_us_resolve"] +
                          0.3 * p["taiwan_military_capability"]),
        noise_dist=noise_dist,
        description="Perceived costs depend on US resolve and Taiwan capability"
    ))

    # Conflict risk = f(perceived costs, prc_domestic_pressure)
    scm.add_equation(StructuralEquation(
        variable="conflict_risk",
        parents=["prc_perceived_costs", "prc_domestic_pressure"],
        function=lambda p: (0.5 + 0.3 * p["prc_domestic_pressure"] -
                          0.4 * p["prc_perceived_costs"]),
        noise_dist=noise_dist,
        description="Conflict risk increases with domestic pressure, decreases with perceived costs"
    ))

    # Baseline scenario
    print_subheader("Baseline Scenario")
    baseline_data = scm.simulate(n_samples=10000, random_state=42)
    print(f"Baseline conflict risk: Mean = {np.mean(baseline_data['conflict_risk']):.3f}, "
          f"Std = {np.std(baseline_data['conflict_risk']):.3f}\n")

    # Intervention 1: Increase US military presence
    print_subheader("Intervention 1: Increase US Military Presence")
    print("do(us_military_presence = 0.8)  # High presence\n")

    intervention1 = Intervention(
        variable="us_military_presence",
        value=0.8,
        description="Sustained US carrier presence + forward-deployed assets"
    )

    post_intervention1 = scm.intervene([intervention1], n_samples=10000, random_state=42)
    print(f"Post-intervention conflict risk: Mean = {np.mean(post_intervention1['conflict_risk']):.3f}")
    print(f"Effect of intervention: {np.mean(baseline_data['conflict_risk']) - np.mean(post_intervention1['conflict_risk']):.3f} reduction")
    print(f"Interpretation: Increasing US presence reduces conflict risk by ~{100*(np.mean(baseline_data['conflict_risk']) - np.mean(post_intervention1['conflict_risk'])):.1f} percentage points\n")

    # Intervention 2: Increase Taiwan defense spending
    print_subheader("Intervention 2: Increase Taiwan Defense Spending")
    print("do(taiwan_defense_spending = 0.9)  # Major defense investment\n")

    intervention2 = Intervention(
        variable="taiwan_defense_spending",
        value=0.9,
        description="Major asymmetric defense investments"
    )

    post_intervention2 = scm.intervene([intervention2], n_samples=10000, random_state=42)
    print(f"Post-intervention conflict risk: Mean = {np.mean(post_intervention2['conflict_risk']):.3f}")
    print(f"Effect of intervention: {np.mean(baseline_data['conflict_risk']) - np.mean(post_intervention2['conflict_risk']):.3f} reduction\n")

    # Combined intervention
    print_subheader("Intervention 3: Combined Strategy")
    print("do(us_military_presence = 0.8, taiwan_defense_spending = 0.9)\n")

    combined_data = scm.intervene([intervention1, intervention2], n_samples=10000, random_state=42)
    print(f"Post-intervention conflict risk: Mean = {np.mean(combined_data['conflict_risk']):.3f}")
    print(f"Effect of combined intervention: {np.mean(baseline_data['conflict_risk']) - np.mean(combined_data['conflict_risk']):.3f} reduction")
    print(f"Interpretation: Combined strategy most effective for reducing conflict risk\n")

    # Counterfactual query
    print_subheader("Counterfactual Query")
    print("Question: What would conflict risk be if we had maintained high US presence,")
    print("given that we currently observe moderate US presence?\n")

    counterfactual = Counterfactual(
        query_variable="conflict_risk",
        intervention=Intervention("us_military_presence", 0.8),
        observations={"us_military_presence": 0.5}
    )

    cf_result = scm.counterfactual_query(counterfactual, n_samples=10000)
    print(f"Counterfactual conflict risk: {cf_result['expected_value']:.3f}")
    print(f"95% CI: ({cf_result['quantiles']['5%']:.3f}, {cf_result['quantiles']['95%']:.3f})")


# ============================================================================
# Part 4: Escalation Dynamics (Hawkes Processes)
# ============================================================================

def part4_escalation_dynamics():
    """
    Model escalation dynamics using Hawkes processes.
    """
    if not HAWKES_AVAILABLE:
        print_header("Part 4: Escalation Dynamics - SKIPPED (scipy not available)")
        return

    print_header("Part 4: Escalation Dynamics - Self-Exciting Processes")

    from geobot.simulation.hawkes import HawkesParameters

    print("Modeling crisis escalation as self-exciting point process...")
    print("Events cluster in time and trigger subsequent events (escalatory spiral)\n")

    # Simulate escalation scenario
    print_subheader("Scenario: Incremental Escalation with Contagion")

    # Three actors: PRC, Taiwan, US
    baseline_rates = [0.5, 0.3, 0.2]  # PRC initiates more, US responds
    countries = ['PRC', 'Taiwan', 'US']

    # Contagion: PRC action triggers Taiwan/US response
    alpha_matrix = np.array([
        [0.3, 0.2, 0.15],  # PRC actions trigger more PRC, Taiwan, US actions
        [0.4, 0.2, 0.3],   # Taiwan actions strongly trigger PRC and US
        [0.5, 0.2, 0.1],   # US actions strongly trigger PRC responses
    ])

    beta_matrix = np.ones((3, 3)) * 1.5  # Decay rate

    params = HawkesParameters(
        mu=np.array(baseline_rates),
        alpha=alpha_matrix,
        beta=beta_matrix
    )

    # Simulate 30-day crisis
    simulator = HawkesSimulator(n_dimensions=3)
    events = simulator.simulate(T=30.0, params=params, random_state=42)

    print(f"Simulated 30-day crisis escalation:")
    for i, country in enumerate(countries):
        print(f"  {country}: {len(events[i])} escalatory events")

    # Assess stability
    stability = simulator.assess_stability(params)
    print(f"\nEscalation dynamics stability assessment:")
    print(f"  Branching ratio: {stability['branching_ratio']:.3f}")
    print(f"  Regime: {stability['regime']}")
    print(f"  Interpretation: {stability['interpretation']}\n")

    if stability['is_explosive']:
        print("⚠️  WARNING: Process is supercritical - escalation could spiral out of control")
    else:
        print("✓ Process is subcritical - escalation will stabilize")


# ============================================================================
# Main Execution
# ============================================================================

def main():
    """Run complete Taiwan situation room analysis."""

    print("\n" + "=" * 80)
    print("  TAIWAN SITUATION ROOM")
    print("  GeoBot 2.0 Integrated Geopolitical Analysis")
    print("  " + datetime.now().strftime("%Y-%m-%d %H:%M:%S"))
    print("=" * 80)

    # Run all parts
    part1_geobot_core_analysis()
    part2_bayesian_analysis()
    part3_causal_intervention_analysis()
    part4_escalation_dynamics()

    # Summary
    print_header("Summary and Recommendations")

    print("""
INTEGRATED ASSESSMENT:

1. GEOBOT 2.0 ANALYTICAL FRAMEWORK
   - PRC has improving joint operations capability but faces significant logistical
     constraints for sustained high-intensity operations
   - Authoritarian governance enables rapid mobilization but creates information
     flow risks
   - Managed corruption likely constrained enough to maintain basic functionality
   - Non-Western analysis reveals PRC emphasis on firepower and fait accompli

2. BAYESIAN BELIEF UPDATING
   - Posterior probability of invasion within 12 months: ~15-20% (up from 10% prior)
   - Satellite evidence of sealift mobilization raises concern
   - Economic integration evidence reduces near-term kinetic risk
   - Continued monitoring required as new intelligence arrives

3. CAUSAL INTERVENTION ANALYSIS
   - Combined strategy (US presence + Taiwan defense) most effective
   - US military presence has direct deterrent effect
   - Taiwan capabilities create operational costs for PRC
   - Counterfactual analysis supports sustained presence policy

4. ESCALATION DYNAMICS
   - Current contagion parameters suggest subcritical regime (stable)
   - However, parameter changes could shift to explosive regime
   - Escalation management critical to prevent spiral

POLICY RECOMMENDATIONS:
   - Maintain credible US extended deterrence
   - Support Taiwan asymmetric defense capabilities
   - Engage in crisis management mechanisms to prevent escalation spirals
   - Continue intelligence collection on PLA readiness and mobilization
   - Monitor for signals of PRC leadership decision to use force
    """)

    print("=" * 80)
    print("  Analysis Complete")
    print("=" * 80 + "\n")


if __name__ == "__main__":
    main()