anylogic傳染病代碼.doc_第1頁
anylogic傳染病代碼.doc_第2頁
anylogic傳染病代碼.doc_第3頁
anylogic傳染病代碼.doc_第4頁
anylogic傳染病代碼.doc_第5頁
已閱讀5頁,還剩30頁未讀 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報或認(rèn)領(lǐng)

文檔簡介

Main.java代碼package 傳染病;import java.sql.Connection;import java.sql.SQLException;import java.util.ArrayList;import java.util.Arrays;import java.util.Calendar;import java.util.Collection;import java.util.Collections;import java.util.Comparator;import java.util.Currency;import java.util.Date;import java.util.Enumeration;import java.util.HashMap;import java.util.HashSet;import java.util.Hashtable;import java.util.Iterator;import java.util.LinkedList;import java.util.List;import java.util.ListIterator;import java.util.Locale;import java.util.Map;import java.util.Random;import java.util.Set;import java.util.SortedMap;import java.util.SortedSet;import java.util.Stack;import java.util.Timer;import java.util.TreeMap;import java.util.TreeSet;import java.util.Vector;import java.awt.Color;import java.awt.Font;import java.awt.Graphics2D;import java.awt.geom.AffineTransform;import static java.lang.Math.*;import static com.xj.anylogic.engine.presentation.UtilitiesColor.*;import static com.xj.anylogic.engine.presentation.UtilitiesDrawing.*;import static com.xj.anylogic.engine.HyperArray.*;import com.xj.anylogic.engine.*;import com.xj.anylogic.engine.analysis.*;import com.xj.anylogic.engine.connectivity.*;import com.xj.anylogic.engine.connectivity.ResultSet;import com.xj.anylogic.engine.connectivity.Statement;import com.xj.anylogic.engine.presentation.*;import java.awt.geom.Arc2D;public class Main extends ActiveObject / 參數(shù) public double ContactRate; /* * 返回參數(shù)ContactRate的默認(rèn)值。 * 此方法不應(yīng)該被用戶調(diào)用 */ public double _ContactRate_DefaultValue_xjal() final Main self = this; return 5 ; public void set_ContactRate( double ContactRate ) if (ContactRate = this.ContactRate) return; double _oldValue_xjal = this.ContactRate; this.ContactRate = ContactRate; onChange_ContactRate_xjal( _oldValue_xjal ); onChange(); /* * Calls On change action for parameter ContactRate. * Note that oldValue in that action will be unavailable if this method is called by user * (current parameter value will be passed as oldValue). * Please call set_ContactRate() method instead. */ void onChange_ContactRate() onChange_ContactRate_xjal( ContactRate ); void onChange_ContactRate_xjal( double oldValue ) public double Infectivity; /* * 返回參數(shù)Infectivity的默認(rèn)值。 * 此方法不應(yīng)該被用戶調(diào)用 */ public double _Infectivity_DefaultValue_xjal() final Main self = this; return 0.05 ; public void set_Infectivity( double Infectivity ) if (Infectivity = this.Infectivity) return; double _oldValue_xjal = this.Infectivity; this.Infectivity = Infectivity; onChange_Infectivity_xjal( _oldValue_xjal ); onChange(); /* * Calls On change action for parameter Infectivity. * Note that oldValue in that action will be unavailable if this method is called by user * (current parameter value will be passed as oldValue). * Please call set_Infectivity() method instead. */ void onChange_Infectivity() onChange_Infectivity_xjal( Infectivity ); void onChange_Infectivity_xjal( double oldValue ) public double TotalPopulation; /* * 返回參數(shù)TotalPopulation的默認(rèn)值。 * 此方法不應(yīng)該被用戶調(diào)用 */ public double _TotalPopulation_DefaultValue_xjal() final Main self = this; return 1000 ; public void set_TotalPopulation( double TotalPopulation ) if (TotalPopulation = this.TotalPopulation) return; double _oldValue_xjal = this.TotalPopulation; this.TotalPopulation = TotalPopulation; onChange_TotalPopulation_xjal( _oldValue_xjal ); onChange(); /* * Calls On change action for parameter TotalPopulation. * Note that oldValue in that action will be unavailable if this method is called by user * (current parameter value will be passed as oldValue). * Please call set_TotalPopulation() method instead. */ void onChange_TotalPopulation() onChange_TotalPopulation_xjal( TotalPopulation ); void onChange_TotalPopulation_xjal( double oldValue ) public double AverageIllnessDuration; /* * 返回參數(shù)AverageIllnessDuration的默認(rèn)值。 * 此方法不應(yīng)該被用戶調(diào)用 */ public double _AverageIllnessDuration_DefaultValue_xjal() final Main self = this; return 15 ; public void set_AverageIllnessDuration( double AverageIllnessDuration ) if (AverageIllnessDuration = this.AverageIllnessDuration) return; double _oldValue_xjal = this.AverageIllnessDuration; this.AverageIllnessDuration = AverageIllnessDuration; onChange_AverageIllnessDuration_xjal( _oldValue_xjal ); onChange(); /* * Calls On change action for parameter AverageIllnessDuration. * Note that oldValue in that action will be unavailable if this method is called by user * (current parameter value will be passed as oldValue). * Please call set_AverageIllnessDuration() method instead. */ void onChange_AverageIllnessDuration() onChange_AverageIllnessDuration_xjal( AverageIllnessDuration ); void onChange_AverageIllnessDuration_xjal( double oldValue ) Override public void setParametersToDefaultValues() super.setParametersToDefaultValues(); ContactRate = _ContactRate_DefaultValue_xjal(); Infectivity = _Infectivity_DefaultValue_xjal(); TotalPopulation = _TotalPopulation_DefaultValue_xjal(); AverageIllnessDuration = _AverageIllnessDuration_DefaultValue_xjal(); / 動態(tài)(流/輔助/存)變量 public double InfectionRate; public double RecoveryRate; public double Susceptible; public double Infectious; public double Recovered; /* * 寫入模型變量到給定數(shù)組 */ public void getScalarPhaseVector_xjal(double _d, double _a) _d0 = Susceptible; _d1 = Infectious; _d2 = Recovered; /* * 給定數(shù)組寫入到模型變量 */ public void putScalarPhaseVector_xjal(double _d, double _a) Susceptible = _d0; Infectious = _d1; Recovered = _d2; public void assignInitialConditions_xjal() _assign_Susceptible_Formula_xjal(); _assign_Infectious_Formula_xjal(); _assign_InfectionRate_Formula_xjal(); _assign_RecoveryRate_Formula_xjal(); _assign_Recovered_Formula_xjal(); public void _assign_Susceptible_Formula_xjal() Susceptible = TotalPopulation-1 ; public void _assign_Infectious_Formula_xjal() Infectious = 1 ; public void _assign_InfectionRate_Formula_xjal() InfectionRate = Infectious * ContactRate * Susceptible / TotalPopulation * Infectivity ; public void _assign_RecoveryRate_Formula_xjal() RecoveryRate = Infectious / AverageIllnessDuration ; public void _assign_Recovered_Formula_xjal() Recovered = 0 ; public void formulasExecute_xjal() _assign_InfectionRate_Formula_xjal(); _assign_RecoveryRate_Formula_xjal(); public void getScalarRightPart_xjal( double _dr, double _ar ) _get_Susceptible_Derivative_xjal( _dr, 0 ); _get_Infectious_Derivative_xjal( _dr, 1 ); _get_Recovered_Derivative_xjal( _dr, 2 ); public void _get_Susceptible_Derivative_xjal( double _dr, int startIndex ) _dr startIndex = -InfectionRate ; public void _get_Infectious_Derivative_xjal( double _dr, int startIndex ) _dr startIndex = InfectionRate - RecoveryRate ; public void _get_Recovered_Derivative_xjal( double _dr, int startIndex ) _dr startIndex = +RecoveryRate ; static ActiveObjectIntegrationManager integrationManager_xjal = new ActiveObjectIntegrationManager( 3, 0, 2 ); public ActiveObjectIntegrationManager getIntegrationManager_xjal() return integrationManager_xjal; / 事件 public EventTimeout _InfectiousDS_autoUpdateEvent_xjal = new EventTimeout(this); public EventTimeout _chartstack_autoUpdateEvent_xjal = new EventTimeout(this); public EventTimeout _chart_autoUpdateEvent_xjal = new EventTimeout(this); public EventTimeout _autoCreatedDS_xjal = new EventTimeout(this); Override public String getNameOf( EventTimeout _e ) if ( _e = _InfectiousDS_autoUpdateEvent_xjal ) return InfectiousDS auto update event; if ( _e = _chartstack_autoUpdateEvent_xjal ) return chartstack auto update event; if ( _e = _chart_autoUpdateEvent_xjal ) return chart auto update event; if ( _e = _autoCreatedDS_xjal ) return Auto-created DataSets auto update event; return super.getNameOf( _e ); Override public int getModeOf( EventTimeout _e ) if ( _e = _InfectiousDS_autoUpdateEvent_xjal ) return EVENT_TIMEOUT_MODE_CYCLIC; if ( _e = _chartstack_autoUpdateEvent_xjal ) return EVENT_TIMEOUT_MODE_CYCLIC; if ( _e = _chart_autoUpdateEvent_xjal ) return EVENT_TIMEOUT_MODE_CYCLIC; if ( _e = _autoCreatedDS_xjal ) return EVENT_TIMEOUT_MODE_CYCLIC; return super.getModeOf( _e ); Override public double getFirstOccurrenceTime( EventTimeout _e ) if ( _e = _InfectiousDS_autoUpdateEvent_xjal | _e = _chartstack_autoUpdateEvent_xjal | _e = _chart_autoUpdateEvent_xjal | _e = _autoCreatedDS_xjal ) return getEngine().getStartTime(); return super.getFirstOccurrenceTime( _e ); Override public double evaluateTimeoutOf( EventTimeout _e ) if ( _e = _InfectiousDS_autoUpdateEvent_xjal ) return 1 ; if ( _e = _chartstack_autoUpdateEvent_xjal ) return 1 ; if ( _e = _chart_autoUpdateEvent_xjal ) return 1 ; if ( _e = _autoCreatedDS_xjal ) return 1 ; return super.evaluateTimeoutOf( _e ); Override public void executeActionOf( EventTimeout _e ) if ( _e = _InfectiousDS_autoUpdateEvent_xjal ) InfectiousDS.update(); return; if ( _e = _chartstack_autoUpdateEvent_xjal ) chartstack.updateData(); return; if ( _e = _chart_autoUpdateEvent_xjal ) chart.updateData(); return; if ( _e = _autoCreatedDS_xjal ) _ds_InfectionRate.update(); _ds_RecoveryRate.update(); _ds_Susceptible.update(); _ds_Infectious.update(); _ds_Recovered.update(); return; super.executeActionOf( _e ); / 分析數(shù)據(jù)元素 /* * InfectionRate的自動創(chuàng)建的數(shù)據(jù)集 */ public DataSet _ds_InfectionRate = new DataSet( 100, new DataUpdater() double _lastUpdateTime = Double.NaN; Override public void update( DataSet _d ) if ( time() = _lastUpdateTime ) return; _d.add( time(), Main.this.InfectionRate ); _lastUpdateTime = time(); /* * 這個數(shù)字在這里是出于模型快照存儲的目的 */ private static final long serialVersionUID = 1366444374273L; ); /* * RecoveryRate的自動創(chuàng)建的數(shù)據(jù)集 */ public DataSet _ds_RecoveryRate = new DataSet( 100, new DataUpdater() double _lastUpdateTime = Double.NaN; Override public void update( DataSet _d ) if ( time() = _lastUpdateTime ) return; _d.add( time(), Main.this.RecoveryRate ); _lastUpdateTime = time(); /* * 這個數(shù)字在這里是出于模型快照存儲的目的 */ private static final long serialVersionUID = 1366444382104L; ); /* * Susceptible的自動創(chuàng)建的數(shù)據(jù)集 */ public DataSet _ds_Susceptible = new DataSet( 100, new DataUpdater() double _lastUpdateTime = Double.NaN; Override public void update( DataSet _d ) if ( time() = _lastUpdateTime ) return; _d.add( time(), Main.this.Susceptible ); _lastUpdateTime = time(); /* * 這個數(shù)字在這里是出于模型快照存儲的目的 */ private static final long serialVersionUID = 1366444010315L; ); /* * Infectious的自動創(chuàng)建的數(shù)據(jù)集 */ public DataSet _ds_Infectious = new DataSet( 100, new DataUpdater() double _lastUpdateTime = Double.NaN; Override public void update( DataSet _d ) if ( time() = _lastUpdateTime ) return; _d.add( time(), Main.this.Infectious ); _lastUpdateTime = time(); /* * 這個數(shù)字在這里是出于模型快照存儲的目的 */ private static final long serialVersionUID = 1366444014230L; ); /* * Recovered的自動創(chuàng)建的數(shù)據(jù)集 */ public DataSet _ds_Recovered = new DataSet( 100, new DataUpdater() double _lastUpdateTime = Double.NaN; Override public void update( DataSet _d ) if ( time() = _lastUpdateTime ) return; _d.add( time(), Main.this.Recovered ); _lastUpdateTime = time(); /* * 這個數(shù)字在這里是出于模型快照存儲的目的 */ private static final long serialVersionUID = 1366444022405L; ); public DataSet _chartstack_expression0_dataSet_xjal = new DataSet( 101, new DataUpdater() double _lastUpdateX = Double.NaN; Override public void update( DataSet _d ) if ( time() = _lastUpdateX ) return; double _a = Susceptible ; _d.add( time(), _a ); _lastUpdateX = time(); /* * 這個數(shù)字在這里是出于模型快照存儲的目的 */ private static final long serialVersionUID = 0L; ); public DataSet _chartstack_expression1_dataSet_xjal = new DataSet( 101, new DataUpdater() double _lastUpdateX = Double.NaN; Override public void update( DataSet _d ) if ( time() = _lastUpdateX ) return; double _a = Infectious ; _d.add( time(), _a ); _lastUpdateX = time(); /* * 這個數(shù)字在這里是出于模型快照存儲的目的 */ private static final long serialVersionUID = 0L; ); public DataSet _chartstack_expression2_dataSet_xjal = new DataSet( 101, new DataUpdater() double _lastUpdateX = Double.NaN; Override public void update( DataSet _d ) if ( time() = _lastUpdateX ) return; double _a = Recovered ; _d.add( time(), _a ); _lastUpdateX = time(); /* * 這個數(shù)字在這里是出于模型快照存儲的目的 */ private static final long serialVersionUID = 0L; ); public DataSet InfectiousDS = new DataSet( 101, new DataUpdater() double _lastUpdateX = Double.NaN; Override public void update( DataSet _d ) if ( time() = _lastUpdateX ) return; _d.add( time(), _InfectiousDS_YValue() ); _lastUpdateX = time(); Override public double getDataXValue() return time(); /* * 這個數(shù)字在這里是出于模型快照存儲的目的 */ private static final long serialVersionUID = 1366444624501L; ); /* * 此方法不應(yīng)該被用戶調(diào)用 */ private double _InfectiousDS_YValue() return Infectious ; / 視圖區(qū)域 public ViewArea _origin_VA = new ViewArea( this, 原點(diǎn), 0, 0, ViewArea.TOP_LEFT, ViewArea.SPECIFIED_ZOOM, 1, 100, 100 ); Override public int getViewAreas(Map _output) if ( _output != null ) _output.put( _origin_VA, this._origin_VA ); return 1 + super.getViewAreas( _output ); static final Font _button_Font = new Font(Dialog, 0, 11 ); static final Font _text_Font = new Font(SansSerif, 1, 12 ); static final int _button = 1; static final int _rectangle = 2; static final int _roundRectangle = 3; static final int _roundRectangle1 = 4; static final int _roundRectangle2 = 5; static final int _roundRectangle3 = 6; static final int _text = 7; static final int _line = 8; static final int _chartstack = 9; static final int _chart = 10; /* * 最高層演示組編號 */ static final int _presentation = 0; /* * 最高層圖標(biāo)組編號 */ static final int _icon = -1; Override public void executeShapeControlAction( int _shape, int index ) switch( _shape ) case _button: TimePlot plot = (Simulation)getEngine().getExperiment().plot;plot.addDataSet( InfectiousDS,Infectious when CR = + ContactRate + Inf = + Infectivity + AID = + AverageIllnessDuration,spectrumColor( plot.getCount(), 5 ), true, Chart.INTERPOLATION_LINEAR, 1, Chart.POINT_NONE );getEngine().getExperiment().stop(); ; break; default: super.executeShapeControlAction( _shape, index ); break; /* * 此方法不應(yīng)該被用戶調(diào)用 */ private double _chart_DataItem0Value() return Susceptible ; /* * 此方法不應(yīng)該被用戶調(diào)用 */ private double _chart_DataItem1Value() return Infectious ; /* * 此方法不應(yīng)該被用戶調(diào)用 */ private double _chart_DataItem2Value() return Recovered ; ShapeButton button; TimeStackChart chartstack; PieChart chart; ShapeRectangle rectangle; ShapeRoundedRectangle roundRectangle; ShapeRoundedRectangle roundRectangle1; ShapeRoundedRectangle roundRectangle2; ShapeRoundedRectangle roundRectangle3; ShapeText text; ShapeLine line; / 持久元素的靜態(tài)初始化 button = new ShapeButton(Main.this, true, 670, 370, 160, 30, controlDefault, controlDefault, _button_Font, Save results and Finish ) Override public void action() executeShapeControlAction( _button, 0 ); /* * 這個數(shù)字在這里是出于模型快照存儲的目的 */ private static final long serialVersionUID = 1368238823059L; ;

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論