Cost function in RBDO

I am working with RBDO using a PCE model. All the examples I saw have Cost functions with simple forms. Mine is a bit more complex because it includes several sequential calculations involving the decision variables and the stochastic parameters. I tried various alternatives to handle problem. One was to write a large Cost function, like this one:
RBDOOpts.Cost.mString = [
'dose = X(:,1); ’ …
'theta11 = X(:,2); ’ …
'theta12 = X(:,3); ’ …
'theta21 = X(:,4); ’ …
'theta22 = X(:,5); ’ …
'theta23 = X(:,6); ’ …
'rho = X(:,7); ’ …
'linVal1 = -(theta11 + theta12 .* dose); ’ …
'linVal2 = -(theta21 + theta22 .* dose + theta23 .* dose .^ 2); ’ …
'Y1 = 1.0 ./ (1.0 + exp(linVal1)); ’ …
'Y2 = 1.0 ./ (1.0 + exp(linVal2)); ’ …
'Z2 = Y2 - 0.5; ’ …
‘ZConst = Z2;’
];

but it does not work because of the “=”. Another strategy was using a function mHandle without much success I have to say. So, anybody has experience in using complex Cost functions?

Another problem is that I need the stochastic parameters within the Cost function In the above example only X(:,1) is a decision variable, the other 6 columns are parameters. So, how can I pass parameters into the cost function?

Hello @BPMD,

The `mString` fails because you have multiple statements and not a single expression that evaluates to a single value. Please refer to Table 8 in the manual for more information:

This forwards you to the model manual section 2.1.3:

The `mHandle` or `mFile` should work. However, it is always hard to help if you don’t provide minimal example to reproduce the problem. How did you implement the `mHandle`? Can you provide an example that we can run?

Best regards,
Styfen

Thank you, Styfen. I was able to handle it. Cheers