You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

AnyLogic风电场仿真实验时长设置与离线风机数量数据导出咨询

Guide to Setting 2-Week Simulation Duration and Exporting Offline Turbine Data in AnyLogic

Hey Simon, glad to hear you’ve got your wind farm model up and running using the official tutorials—great start! Let’s walk through how to adjust the simulation duration to 2 weeks and export the count of offline turbines during that period, step by step:

1. Set Simulation Duration to 2 Weeks

  • Open your experiment (usually named Main or whatever you’ve called it) by double-clicking it in the Project view.
  • Navigate to the Time tab in the experiment’s properties panel.
  • Look for the Simulation duration field. You can set this in a couple intuitive ways:
    • If your model uses hours as the time unit: Enter 336 (since 2 weeks = 2×7×24 hours).
    • For a more readable approach, use AnyLogic’s built-in time function: Type weeks(2)—it’ll automatically convert to your model’s default time unit (just make sure your project’s time unit is set logically, e.g., hours or days, in Project Settings > Time).
  • Click Apply to save the setting. Your simulation will now run for exactly 2 weeks.

2. Track and Export Offline Turbine Count Data

First, we need to track how many turbines are offline at any time, then export that data to a usable file.

Step 2.1: Track Offline Turbines in Real-Time

  • In your main model agent (or the Main agent), create a collection to manage offline turbines:
    • Add a Collection<Turbine> variable (replace Turbine with your actual wind turbine agent name) and name it offlineTurbines.
    • In your turbine agent’s code, when a turbine goes offline (e.g., when a fault is triggered), add:
      main.offlineTurbines.add(this);
      
    • When the turbine comes back online (e.g., after maintenance completes), add:
      main.offlineTurbines.remove(this);
      
    • To get the real-time offline count, you can directly use offlineTurbines.size() whenever you need it—no extra variable required, though you can create an Integer variable offlineTurbineCount and update it if that feels more straightforward.

Step 2.2: Record Data at Regular Intervals

  • Drag a Dataset component from the Analysis palette into your Main agent, name it offlineTurbineDataset.
  • Add a Periodic Event component to log data at your desired frequency (e.g., every hour):
    • Set the event’s Interval to hours(1) (adjust to days, minutes, etc., based on how granular you want the data).
    • In the event’s Action field, add this code to log the current simulation time and offline turbine count:
      offlineTurbineDataset.add(time(), main.offlineTurbines.size());
      

Step 2.3: Export the Data to a File

You can choose to export automatically when the simulation ends, or add a manual button for on-demand exports:

  • Automatic Export on Simulation Stop:
    • Open your experiment’s properties, go to the Actions tab, and find the On stop field.
    • Add this code to save the dataset as a CSV file (it’ll save to your model’s root directory):
      main.offlineTurbineDataset.writeCsv(new File("2week_offline_turbine_data.csv"));
      
  • Manual Export Button:
    • Drag a Button component into your model’s presentation area, set its text to "Export Offline Data".
    • In the button’s On click action, paste the same CSV export code above.

Step 2.4: Verify the Data

Run a short test simulation first (e.g., 1 day) to make sure:

  • The offline count updates correctly when turbines fail or recover.
  • The dataset records the right values at each interval.
  • The CSV file generates properly with clear time and count columns.

内容的提问来源于stack exchange,提问作者Simon

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.30 13:13:11