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.

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);