In fmincon i want to supply the Gradient of constraints. My constraints are very large and the optimization variables are also very large. I tried to use myAD and able to calculate the gradient of objective function but not of constraints

1 view (last 30 days)
Problem is having equality constraints(ceq) as well as inequality constraints(c) of the form
for n=1:iter-1
c(n) = -y(optvar*(n)+1)+15-(T(n+1)-4)^4; %optvar=7
end
and ceq as
for m= 1:state
ceq(2*state*(n-1)+m)=y(optvar*n+m)-y(optvar*(n-1)+m)-(beta/gamma)*fnp1(m)*h-(1-beta/gamma)*fn(m)*h-...
(1/2-beta/gamma)*y(optvar*(n-1)+state+alg+m)*h
end
where state,optvar are positive integer and fnp1 is some function.
How to calculate the gradient of c and ceq. As i am new to matlab so finding it difficult calculate.

Answers (1)

Matt J
Matt J on 28 May 2014
Edited: Matt J on 28 May 2014
where state,optvar are positive integer and fnp1 is some function.
If optvar is the vector of unknowns, it cannot be constrained to integer values. fmincon cannot handle integer programming problems. You could try ga(). There is no gradient computation involved there.
  4 Comments
Divyansh
Divyansh on 29 May 2014
This was the small sample problem in which the constraint is luckily linear but the actual problem i have is having nonlinear constraints of type
c(var*n+6)=18300*sqrt(rho0)*exp(0.5*beta1(ra- y(optvar*n+1)))*y(optvar*n+4)^3.05
where rho0,beta1 are having constant value..and c depend on unknown vector y nonlinearly.
Matt J
Matt J on 29 May 2014
Edited: Matt J on 29 May 2014
This constraint looks like it is in error. Everything on the right hand side is inherently strictly positive except for y(optvar*n+4)^3.05. The constraint is therefore only satisfied at y(optvar*n+4)=0 and a discrete set of negative values, where the constraint is not differentiable.
If y(optvar*n+4)=0 is really the condition that you want, there is no need to treat y(optvar*n+4) as an unknown. Just set it to zero at the beginning and exclude it from your problem.

Sign in to comment.

Categories

Find more on Get Started with Optimization Toolbox in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!