首页/文章/ 详情

Anylogic官方案例教程——Air Defense System model(1)防空系统模型

1年前浏览5526

Air Defense System model 防空系统模型

This tutorial is taken from "The Big Book of Simulation Modeling" by Andrei Borshchev and Ilya Grigoryev and adapted for AnyLogic 8.
We will build a simple model of a radar-based air defense system. All types of agents in this model (bomber aircrafts, radars, missiles, bombs, and buildings) exist and interact in the continuous 3D space. We will use various kinds of movement and space sensing techniques.
Bombers are sent to destroy ground facilities compactly located in a certain area. One aircraft is launched per building. Aircrafts carry bombs. To complete its mission successfully, an aircraft needs to drop a bomb on the building. Having completed the mission, the bomber returns to the base using a higher altitude route. The bomber speed is 600 km/h.
The buildings are protected by the air defense system, which consists of two radars equipped with guided surface-to-air missiles. A radar can simultaneously guide up to two missiles. A missile is launched once the bomber enters the radar’s coverage area. The missile speed is 900 km/h. The missile explodes once it gets close to the aircraft. If the missile exits the radar coverage area before it hits the aircraft, it destroys itself.
The model development consists of four phases, with a ready-to-run model at the end of each phase.

本教程摘自Andrei Borshchev和Ilya Grigoryev的“仿真建模的大书”,改编为AnyLogic 8。

我们将建立一个雷达防空系统的简单模型。 模型中所有类型的agent(轰炸机、雷达、导弹、炸弹和建筑物)都存在并在连续的3D空间中相互作用。 我们将使用各种各样的运动和空间传感技术。

轰炸机被派去摧毁集中在某一地区的地面设施。 每座建筑发射一架飞机。 飞机携带炸弹。 为了成功完成任务,一架飞机需要在建筑物上投下一颗炸弹。 在完成任务后,轰炸机使用更高的高度路线返回基地。 轰炸机的速度是600公里/小时。

这些建筑物受到防空系统的保护,该系统由两台装有地对空导弹的雷达组成。 雷达可以同时制导两枚导弹。 一旦轰炸机进入雷达覆盖区域,导弹就发射。 导弹速度是900公里/小时。 导弹一旦接近飞机就会爆炸。 如果导弹在击中飞机之前离开了雷达覆盖区域,它就会自我毁灭。

模型开发由四个阶段组成,每个阶段的末尾都有一个准备运行的模型。

Phase 1. Creating assets 阶段1.创建资产

In the first phase we will create a new model and populate it with buildings that will be subject to bombing.

在第一阶段,我们将创建一个新的模型,并填充它的建筑,将被轰炸。

Create a new model创建一个新模型

Click the New toolbar button. The New Model dialog box will be displayed.
Define the parameters of the new model:
Specify the name of the model in the Model name field. Type Air Defense System.
Set the new model location if necessary by clicking the Browse button and selecting the required folder.
Set Model time units to seconds.

单击新工具栏按钮。将显示“新建模型”对话框。

定义新模型的参数:

在模型名称字段中指定模型的名称。型防空系统。

如果需要的话,通过单击Browse按钮并选择所需的文件夹来设置新的模型位置。

设置模型时间单位为秒。

3.Click Finish to create a new model.

3.单击Finish创建一个新模型。

We shall start designing our model with creating a new population of agents that will represent 10 facilities.

我们将从创建代表10个设施的新代理群体开始设计我们的模型。

Create new population of agents 创建新的代理群体

Drag the Agent element from the Agent palette onto the Main diagram. The New agent dialog box will open.
Click Population of agents. You will be taken to the next step of the New agent wizard.

将Agent元素从Agent调色板拖动到Main图上。将打开“新建代理”对话框。

单击“填充代理”。您将进入New代理向导的下一步。

3.Type Building in the Agent type name field. The Agent population name will be automatically filled.
Click Next to proceed to step 3.

3.在代理类型名称字段中生成类型。代理填充名称将自动填充。

单击Next继续步骤3。

4.Leave the Choose animation parameter set to 3D mode and choose the House animation shape in the Buildings section.
Click Next to proceed to step 4.

4.将“选择动画”参数设置为3D模式,并在“建筑”部分选择房屋动画形状。

单击Next继续步骤4。

5.We will not set any agent parameters, you may click Next to proceed to Step 5.

5.我们将不设置任何代理参数,您可以单击Next继续步骤5。

6.Set the Create population with parameter to 10.
Click Next to proceed to step 6.

6.将参数“创建填充”设置为10。

单击“下一步”,继续步骤6。

7.Leave the Space type parameter set to Continuous and select the Apply random layout option.

7.将空格类型参数设置为连续,并选择应用随机布局选项。

8.Click Finish to save the changes and create the customized population.
We have created a population of agents and defined animation shape for them.

8.单击Finish保存更改并创建自定义填充。

我们创建了一个代理群体,并为它们定义了动画形状。

Adjust the scale of the model调整模型的比例

1.Click the Scale element on the Main diagram to open its Properties.

1.单击主图上的Scale元素以打开其属性。

2.Set the Ruler length corresponds to parameter to 100. The scale on the ruler will change.

2.将标尺长度对应的参数设置为100。尺子上的刻度会改变。

We modified the scale of the model, as a result the building shape changed its size. As you can see in the image above, if we will keep the animations of our agents resized corresponding to the model scale, these agents (such as building here) will become invisible in our model's animation scene. So we will use greater scales for the agents to make them visible during the animation.

我们修改了模型的比例,结果建筑的形状改变了它的大小。如上图所示,如果我们将代理的动画调整为与模型比例相对应的大小,这些代理(比如这里的building)将在模型的动画场景中变得不可见。所以我们将使用更大的比例的代理,使他们在动画中可见。

We have completed setting up the population of agents and may now run our model for the first time to observe the model behavior.

我们已经完成了代理的总体设置,现在可以第一次运行我们的模型来观察模型的行为。

Run the model 运行模型

1.Click the Run toolbar button.

1.单击运行工具栏按钮。

The model window will appear and the model will launch automatically. You will see the 10 building shapes randomly distributed in a 500 by 500 pixel space. This is the space size set by default. We do not need to change it as we will customize the location of the facilities.

模型窗口将出现,模型将自动启动。你将看到10个建筑形状随机分布在一个500 × 500像素的空间。这是默认设置的空间大小。我们不需要更改它,因为我们将定制设施的位置。

Now we will create 3D animation for our model. First of all we need to add 3D window to our Main diagram. The 3D window plays the role of a placeholder for 3D animation. It defines the area on the presentation diagram where 3D animation will be shown at runtime.

现在我们将为我们的模型创建3D动画。首先,我们需要在主图中添加3D窗口。3D窗口扮演3D动画占位符的角色。它定义了演示图上3D动画将在运行时显示的区域。

Add 3D window 添加三维窗口

Drag the 3D Window element from the 3D section of the Presentation palette to the graphical editor. Place the window below the model window frame.

将3D Window元素从Presentation面板的3D部分拖到图形编辑器中。将窗口放置在模型窗口框架的下方。

2.Navigate to the Properties view of the 3D window and set its Width and Height parameters to 1000 and 600 respectively.

2.导航到3D窗口的属性视图,并将其宽度和高度参数分别设置为1000和600。

Now we will run the model and switch between the 2D and 3D views in the model window.

现在,我们将运行模型,并在模型窗口的2D和3D视图之间切换。

Compare 2D and 3D views 比较2D和3D视图

Click Run in the toolbar to run the model.

单击工具栏中的Run以运行模型。

When you create a 3D window, AnyLogic adds a view area that allows you to easily navigate to the 3D view at runtime. To switch to this 3D view while the model is running, open the developer panel by clicking the Developer panel

当你创建一个3D窗口时,AnyLogic添加了一个视图区域,允许你在运行时轻松导航到3D视图。要在模型运行时切换到这个3D视图,请单击developer面板打开开发人员面板

control in the right corner of the control panel.In the developer panel, expand the
select view area to navigate list and select [window3d] from the list.

控制面板右下角的控件。在开发人员面板,展开选择视图区域导航列表,并从列表中选择[window3d]。

3.The view mode will change to 3D.

3.视图模式将更改为3D。

Draw the surface 画出表面

1.Drag a Rectangle shape from the Presentation palette onto the editor of Main, place its top left corner at (0,0).

1.将一个Rectangle形状从Presentation面板拖到Main的编辑器上,将其左上角置于(0,0)。

2.Navigate to the Position and size section of the rectangle's Properties and set its Width and Height parameters to 1000 and 600 respectively, hence the area size is 1000*600 meters.

2.导航到矩形的属性的位置和大小部分,并设置其宽度和高度参数分别为1000和600,因此区域大小为1000*600米。

3.Now set the Z and Z-Height parameters to -1 and 1 respectively.

3.现在将Z和Z- height参数分别设置为-1和1。

4.In the Appearance section of the rectangle's Properties set the Line color option to No color.

4.在矩形属性的外观部分,将线条颜色选项设置为无颜色。

5.Now we will define the texture of the rectangle area. Click the Fill color control and select Textures to open a dialog box with available textures.

5.现在我们将定义矩形区域的纹理。点击填充颜色控件并选择纹理打开一个可用纹理的对话框。

6.Click Earth texture to set it as the fill color for the rectangle shape.

6.点击地球纹理设置为矩形的填充颜色。

7.Click OK to close the dialog box. The rectangle shape will change it appearance.
Now run the model and observe the new layout both in 2D and 3D modes.

7.单击OK关闭对话框。矩形形状将改变它的外观。

现在运行模型并在2D和3D模式下观察新的布局。

Observe the new layout 观察新的布局

1.Run the model. You will observe the model in the 2D view.
As you can see, we have the new layout here but no buildings can be seen.

1.运行模型。您将在2D视图中观察该模型。

正如你所看到的,我们有了新的布局,但是没有看到建筑。

2.Switch to 3D animation scene. You can observe buildings in 3D view.

2.切换到3D动画场景。你可以在3D视图中观察建筑物。

In order to make buildings visible in the 2D view we must reorder the shapes in the design.

为了让建筑在2D视图中可见,我们必须在设计中重新排列形状。

Reorder shapes 重新排序的形状

1.Right-click the rectangle shape to open its context menu. Then click the Order menu item and select Sent to Back sub-item from the list of available orders.

1.右键单击矩形,打开它的上下文菜单。然后单击“订单”菜单项,并从可用订单列表中选择“发送回退”子项。

The 2D building shape will now be visible.

2D建筑的形状现在可以看到了。

Now the model should have correct visualization in both 2D and 3D view. Prior to running the model to check if everything works like it should, we will lock the Rectangle shape and add camera.

现在,模型在2D和3D视图中都应该具有正确的可视化。在运行模型检查是否一切正常之前,我们将锁定矩形形状并添加摄像机。

Lock the rectangle shape 锁定矩形形状

1.In the Properties view select the Lock option to lock the shape.
This will prevent occasional selection of the rectangle while working with other elements on the diagram.

1.在属性视图中选择“锁定”选项来锁定形状。

这将防止在使用图表上的其他元素时偶尔选择矩形。

Add a camera 添加相机控制

1.Drag the Camera element from the 3D section of the Presentation palette onto the graphical editor. You will see the camera icon in the graphical editor.

1.将Camera元素从Presentation面板的3D部分拖到图形编辑器上。您将在图形编辑器中看到摄像机图标。

2.Direct the camera at the buildings presentation shapes (the positioning is described in details in the Camera article).

2.将摄像机对准建筑物的呈现形状(摄像机文章中详细描述了定位)。

It is time to run the model and adjust the camera position to the desired one. We will save that position afterwards to have the camera always located at the set position.

是时候运行模型和调整相机的位置到所需的一个。我们将保存该位置之后,摄像机始终位于设置的位置。

Adjust the camera position 调整摄像机位置

1.Run the model and switch to 3D mode.

1.运行模型并切换到3D模式。

2.Right-click the 3D model presentation to open a pop-up menu. Navigate to the Camera menu item and select camera sub-item. You will switch to the camera view.

2.右键单击3D模型展示以打开弹出菜单。导航到摄像机菜单项并选择摄像机子项。你将切换到摄像机视图。

3.Position the camera to have the best possible picture while observing the model in the runtime (for more details on navigating the 3D scene refer here).

3.在运行时观察模型时,将相机放置在最佳位置(关于导航3D场景的更多细节请参考这里)。

4.When done, right-click the 3D model presentation and click Copy camera's location.

4.完成后,右键单击3D模型演示并单击复 制相机的位置。

You may stop the simulation now. We have set up our camera and copied its position, now we need to apply the new camera position.

现在可以停止模拟了。我们已经设置好了摄像机并复 制了它的位置,现在我们需要应用新的摄像机位置。

Apply new camera position 应用新的相机位置

1.Click the Camera element to open its Properties view.

1.单击Camera元素以打开其Properties视图。

2.Click the Paste coordinates from clipboard button in the Properties view. The rotation parameters will change.

2.在“属性”视图中单击“从剪贴板粘贴坐标”按钮。旋转参数将会改变。

In the last step of this phase we will create a protected area, within which the buildings will be placed. The area will further be equipped with the air defense system, eliminating the air attacks on our facilities.

在这个阶段的最后一步,我们将创建一个保护区域,建筑将放置在其中。该地区将进一步配备防空系统,消除对我们设施的空袭。

Define protected area 定义受保护的区域

1.Double-click the Polygonal Node element in the Process Modeling Library palette to activate drawing mode.

1.双击Process Modeling Library面板中的Polygonal Node元素来激活绘画模式。

2.Click on top of the rectangle to start drawing the protected area.

2.单击矩形顶部开始绘制受保护区域。

3.Finish drawing with a double-click on the last node.

3.双击最后一个节点完成绘图。

4.Navigate to the element's Properties, name it protectedArea and set its Visible parameter to no.

4.导航到元素的Properties,将其命名为protectedArea,并将其Visible参数设置为no。

We have created a new area, now we need to locate our facilities within its boundaries.

我们已经建立了一个新的区域,现在我们需要在它的边界内设置我们的设施。

Relocate the facilities 搬迁的设施

1.Click the buildings population on the Main to open the Properties view.

1.单击Main上的建筑填充,打开Properties视图。

2.Navigate to the Initial location section and set the Place agent(s) parameter to in the node. The Node parameter will appear below.

2.导航到初始位置部分,并在节点中设置Place代理参数。Node参数将出现在下面。

3.Click the set by default None value for the Node parameter and select protectedArea from the drop-down list of available nodes.

3.单击“节点”参数默认设置为“无”的值,在可选节点的下拉列表中选择protectedArea。

4.Now open the properties of Main and navigate to the Space and network section.

4.现在打开Main的属性,导航到Space和network部分。

5.Set the Layout type to User-defined.

5.设置“布局类型”为“自定义”。

Finally, we may run the model. The buildings will be located within the area defined by the polygonal node.

最后,我们可以运行模型。建筑将位于多边形节点定义的区域内。

Well done, we have completed the first phase of the Air defense system tutorial. Proceed to Phase 2.

干得好,我们已经完成了第一阶段的防空系统教程。进入第二阶段。

来源:知乎陈潜龙

仿真体系AnyLogic
著作权归作者所有,欢迎分享,未经许可,不得转载
首次发布时间:2023-06-05
最近编辑:1年前
陈潜龙
本科 致力高机动无人车
获赞 3粉丝 4文章 2课程 3
点赞
收藏
未登录
还没有评论
课程
培训
服务
行家
VIP会员 学习 福利任务 兑换礼品
下载APP
联系我们
帮助与反馈