以編程方式設置分析器模擬器分發我正在嘗試創建一個啟用了模擬器選項的Profiler,並且一些輸入具有隨機分佈。分發類型和該分佈的參數將保存為表變量,以便根據需要進行查詢。但是Profiler()函數中的JSL似乎不能識別if語句。
例如,此代碼工作正常
Profiler(
Y( :a, :b ),
Profiler(
1,
Simulator(
1,
Factors(
c << Fixed( 3.5 ),
d << Random( Normal( :dist_p1, :dist_p2 ) )
),
Resimulate
)
)
)但此代碼不會加載“d”的分發信息
Profiler(
Y( :a, :b ),
Profiler(
1,
Simulator(
1,
Factors(
c << Fixed( 3.5 ),
if(
dist_type == "Normal", d << Random( Normal( :dist_p1, :dist_p2 ) ),
dist_type == "Weibull", d << Random( Weibull( :dist_p1, :dist_p2 ) )
)
),
Resimulate
)
)
)
Re:以編程方式設置分析器模擬器分發我簡單地考慮了這種方法,但在我的真實文件中,它將復制100多行代碼9次(3個隨機變量,3種分佈類型)。它很快變得無法管理。
編輯:這與David_Burnham有關。還在學習如何使用這些論壇......
Re:以編程方式設置分析器模擬器分發好吧,如果我回到最高級別的功能(在這種情況下是Profiler)並用Eval,Substitute和Expr包裝它我可以得到我想要的行為。 這讓我感到困惑,因為我認為應首先評估if,然後將其用作其內部函數的參數,但我現在可以理解為什麼這樣做不起作用。
Eval(
Substitute(
Expr(
Profiler(
Y( :a, :b ),
Simulator(
Factors(
c << Fixed( 3.5 ),
d_
),
Resimulate
)
)
),
Expr( _d_ ),
if (:dist_type == "Normal", Parse( "d << Random( Normal( :dist_p1, :dist_p2 ))" ),
:dist_type == "Weibull", Parse( "d << Random( Weibull( :dist_p2, :dist_p1 ))" )
)
)
)Re:以編程方式設置分析器模擬器分發Profiler是一個功能。 函數內部的每個函數都應該是函數運行所需的函數參數。 所以你不能只在其中粘貼任意JSL代碼。 您需要將條件邏輯移到外面:
type = "Normal";
p1 = 3.0;
p2 = 0.5;
If (type == "Normal",
Profiler(
Y( :a, :b ),
Profiler(
1,
Simulator(
1,
Factors(
c << Fixed( 3.5 ),
d << Random( Normal( p1, p2 ) ),
),
Resimulate
)
)
)
);