MATLAB: Optimization function based on different domain of optimized variables

optimizationOptimization Toolbox

Hello,
I have an linear objective function f(x1,x2,x3.. ) which is defined for a fixed domain of x1 say x1< (constant k). Also the objective function changes to g(x1,x2,x3 … ) if x1> (constant k). The objective function in both the cases is linear. x1,x2,x3 are the optimization variables. There are set of other equality and inquality constraints on the other variables.
I was trying to solve this optimization problem using linprog .
How can I switch the optimization function based on the domain of x1? Can I iterate over the current value of x1 and check if it is less than that constant in 'linprog' solver and accordingly select the optimization function f or g?

Best Answer

Solve the problem twice, once with the constraint x1<=k and once with x1>=k, imposing the appropriate objective function in each case. Whichever of the solutions gives the best objective function value wins.