# Problem with soft constraints in RBDO

Hello everyone
Following my previous questions on implementing the RBDO problem, I have trouble defining soft constraints.
We know that in an optimization problem, in addition to the inequality constraints, there are also equality constraints. But I don’t know how to define such constraints?
Also, in one of my soft constraints, the MATLAB max function is used, but there is a problem with this part when running the program.
I have attached the MATLAB codes and I have specified these constraints in “uq_RubBreakwat_SoftCon.m” as comments.

Does anyone have a suggestion to solve this problem?
The zip version of all code files is also attached.
RBDO.zip (3.6 KB)

Unfortunately equality constraints are not supported in the current version of the RBDO module. I would however suggest the following two options:

1. Define two inequality constraints to form an equalitiy one e.g. X <= a and X >= a. I am not sure if the algorithm would perform well with such a trick though. It’s probably not the best approach but may be it will help.
2. Alternatively, I would suggest you hard-code your equality constraints in UQLab. If you are using an `fmincon`-based solver, you can go in the file uq_matlabnonlconwrapper.m and add the constraint directly at the end of the file. At line 67, you will see
`ceq = [];`
You can then write your equality soft constraints there a few lines above and save the result (as a row vector if you have many) in the variable `ceq` which will then be carried out in `fmincon` as equality constraint.

Regarding the max constraint, I am not sure what you actually tried to achieve. Your max constraint has three arguments, two of which are constant. So you can simply remove the smallest of the two:
This
`Y(:,17) = max(2 .* X(:,13), 0.4 * 4.91, 3 * 0.384) - X(:,9)`
becomes this
`Y(:,17) = max(2 .* X(:,13), 0.4 * 4.91) - X(:,9)`
… or may be I am mistaken you were trying to do something else. In any case, the `max` function does not take three arguments. If you have more than two arguments, you need to put everything in a single matrix and then use the max operator in the appropriate dimension.

Cheers,
Moustapha

1 Like

Dear @moustapha

As always, your solutions are very effective.
I checked the first proposed solution and the answers were obtained with a very good approximation.

Thank you very much.

1 Like