📄 swarm.overview.mag4.schedule-swarm.sect1.html
字号:
<HTML><HEAD><TITLE>Scheduling a Model Swarm</TITLE><METANAME="GENERATOR"CONTENT="Modular DocBook HTML Stylesheet Version 1.53"><LINKREL="HOME"TITLE="Documentation Set for Swarm 2.1.1"HREF="set.html"><LINKREL="UP"TITLE="Mag 4x:Sketch of Code "HREF="swarm.overview.mag4.chapter.html"><LINKREL="PREVIOUS"TITLE="Building Space objects"HREF="swarm.overview.mag4.build-space.sect1.html"><LINKREL="NEXT"TITLE="Building a Graphical Observer Swarm"HREF="swarm.overview.mag4.build-observer.sect1.html"></HEAD><BODYCLASS="SECT1"BGCOLOR="#FFFFFF"TEXT="#000000"LINK="#0000FF"VLINK="#840084"ALINK="#0000FF"><DIVCLASS="NAVHEADER"><TABLEWIDTH="100%"BORDER="0"CELLPADDING="0"CELLSPACING="0"><TR><THCOLSPAN="3"ALIGN="center">Documentation Set for Swarm 2.1.1</TH></TR><TR><TDWIDTH="10%"ALIGN="left"VALIGN="bottom"><AHREF="swarm.overview.mag4.build-space.sect1.html">Prev</A></TD><TDWIDTH="80%"ALIGN="center"VALIGN="bottom">Chapter 4. Mag 4x:Sketch of Code</TD><TDWIDTH="10%"ALIGN="right"VALIGN="bottom"><AHREF="swarm.overview.mag4.build-observer.sect1.html">Next</A></TD></TR></TABLE><HRALIGN="LEFT"WIDTH="100%"></DIV><DIVCLASS="SECT1"><H1CLASS="SECT1"><ANAME="SWARM.OVERVIEW.MAG4.SCHEDULE-SWARM.SECT1">4.5. Scheduling a Model Swarm</A></H1><P>Once all of the simulated objects are created in <TTCLASS="LITERAL">buildObjects</TT>, the next task is to schedule them in the method <TTCLASS="LITERAL">buildActions</TT>.</P><TABLEBORDER="0"BGCOLOR="#E0E0E0"WIDTH="100%"><TR><TD><PRECLASS="PROGRAMLISTING">modelActions = [ActionGroup create: [self getZone]];[modelActions createActionTo: heat message: M(stepRule)];[modelActions createActionForEach: heatbugList message: M(step)];[modelActions createActionTo: heat message: M(updateLattice)];modelSchedule = [Schedule createBegin: [self getZone]];[modelSchedule setRepeatInterval: 1];modelSchedule = [modelSchedule createEnd];[modelSchedule at: 0 createAction: modelActions]; </PRE></TD></TR></TABLE><P>The heatbug model schedule actually consists of two components: an ActionGroup called <TTCLASS="LITERAL">modelActions</TT> and a Schedule called <TTCLASS="LITERAL">modelSchedule</TT>. The ActionGroup is a tightly coupled list of three messages: every time the action group is executed, it will send three messages in a row: <TABLEBORDER="0"BGCOLOR="#E0E0E0"WIDTH="100%"><TR><TD><PRECLASS="PROGRAMLISTING">[heat stepRule];[heatbugList forEach: step];[heat updateLattice]; </PRE></TD></TR></TABLE> The ActionGroup alone specifies three messages to send - in order to put it in the simulation, that ActionGroup is then dropped into a Schedule. The Schedule itself only has one action - to execute <TTCLASS="LITERAL">modelActions</TT> itself. That action takes place at time 0. But because we've set a repeat interval on the schedule of 1, the schedule itself loops, executing every 1 time step. The final result is that <TTCLASS="LITERAL">modelActions</TT> is executed at time 0, time 1, etc.</P></DIV><DIVCLASS="NAVFOOTER"><HRALIGN="LEFT"WIDTH="100%"><TABLEWIDTH="100%"BORDER="0"CELLPADDING="0"CELLSPACING="0"><TR><TDWIDTH="33%"ALIGN="left"VALIGN="top"><AHREF="swarm.overview.mag4.build-space.sect1.html">Prev</A></TD><TDWIDTH="34%"ALIGN="center"VALIGN="top"><AHREF="set.html">Home</A></TD><TDWIDTH="33%"ALIGN="right"VALIGN="top"><AHREF="swarm.overview.mag4.build-observer.sect1.html">Next</A></TD></TR><TR><TDWIDTH="33%"ALIGN="left"VALIGN="top">Building Space objects</TD><TDWIDTH="34%"ALIGN="center"VALIGN="top"><AHREF="swarm.overview.mag4.chapter.html">Up</A></TD><TDWIDTH="33%"ALIGN="right"VALIGN="top">Building a Graphical Observer Swarm</TD></TR></TABLE></DIV></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -