cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • Register to attend Discovery Summit 2025 Online: Early Users Edition, Sept. 24-25.
  • New JMP features coming to desktops everywhere this September. Sign up to learn more at jmp.com/launch.
Choose Language Hide Translation Bar
DeepMink727
Level I

Request help with setting and maximizing desirability within a function.

Hello all, I am trying to write a function that tries to hit a user-specified target value in a piece of equipment. The arguments supplied are the name of the target metric that needs to be matched, the value that needs to be matched, name of the equipment and weight of the targeted equipment.

 

I hope to do this by setting desirability curves using response limits and match target. I tested that the code works when I specify the column and outside of the function as a standalone code snippet. Now that I'm trying to wrap this in a function, the specific part of the code that sets the response limits, doesn't work. Can someone help me identify what I'm doing wrong? Thank you!

 

The graphical output I'm getting is as follows. The required response metric, factor values and the locks work great but the desirability curve is not changing.

 

DeepMink727_0-1753486969540.png

 

 

 

dt = currentdatatable();

// FindMatchingAgiSpeed is a function that finds the agitation speed in Brx_B that will 
// match the hydrodynamic quantity requested as the input
FindMatchingAgiSpeed = Function( {dt, HydyMetricMixing, valueOfHydyMetric, Brx_Name_B, Brx_Volume_B},
	
    // HydyMetricMixing is a string and can be either "P/V (W/m^3)" or "Top 10% EDR (W/kg)" or "Tip Speed (m/s)" and so on
	// valueOfHydyMetric is a float that is the value of the chosen HydyMetricMixing that we want to achieve in Brx_B
	// Brx_Name_B is a string which is our target production bioreactor we want to find the agitation setpoint for
	// Brx_Volume_B is the amount of liquid in the bioreactor

	HydyMetricMixing_col = Column (dt, HydyMetricMixing);

	// this part of the code works perfectly
	profiler = dt << Profiler(
		Y( HydyMetricMixing_col ),

		Confidence Intervals( 1 ),
		Desirability Functions( 1 ),

		Term Value(
			:"Bioreactor"n( Brx_Name_B, Lock( 1 ), Show( 1 ) ),
			:"Volume (L)"n( Brx_Volume_B, Lock( 1 ), Show( 1 ) ),
			:"Agitation (RPM)"n(50, Min(12), Max(263), Lock(0), Show(1))
		),
	);

	// This part of the code does not work at all
	profiler << Response Limits(
		Eval( Parse( ":" || Char(HydyMetricMixing) ) ), // Convert string to symbol
		{
			Lower( valueOfHydyMetric*0.8, 0.0183 ),
			Middle( valueOfHydyMetric, 1 ),
			Upper( valueOfHydyMetric*1.2, 0.0183 ),
			Goal( "Target" ), Importance( 1 )
		}
	);

	// Maximize desirability
	profiler << Maximize and Remember;

// "Agitation (RPM)" obtained after maximization is the result we want to return from this function ); // call the function to find the optimized value FindMatchingAgiSpeed(dt, "P/V (W/m^3)", 93.0, "SSB_10kL_ABEC", 9000);

 

 

2 ACCEPTED SOLUTIONS

Accepted Solutions
jthi
Super User

Re: Request help with setting and maximizing desirability within a function.

Not sure how you would use response limits in this way, separate from Profiler as documentation is lacking and those chosen syntax is in my opinion quite bad... I know you can build the whole Profiler expression and include the response limits to that. Other option would be to utilize response limit column property but I think these have to be set before running Profiler. Looking at your function building it into the Profiler should be fine, this post does provide the basic idea JSL to fit model, maximize desirability, and extract results with user-selectable columns 

Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Tiretread.jmp");

lval = 150;
mval = 200;
uval = 300;
col = "Pred Formula ABRASION";

pf = Eval(Substitute(
	Expr(dt << Profiler(
		Y(_col_),
		_colw_ << Response Limits(
			{Lower(_lval_, 0.9819), Middle(_mval_, 0.5), Upper(_uval_, 0.066),
			Goal(Maximize), Importance(1)}
		)
	)),
	Expr(_col_), Name Expr(As Column(dt, col)),
	Expr(_colw_), Parse(col),
	Expr(_lval_), lval,
	Expr(_mval_), mval,
	Expr(_uval_), uval
));

You can check the expression which is being used by just running the Substitute part without Eval

jthi_0-1753532042719.png

 

-Jarmo

View solution in original post

jthi
Super User

Re: Request help with setting and maximizing desirability within a function.

Response limits are not really being sent to a column but to a JMP name. That is why I use Parse() and not Column()/AsColumn(). No idea why it is implemented like that.

 

In your case because your column name requires special syntax (""n) try using As Name() instead of Parse().

Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Tiretread.jmp");
Column(dt, "Pred Formula ABRASION") << Set Name("Pred Formula ABRASION/123-");

lval = 120;
mval = 150;
uval = 190;
col = "Pred Formula ABRASION/123-";

pf = Eval(Substitute(
	Expr(dt << Profiler(
		Y(_col_),
		_colw_ << Response Limits(
			{Lower(_lval_, 0.9819), Middle(_mval_, 0.5), Upper(_uval_, 0.066),
			Goal(Maximize), Importance(1)}
		)
	)),
	Expr(_col_), Name Expr(As Column(dt, col)),
	Expr(_colw_), As Name(col),
	Expr(_lval_), lval,
	Expr(_mval_), mval,
	Expr(_uval_), uval
));
pf << Desirability Functions(1);

I suggest checking the expression you are building, with Substitute and EvalExpr it is quite easy by just running that part highlighted

jthi_0-1753550348544.png

 

I will also start using that as that is much more robust and most likely the correct way to go with something like this.

 

-Jarmo

View solution in original post

4 REPLIES 4
jthi
Super User

Re: Request help with setting and maximizing desirability within a function.

Not sure how you would use response limits in this way, separate from Profiler as documentation is lacking and those chosen syntax is in my opinion quite bad... I know you can build the whole Profiler expression and include the response limits to that. Other option would be to utilize response limit column property but I think these have to be set before running Profiler. Looking at your function building it into the Profiler should be fine, this post does provide the basic idea JSL to fit model, maximize desirability, and extract results with user-selectable columns 

Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Tiretread.jmp");

lval = 150;
mval = 200;
uval = 300;
col = "Pred Formula ABRASION";

pf = Eval(Substitute(
	Expr(dt << Profiler(
		Y(_col_),
		_colw_ << Response Limits(
			{Lower(_lval_, 0.9819), Middle(_mval_, 0.5), Upper(_uval_, 0.066),
			Goal(Maximize), Importance(1)}
		)
	)),
	Expr(_col_), Name Expr(As Column(dt, col)),
	Expr(_colw_), Parse(col),
	Expr(_lval_), lval,
	Expr(_mval_), mval,
	Expr(_uval_), uval
));

You can check the expression which is being used by just running the Substitute part without Eval

jthi_0-1753532042719.png

 

-Jarmo
DeepMink727
Level I

Re: Request help with setting and maximizing desirability within a function.

Hi Jarmo,

Thank you for your suggestion. I will rewrite the profiler like you suggested. However, something is still bugging me regarding the syntax. I rewrote my function to set "Response Limits" within the profile instead of a separate step.It still does not work. But if I replace the column variable name and hard code it with the column name, it works. Could you share what I might be doing incorrectly?

 

Within the profiler defined inside the function, when I do this, it works:

"P/V (W/m^3)"n <<  Response Limits(
			{
				Goal("Match Target"),
				Importance( 1 ),
				Lower(valueOfHydyMetric*0.8, 0.0183),
				Middle(valueOfHydyMetric, 1),
				Upper(valueOfHydyMetric*1.2, 0.0183)
			}
		),

But when I do this, it does not work

Column (dt, HydyMetricMixing) <<  Response Limits(
			{
				Goal("Match Target"),
				Importance( 1 ),
				Lower(valueOfHydyMetric*0.8, 0.0183),
				Middle(valueOfHydyMetric, 1),
				Upper(valueOfHydyMetric*1.2, 0.0183)
			}
		),

I tried everything, parsing, eval, expr, etc. I just want the column name stored as a string to work with the Response Limits message. Here HydyMetricMixing is just a variable that stores the string "P/V (W/m^3)".

jthi
Super User

Re: Request help with setting and maximizing desirability within a function.

Response limits are not really being sent to a column but to a JMP name. That is why I use Parse() and not Column()/AsColumn(). No idea why it is implemented like that.

 

In your case because your column name requires special syntax (""n) try using As Name() instead of Parse().

Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Tiretread.jmp");
Column(dt, "Pred Formula ABRASION") << Set Name("Pred Formula ABRASION/123-");

lval = 120;
mval = 150;
uval = 190;
col = "Pred Formula ABRASION/123-";

pf = Eval(Substitute(
	Expr(dt << Profiler(
		Y(_col_),
		_colw_ << Response Limits(
			{Lower(_lval_, 0.9819), Middle(_mval_, 0.5), Upper(_uval_, 0.066),
			Goal(Maximize), Importance(1)}
		)
	)),
	Expr(_col_), Name Expr(As Column(dt, col)),
	Expr(_colw_), As Name(col),
	Expr(_lval_), lval,
	Expr(_mval_), mval,
	Expr(_uval_), uval
));
pf << Desirability Functions(1);

I suggest checking the expression you are building, with Substitute and EvalExpr it is quite easy by just running that part highlighted

jthi_0-1753550348544.png

 

I will also start using that as that is much more robust and most likely the correct way to go with something like this.

 

-Jarmo
DeepMink727
Level I

Re: Request help with setting and maximizing desirability within a function.

Hi Jarmo,

That worked perfectly! Changing Parse() to As Name() fixed everything and now correctly assigns the name string stored in the variable as the column to which the Response Limits must be passed to.

Thank you again for your help!

Recommended Articles