function [prob] = prob4(p)

prob = struct('n',{0},'m',{0},'bl',{0},'bu',{0},'cl',{0},'cu',{0},'obj',{0},'cons',{0},'hess',{0},'x',0,'name',0);
prob.n = 3;
prob.m = 3;
prob.me = 1;
%prob.cl = [0;p(2);p(1)];
%prob.cu = [Inf;Inf;p(1)];

prob.dcdp = [-1 0; 0 0;0 -1];

prob.name = 'Problem 1';
prob.x = zeros(3,1);

prob.obj = (@(x)(objective(x,p)));
prob.cons = (@(x)(constraint(x,p)));
prob.hess = (@(x,y)(hessian(x,y,p)));
prob.chess = (@(x)(conhess(x,p)));
end

function [f,g] = objective(x,p)

f = x(3)*x(1)^3+x(2)^2;
g=zeros(2,1);
g(2) =  2*x(2);
g(1) = 3*x(3)*x(1)^2;
g(3) = x(1)^3;
end

function [c,J] = constraint(x,p)
    c=[x(3)-p(1); x(2)-exp(-x(1));x(1)-p(2)];

    J=zeros(3,3);
    J(2,1) = exp(-x(1));
    J(2,2) = 1;
    J(3,1) = 1;
    J(1,3) = 1;

end

function [H] = hessian(x,y,p)
H=zeros(3);
y=y;
H(1,1) = x(3)*6*x(1)+y(2)*exp(-x(1));
H(1,3) = 3*x(1)^2;
H(2,2) = 2;
H(3,1) = 3*x(1)^2;
end

function HC = conhess(x,p)
HC = zeros(3,3,3);
HC(1,1,2) = -exp(-x(1));
end