summaryrefslogtreecommitdiff
path: root/tests/general_tests/fmincon/fmincon_logical13.sce
blob: 5c1246cddd572e6a766d32ead2cb11c12b685874 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
// Example with objective function and inequality constraints

function y=fun(x)
    y=-sum(exp(x));
endfunction

x0 = repmat(1,1,20);
lb = repmat(0,1,20);

//Nonlinear constraints
function [c,ceq]=nlc(x)
c = [- 0.5*exp(x(1)) - 2.5*exp(x(2)) - 1.5*exp(x(3)) + 50];
ceq = [];
endfunction

[xopt,fopt,exitflag,output,lambda,gradient,hessian] = fmincon (fun, x0,[],[],[],[],lb,[],nlc)