How to pass a variable in the formula of custom profilerWe can define a custom formula in the custom profiler and it is quite easy, as the following example shows
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Tiretread.jmp" );
obj = Custom Profiler( Y( :Pred Formula ABRASION, :Pred Formula MODULUS ) );
obj << Objective Formula(
:Pred Formula ABRASION + .5 * :Pred Formula MODULUS
);
obj << Optimize;
Now, let's say that I would like to change the coefficient value from 0.5 to another setting. So I define the following formula:
coef=4;
myFormula=Parse(eval(EvalExpr(":Pred Formula ABRASION + "||Char(coef)||" * :Pred Formula MODULUS")));
the result in the log is ok:
:Pred Formula ABRASION + 4 * :Pred Formula MODULUS
but, if I use the same sentence in the previous statement, I do not succeed to have the expected result:
obj << Objective Formula(Parse(eval(EvalExpr(":Pred Formula ABRASION + "||Char(coef)||" * :Pred Formula MODULUS"))));

I probably did a basic mistake, but I am having trouble with it. and I would like to adapt this method to a more complex situation (change desirability coeffcients in the native expression)
Thank you for your suggestions
Re: How to pass a variable in the formula of custom profilerFlorence,
In general, it's preferable to treat expression as expressions rather than text string to be evaluated. This will work:
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Tiretread.jmp" );
obj = Custom Profiler( Y( :Pred Formula ABRASION, :Pred Formula MODULUS ) );
cVal = 4;
Eval(Substitute(
Expr(
obj << Objective Formula(
:Pred Formula ABRASION + coefVal * :Pred Formula MODULUS
)
),
Expr(coefVal),cVal
));
obj << Optimize;
Don
Re: How to pass a variable in the formula of custom profilerHi Don,
Thank a lot for your answer.
In this basic example, it works pretty well, as my formula is simple.
In the real life, I have a more complex situation. I want to be able to set the content of desirabilities that I will catch from a data table.
y1_target_value=175;
y1_min=150;
y1_max=200;
y2_target=500;
y2_min=450;
y2_max=550;
Eval(Substitute(
Expr(
obj << Objective Formula(
Exp((0.25 * Log(Desirability([100, y1_target, 200], [0.0183, 1, 0.0183], Pred Formula Abrasion)) + 0.25 * Log(Desirability([400, 475, 550], [0.0183, 1, 0.0183], Pred Formula Elongation))) / 0.5)
)
),
Expr(y1_target),y1_target_value
));
obj << Optimize;
if I apply the substitute in this case, I have an error.

and yes.... I want to change the content of the 6 variables (target and spec for the two Y)!!
thank you for your suggestions,
Florence
Re: How to pass a variable in the formula of custom profilerFlorence,
The issue has to do with the way the matrix operator (the open and close square brackets) work. The simplest approach I can think of is to create the matrices beforehand and treat them as a whole, rather than trying to construct them in Substitute. This should work
y1_target_value=175;
y1_min=150;
y1_max=200;
y2_target=500;
y2_min=450;
y2_max=550;
y1Mat = Matrix({y1_min,y1_target_value,y1_max});
y2Mat = Matrix({y2_min,y2_target,y1_max});
Eval(Substitute(
Expr(
obj << Objective Formula(
Exp((0.25 * Log(Desirability(y1Mat, [0.0183, 1, 0.0183], Pred Formula Abrasion)) + 0.25 * Log(Desirability(y2Mat, [0.0183, 1, 0.0183], Pred Formula Elongation))) / 0.5)
)
),
Expr(y1Mat),y1Mat,
Expr(y2Mat),y2Mat,
));
obj << Optimize;
Re: How to pass a variable in the formula of custom profilerI feel like I'm missing something here. Why use the Expr/Eval, etc. instead of just putting the formula in?
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Tiretread.jmp" );
y1_target_value = 175;
y1_min = 150;
y1_max = 200;
y2_target = 500;
y2_min = 450;
y2_max = 550;
y1Mat = Matrix( {y1_min, y1_target_value, y1_max} );
y2Mat = Matrix( {y2_min, y2_target, y1_max} );
obj = Custom Profiler( Y( :Pred Formula ABRASION, :Pred Formula MODULUS ) );
obj << Objective Formula(
Exp(
(0.25 * Log( Desirability( y1Mat, [0.0183, 1, 0.0183], :Pred Formula Abrasion ) ) + 0.25 * Log(
Desirability( y2Mat, [0.0183, 1, 0.0183], :Pred Formula Elongation )
)) / 0.5
)
);
obj << Optimize;
Re: How to pass a variable in the formula of custom profilerIf you look at the expression in the Formula outline, the values for y1Mat and y2Mat appear unevaluated, i.e., as variables:
Exp((0.25 * Log(Desirability(<FONT color="#FF0000">y1Mat</FONT>, [0.0183, 1, 0.0183], :Pred Formula Abrasion)) + 0.25 * Log(Desirability(<FONT color="#FF0000">y2Mat</FONT>, [0.0183, 1, 0.0183], :Pred Formula Elongation))) / 0.5)
BTW, it looks like I had a few mistakes in the previous code. Here's the corrected version
y1_target_value=175;
y1_min=150;
y1_max=200;
y2_target=500;
y2_min=450;
y2_max=550;
y1Mat = Matrix({y1_min,y1_target_value,y1_max});
y2Mat = Matrix({y2_min,y2_target,y2_max});
Eval(Substitute(
Expr(
obj << Objective Formula(
Exp((0.25 * Log(Desirability(y1Mat, [0.0183, 1, 0.0183], :Pred Formula Abrasion)) + 0.25 * Log(Desirability(y2Mat, [0.0183, 1, 0.0183], :Pred Formula Elongation))) / 0.5)
)
),
Expr(y1Mat),y1Mat,
Expr(y2Mat),y2Mat,
));
obj << Optimize;
All this said, I'm not sure this is the way to implement different boundaries for the desirability functions. The formula appears correct, but the objective value is missing.
Re: How to pass a variable in the formula of custom profilerThank you for the tips! it works
Regarding the formula, it is the one defined by JMP when I launch the custom profiler with the prediction formula generated by Fit Model platform.
The default is the following:

with this type of prediction formula:

I will check if I have the same results than on native Model Fitting platform.
Thanks again!
Re: How to pass a variable in the formula of custom profilerThanks Florence,
I found the problem. I used ABRASION and MODULUS in Custom Profiler but used ABRASION and ELONGATION in the Objective Formula.
Here is the (hopefully) error free code:
obj = Custom Profiler( Y( :Pred Formula ABRASION, :Pred Formula MODULUS ) );
y1_target_value=175;
y1_min=150;
y1_max=200;
y2_target=500;
y2_min=450;
y2_max=550;
y1Mat = Matrix({y1_min,y1_target_value,y1_max});
y2Mat = Matrix({y2_min,y2_target,y2_max});
Eval(Substitute(
Expr(
obj << Objective Formula(
Exp((0.25 * Log(Desirability(y1Mat, [0.0183, 1, 0.0183], :Pred Formula Abrasion)) + 0.25 * Log(Desirability(y2Mat, [0.0183, 1, 0.0183], :Pred Formula Modulus))) / 0.5)
)
),
Expr(y1Mat),y1Mat,
Expr(y2Mat),y2Mat,
));
obj << Optimize;