Optimization with constraints

Let's find the maximum of the 'Script model' from models.qsl. It is a script based model:

'script language = VBscript
function Main()
    qs_RESULT(1) = sin(qs_VAR(1)+qs_sqr(qs_VAR(1))-1)+0.5*sin(qs_sqr(qs_VAR(2)))
end function

We would be interested to find the maximum of the above function with the condition that the values of the function are less than 0. All you need to do is to add the constrain entry in the model description ('<0').

Choose Contour plots and select the script model to be both 'Model' and 'Constraint'. You can add up to 20 constraint functions. The resulting plot is:

The gray area represents the region of infeasibility, i.e. - the region where the constraint is violated. Click 'Optimize' and make the following selections:

Click 'Optimize to begin optimization. Once it is finished, click 'Return'. The results will be transferred back to the contours and you will have the options to show them on the plot. Don't forget to click 'X=Xopt' to re-plot the contours at the optimum values.

 

For two sided constraint, use two constraint entries - for example:

which produces the following plot:

Perform optimization as with the one sided example, but this time search for MINIMUM. The result is as follows:

See also