function [prob] = mftomfaddconprob(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 = 7;
prob.me = 1;
%prob.cl = [0;p(2);p(1)];
%prob.cu = [Inf;Inf;p(1)];

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

prob.name = 'MFCQ to MFCQ active set change';
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 =-exp(x(2))+.5*(x(1)-x(3))^2;
g=zeros(3,1);
g(1) = (x(1)-x(3));
g(2) = -exp(x(2));
g(3) = -(x(1)-x(3));
end

function [c,J] = constraint(x,p)
    c=[x(3)-p(1);x(1)-x(2);p(1)-x(2);-x(1)-x(2)+2*p(1);5-x(1);.5*x(1)-x(2)+p(2)-2.5;-.5*x(1)-x(2)+p(2)+2.5];

    J=zeros(7,2);
    J(1,3) = 1;
    J(2,1) = 1;
    J(2,2) = -1;
    J(3,2) = -1;
    J(4,1) = -1;
    J(4,2) = -1;
    J(5,1) = -1;
    J(6,1) = .5;
    J(6,2) = -1;
    J(7,1) = -.5;
    J(7,2) = -1;
    
end

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

function HC = conhess(x,p)
HC = zeros(3,3,7);
end