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

function y=fun(x)
    y=0
    for i = 1:20
       y = y + exp(x(i)) 
    end
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)