<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Request help with setting and maximizing desirability within a function. in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Request-help-with-setting-and-maximizing-desirability-within-a/m-p/889600#M105166</link>
    <description>&lt;P&gt;Hi Jarmo,&lt;/P&gt;
&lt;P&gt;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.&lt;/P&gt;
&lt;P&gt;Thank you again for your help!&lt;/P&gt;</description>
    <pubDate>Sat, 26 Jul 2025 18:36:31 GMT</pubDate>
    <dc:creator>DeepMink727</dc:creator>
    <dc:date>2025-07-26T18:36:31Z</dc:date>
    <item>
      <title>Request help with setting and maximizing desirability within a function.</title>
      <link>https://community.jmp.com/t5/Discussions/Request-help-with-setting-and-maximizing-desirability-within-a/m-p/889550#M105162</link>
      <description>&lt;P&gt;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.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;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!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;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.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="DeepMink727_0-1753486969540.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/78970iB03C557EFAC3B740/image-size/medium?v=v2&amp;amp;px=400" role="button" title="DeepMink727_0-1753486969540.png" alt="DeepMink727_0-1753486969540.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;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 &amp;lt;&amp;lt; 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 &amp;lt;&amp;lt; 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 &amp;lt;&amp;lt; Maximize and Remember;&lt;BR /&gt;&lt;BR /&gt;    // "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);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 25 Jul 2025 23:43:57 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Request-help-with-setting-and-maximizing-desirability-within-a/m-p/889550#M105162</guid>
      <dc:creator>DeepMink727</dc:creator>
      <dc:date>2025-07-25T23:43:57Z</dc:date>
    </item>
    <item>
      <title>Re: Request help with setting and maximizing desirability within a function.</title>
      <link>https://community.jmp.com/t5/Discussions/Request-help-with-setting-and-maximizing-desirability-within-a/m-p/889587#M105163</link>
      <description>&lt;P&gt;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&amp;nbsp;&lt;LI-MESSAGE title="JSL to fit model, maximize desirability, and extract results with user-selectable columns" uid="585547" url="https://community.jmp.com/t5/Discussions/JSL-to-fit-model-maximize-desirability-and-extract-results-with/m-p/585547#U585547" discussion_style_icon_css="lia-mention-container-editor-message lia-img-icon-forum-thread lia-fa-icon lia-fa-forum lia-fa-thread lia-fa"&gt;&lt;/LI-MESSAGE&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;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 &amp;lt;&amp;lt; Profiler(
		Y(_col_),
		_colw_ &amp;lt;&amp;lt; 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
));
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You can check the expression which is being used by just running the Substitute part without Eval&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jthi_0-1753532042719.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/78986iF56EC4F210E2676F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jthi_0-1753532042719.png" alt="jthi_0-1753532042719.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 26 Jul 2025 12:14:21 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Request-help-with-setting-and-maximizing-desirability-within-a/m-p/889587#M105163</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2025-07-26T12:14:21Z</dc:date>
    </item>
    <item>
      <title>Re: Request help with setting and maximizing desirability within a function.</title>
      <link>https://community.jmp.com/t5/Discussions/Request-help-with-setting-and-maximizing-desirability-within-a/m-p/889594#M105164</link>
      <description>&lt;P&gt;Hi Jarmo,&lt;/P&gt;
&lt;P&gt;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?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Within the profiler defined inside the function, when I do this, it works:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;"P/V (W/m^3)"n &amp;lt;&amp;lt;  Response Limits(
			{
				Goal("Match Target"),
				Importance( 1 ),
				Lower(valueOfHydyMetric*0.8, 0.0183),
				Middle(valueOfHydyMetric, 1),
				Upper(valueOfHydyMetric*1.2, 0.0183)
			}
		),&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But when I do this, it does not work&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Column (dt, HydyMetricMixing) &amp;lt;&amp;lt;  Response Limits(
			{
				Goal("Match Target"),
				Importance( 1 ),
				Lower(valueOfHydyMetric*0.8, 0.0183),
				Middle(valueOfHydyMetric, 1),
				Upper(valueOfHydyMetric*1.2, 0.0183)
			}
		),&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;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&amp;nbsp;&lt;CODE class=" language-jsl"&gt;HydyMetricMixing&lt;/CODE&gt;&amp;nbsp;is just a variable that stores the string&amp;nbsp;&lt;CODE class=" language-jsl"&gt;"P/V (W/m^3)"&lt;/CODE&gt;.&lt;/P&gt;</description>
      <pubDate>Sat, 26 Jul 2025 16:22:59 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Request-help-with-setting-and-maximizing-desirability-within-a/m-p/889594#M105164</guid>
      <dc:creator>DeepMink727</dc:creator>
      <dc:date>2025-07-26T16:22:59Z</dc:date>
    </item>
    <item>
      <title>Re: Request help with setting and maximizing desirability within a function.</title>
      <link>https://community.jmp.com/t5/Discussions/Request-help-with-setting-and-maximizing-desirability-within-a/m-p/889597#M105165</link>
      <description>&lt;P&gt;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().&amp;nbsp;No idea why it is implemented like that.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In your case because your column name requires special syntax (""n) try using As Name() instead of Parse().&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Tiretread.jmp");
Column(dt, "Pred Formula ABRASION") &amp;lt;&amp;lt; Set Name("Pred Formula ABRASION/123-");

lval = 120;
mval = 150;
uval = 190;
col = "Pred Formula ABRASION/123-";

pf = Eval(Substitute(
	Expr(dt &amp;lt;&amp;lt; Profiler(
		Y(_col_),
		_colw_ &amp;lt;&amp;lt; 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 &amp;lt;&amp;lt; Desirability Functions(1);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I suggest checking the expression you are building, with Substitute and EvalExpr it is quite easy by just running that part highlighted&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jthi_0-1753550348544.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/78994i58B3B2DDCFB97C75/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jthi_0-1753550348544.png" alt="jthi_0-1753550348544.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I will also start using that as that is much more robust and most likely the correct way to go with something like this.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 26 Jul 2025 17:19:44 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Request-help-with-setting-and-maximizing-desirability-within-a/m-p/889597#M105165</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2025-07-26T17:19:44Z</dc:date>
    </item>
    <item>
      <title>Re: Request help with setting and maximizing desirability within a function.</title>
      <link>https://community.jmp.com/t5/Discussions/Request-help-with-setting-and-maximizing-desirability-within-a/m-p/889600#M105166</link>
      <description>&lt;P&gt;Hi Jarmo,&lt;/P&gt;
&lt;P&gt;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.&lt;/P&gt;
&lt;P&gt;Thank you again for your help!&lt;/P&gt;</description>
      <pubDate>Sat, 26 Jul 2025 18:36:31 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Request-help-with-setting-and-maximizing-desirability-within-a/m-p/889600#M105166</guid>
      <dc:creator>DeepMink727</dc:creator>
      <dc:date>2025-07-26T18:36:31Z</dc:date>
    </item>
  </channel>
</rss>

