Resource Scheduling Using MATLAB Discrete-Event System and Data Store Memory Blocks
此示例显示如何使用MATLAB离散事件系统块和数据存储存储块之间的数据交换来建立资源调度。
该示例模拟生成两种类型的设施,Part A
andPart B
,经过加热过程。两个部分从相同资源池中获取用于加热过程的资源。资源收购Part A
优先级更高。什么时候Part A
获取一定数量的资源,Part B
可以只收购1
资源。该约束要求基于共享数据的进程和采集之间共享资源总数。
模型描述
在模型中,实体生成器块生成类型的实体Parta.
。The parts are then sent to a storage unit to acquire resources from the Resource Pool block. A MATLAB Discrete-Event System Block that uses the园艺
System Object™表示存储单元。
系统对象™定义了获取的资源和资源采集事件的量Part A
。
function[实体,事件] = partaEntry(OBJ,存储,实体,来源)%将所获取的资源的量定义为随机值。Amount = randi([1 3]); resReq = obj.resourceSpecification('Resources', 数量);%定义了资源采集事件。event = obj.eventAcquireResource(resReq,'resourceacq');结尾
什么时候Part A
成功获得资源,实体forwarded to the output.TotalAcquiredByPartA
存储在数据存储存储块中的数据,表示所获取的资源总数Part A
。系统对象™首先调用数据存储中存储的值A.它更新并写入新的TotalAcquiredByPartA
通过添加所获取的资源数量来值。
function[实体,事件] = resourceacquired(obj,存储,......实体,资源,标签)全球的TotalacquiredByparta;成功资源获取后%,转发实体% to the output |1|.Events = Obj.EventForward('输出', 1, obj.Delay);%更新总数of resources acquired.TotalAcquiredByPartA = TotalAcquiredByPartA + resources.amount;结尾
该部分被发送到加热处理A,其由实体服务器块表示。当加热过程完成时,该部件释放了所获取的资源并离开设施。
在该模型中,另一个实体生成器块生成类型的实体Part B
。The parts are then sent to a storage unit to acquire resources from the Resource Pool block. A MATLAB Discrete-Event System Block that uses thePartbstorage
System Object™ represents the other storage unit.
系统对象™定义了获取的资源和资源采集事件的量Part B
。
function[实体,事件] = partBentry(OBJ,存储,实体,来源)全球的TotalacquiredByparta;如果由A部分获得的资源数量大于% 30 then Part B acquires only |1| resource.如果TotalAcquiredByparta> 30类= 1;别的% Otherwise, Part B can acquire any number of resources between%| 1 |和| 5 |。金额= randi([1 5]);结尾RESREQ = obj.resourcespecification('Resources', 数量);% Define the resurce acquisition event.event = obj.eventAcquireResource(resReq,'resourceacq');结尾
资源量Part B
收购取决于所获得的资源Part A
。此次收购是通过的Partbstorage
系统对象™读取值TotalAcquiredByPartA
stored in Data Store A for each entity entry.
在成功获取资源后,实体已转发给输出。系统对象(TM)更新TotalAcquiredByPartB
并将其新值写入数据存储B.
function[实体,事件] = resourceacquired(obj,存储,......实体,资源,标签)全球的TotalAcquiredByptB;% After succesful resource收购,前进这entity到这output.事件=obj.Eventforward('输出', 1, obj.Delay);%更新总数ofresources获得。TotalAcquiredByPartB=TotalAcquiredByPartB+资源。结尾
Then the parts are sent to Heating Process B. They release the resources after the process is complete and depart the facility.
跟踪模型中的资源组件,跟踪可用资源并按每个部分获取的资源数量。可用资源由可用金额,有用资源池块的统计信息。收购资源Part A
andPart B
通过数据存储读取块的输出观察到从数据存储A和数据存储B读取值的块。
仿真结果
模拟模型。观察连接到数据存储的范围块读取部分A.范围显示Part A
收购30.
仿真时间周围的资源40
。
还要观察到数据存储的范围块读取部分B.范围显示Part B
收购1
resource after the simulation time40
due to the prioritization of resources.