以编程方式设置分析器模拟器分发我正在尝试创建一个启用了模拟器选项的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
)
)
)
);