Science Sector

Purpose: The ScienceSector orchestrates all scientific research activities within the simulation. Its primary function is to manage a fleet of ScienceRover agents to generate a cumulative science score, which can unlock new technologies or fulfill mission objectives. It also runs a receding-horizon growth policy that orders new rovers from the manufacturing/logistics pipeline to keep pace with a target science growth rate.

Core Components:

  • ScienceRover: The primary agent within the sector. Each rover is an independent entity with its own battery (battery_capacity_kWh, current_battery_kWh), power consumption rate (power_usage_kWh_per_step), and science generation rate (science_generation). Its behavior is governed by its internal state, primarily its battery level, and its status (IDLE, OPERATIONAL, CHARGING, LOW_BATTERY, THROTTLED).

  • ScienceSectorConfig: Scalar configuration and runtime counters for the sector, including growth-policy parameters (growth_duration_sp, lead_time_L, planning_horizon_H, safety_margin_beta, max_pipeline_capacity, expected_losses) and tracked state (current_growth_rate, S_0, rovers_in_pipeline, total_rovers, operational_rovers, p_eff).

Operational Cycle & Key Algorithms

A. Throttling (step)

A system-wide throttle_factor is applied before any power math. For each rover, a random draw against throttle_factor decides whether it is marked THROTTLED and excluded from this step’s power allocation and operation entirely. This is a key mechanism for policies (like the Dust Coverage Policy) to influence the sector’s activity level via set_throttle_factor. Deciding throttling first, and filtering throttled rovers out before any power distribution, ensures a throttled rover never ties up a power share it won’t use.

B. Fair-Share Power Distribution (_fair_share)

Only un-throttled rovers that actually need to charge (current_battery_kWh < power_usage_kWh_per_step) are considered demanders; each rover’s demand is the energy needed to reach full capacity (battery_capacity_kWh - current_battery_kWh). _fair_share performs a max-min fair split across just those rovers: available power is divided evenly among all current demanders, any rover whose remaining demand is covered by that even share is fully satisfied and removed, and its unused share is rolled back into the pool and re-split among the rovers still waiting, repeating until all demand is met or power runs out. A rover with a full battery is excluded from the split up front, so its unused share is never withheld from rovers that need to charge.

C. Rover Operation (ScienceRover.step)

Each un-throttled rover then executes its own step logic with the power allocated to it:

  • If it has enough battery, it operates, consuming power_usage_kWh_per_step and generating science_generation science, and its status becomes OPERATIONAL.

  • If it lacks power to operate, it attempts to charge from its allocation, becoming CHARGING (or LOW_BATTERY if still under the operating threshold afterward).

D. Metric & Growth Aggregation (step)

The sector aggregates step_science_generated and total power consumed by all rovers during the step, adds the science to total_science_cumulative, appends (step, step_science_generated) to science_history, and recalculates the current growth rate.

E. Growth-Rate Measurement (_calculate_growth_rate)

Using a sliding window of the last growth_duration_sp entries in science_history, the sector fits the observed science-production rate to an exponential model S(t) = S_0 * 2^(r*t) and solves for r = log2(S_current / S_0) / t_elapsed, updating current_growth_rate and S_0 (the production rate at the start of the window). Degenerate cases (fewer than two history samples, non-positive rates, or zero elapsed time) fall back to current_growth_rate = 0.0.

F. Receding-Horizon Growth Algorithm (_apply_growth_algorithm, triggered by control_science_growth_rate)

Algorithm from science_policies.md:

  1. Calculate effective productivity p_eff = p * a * u, where a (availability_factor_a) is the fraction of rovers currently OPERATIONAL and u (utilization_factor_u) is 1 - throttle_factor.

  2. Compute the future target science rate at the planning horizon, S_target(t+H), from S_0 and the configured growth_rate_sp.

  3. Determine required rovers R_req = ceil(S_target / p_eff).

  4. Forecast available rovers R_fore = total_rovers - expected_losses + rovers_in_pipeline.

  5. Compute the order quantity q(t) = max(0, ceil((1+safety_margin_beta) * R_req) - R_fore).

  6. Cap the order at the remaining pipeline capacity (max_pipeline_capacity - rovers_in_pipeline), logging a warning if the request is capped.

  7. If the capped order is non-zero, increment rovers_in_pipeline and publish one CONSTRUCTION_REQUEST event per ordered rover (module_id="comp_science_rover") so each unit is tracked individually through the pipeline.

G. Fleet Growth (handle_module_completed, _create_rover)

The sector subscribes to module_completed events on the event bus. When a comp_science_rover module completes for this sector, _create_rover instantiates a new ScienceRover and decrements rovers_in_pipeline (if positive). Each new rover’s unique_id is derived from len(self.science_rovers) (the fleet size before the new rover is appended), which stays unique even when rovers are created outside the normal increment path (see state restoration below), since it depends on the actual list length rather than a counter that _apply_latest_state may not advance.

H. State Restoration (_apply_latest_state)

On construction, if a latest_state snapshot is supplied, the sector restores its counters (total_science_cumulative, total_rovers, operational_rovers, rovers_in_pipeline, current_growth_rate, S_0, p_eff) and, if the saved total_rovers exceeds the number of agents actually spawned, tops up the fleet by calling _create_rover(..., increment_total=False) for each missing rover so the restored count isn’t double-applied.

Interaction with the World System:

  • Metric Contribution: The sector reports its contributions via get_metrics, including IND-DUST-COV: the number of operational rovers contributes to overall dust coverage, simulating the environmental impact of their activity (_create_metric_map, driven by each rover config’s metric_contributions).

  • Policy Interface: set_throttle_factor is a direct interface for the PolicyEngine to raise or lower the sector’s operational tempo.

  • Dynamic Growth: The sector listens for module_completed events, allowing it to dynamically add new rovers as they are constructed, and itself drives that construction by publishing CONSTRUCTION_REQUEST events via the growth algorithm.

Equations

Science Metric as Technology Unlock Driver:

\[S_t = S_{t-1} + \eta_{\mathrm{SCI}} \cdot r_{\mathrm{SCI}}(t) - \delta_{\mathrm{SCI}} \, S_{t-1}\]

Unlock condition:

\[S_t \geq S_{\mathrm{fusion}} \quad \Rightarrow \quad \text{Fusion technology unlocked}\]

Explanation:

  • \(S_t\): cumulative science score.

  • \(\eta_{\mathrm{SCI}}\): science efficiency per rover-hour/mission.

  • \(r_{\mathrm{SCI}}(t)\): science rate at time (t).

  • \(\delta_{\mathrm{SCI}}\): knowledge decay rate.

  • Crossing \(S_{\mathrm{fusion}}\) unlocks helium-3 fusion tech.

Growth-Rate Fit:

\[S(t) = S_0 \cdot 2^{r t} \quad \Rightarrow \quad r = \frac{\log_2(S_{\text{current}} / S_0)}{t_{\text{elapsed}}}\]

Receding-Horizon Rover Ordering:

\[p_{\text{eff}} = p \cdot a \cdot u\]
\[R_{\text{req}} = \left\lceil \frac{S_{\text{target}}(t+H)}{p_{\text{eff}}} \right\rceil\]
\[R_{\text{fore}} = R_{\text{total}} - \text{Losses}_{\text{expected}} + R_{\text{pipeline}}\]
\[q(t) = \max\left(0,\ \lceil (1+\beta) \cdot R_{\text{req}} \rceil - R_{\text{fore}}\right)\]

Configuration Options

The sector is configured in the world_system JSON file, defining its rover fleet and growth-policy parameters.

"science": {
  "sector_name": "science",
  "growth_duration_sp": 6,
  "lead_time_L": 2,
  "planning_horizon_H": 60,
  "safety_margin_beta": 0.1,
  "max_pipeline_capacity": 10,
  "expected_losses": 0,
  "science_rovers": [
    {
      "quantity": 4,
      "config": {
        "power_usage_kWh": 0.2,
        "science_generation": 0.5,
        "battery_capacity_kWh": 20
      },
      "metric_contributions": [
        {
          "metric_id": "IND-DUST-COV",
          "contribution_type": "predefined",
          "contribution_value": 0.01
        }
      ]
    }
  ]
}

TODO: Potential Improvements

  • [ ] Losses Modeling: expected_losses is currently a static config value; it is never updated to reflect actual rover attrition over time.

  • [ ] Per-Rover Capability: Unlike the manufacturing sector’s per-robot isru_modes, all science rovers are treated as interchangeable; there is no mechanism for specialized rover types or capability matching.