GA optimization inequality constraints

Hello community,
I have been trying to solve a optimization problem for which my inequality constrains are as follows:
Say if X is the solution (1*2000 matrix), my constraint is that every next value for the X matrix should be higher than the previous value. Lets say a is value of X at 1st position (X1) and b is the value at second X2. So constraint is b-a >= 0.01; To write it in terms of less than, since ga takes constraints as A.X<=b, we have (a-b <= -0.01).
But when iam trying to build A matrix and B matrix, when i give negative inputs in B matrix i always get the error: Could not find a feasible initial point.
Can someone help me in - how to define this constraint without using a negative constant value? or is there any other way to do the same? I have been struck in this problem for quite sometime. Please give me any siggestions.
Thanks.

 采纳的回答

Matt J
Matt J 2019-8-30
编辑:Matt J 2019-8-30
The construction of the A and b matrices should be,
A=-diff(speye(2000));
b=-0.01*ones(2000,1);
If you have done this, then there is nothing incorrect about the way you have built the constraints, assuming X(i+1)-X(i)>=0.01 are indeed the conditions you want. You should investigate whether the problem truly does have a feasible solution under these constraints and whatever other constraints you have imposed.

6 个评论

Hello, I tried applying the same, but whenever i try to have a negative value for b, the error still comes. Is it because that there is no feasible solution for the constraint with a negative value for b matrix? Because i have perfomed the experiments and it works and also model has already been validated, then how come now the constraints is creating a problem? Could you give any more insights?
Could you give any more insights?
Perhaps, if you show the code for the other constraints.
Hi,
I have 4 different variables (say X1-X4) for 2000+ time points and thus the ga opt fun will use these X1-X4 at 2000+ points to calculate and solve the ode. So this code is for the bounds and constraints and for solving ga.
options = gaoptimset ('UseParallel', true, 'PopulationSize', 1000)
% lb=[ 24 400 0.005 0.208];
% ub=[ 100 900 0.01 0.25];
no_term = 721*4;
for i = 1:4:no_term
lb(i) = 24;
ub(i) = 100;
end
for i = 2:4:no_term
lb(i) = 400;
ub(i) = 900;
end
for i = 3:4:no_term
lb(i) = 0.005;
ub(i) = 0.01;
end
for i = 4:4:no_term
lb(i) = 0.208;
ub(i) = 0.25;
end
A= zeros (20,2884);
for m = 1:no_term-4
A(m,m) = 1;
A(m, m+4) = -1;
end
%b= zeros (2880,1);
for n = 1:no_term-4
b (n) = -0.01;
end
[X fval] = ga(@gaopt, no_term, [A], [b], [], [], [lb], [ub], [], options);
These bounds,
for i = 3:4:no_term
lb(i) = 0.005;
ub(i) = 0.01;
end
for i = 4:4:no_term
lb(i) = 0.208;
ub(i) = 0.25;
end
conflict with your montonicity constraints. If you have 2000 time points and X(i) increases by at least 0.01 at each time point, then X(i) will increase by at least 20 from X(1) to X(2000). But it is impossible for this to happen and also satisfy the above lb and ub bounds. In the first case ub-lb=0.005 and in the second case ub-lb=0.420
Thanks for noticing that. But when i tried using something like this also, I got the same error. ie., whenever i used a negative value for b matrix i got the error.
b= zeros (2880,1);
for n = 1:4:no_term-4
b (n) = -0.01;
end
for n = 2:4:no_term-4
b (n) = -0.01;
end
for n = 3:4:no_term-4
b (n) = -0.0001;
end
for n = 4:4:no_term-4
b (n) = -0.001;
end
They are still too large to satisfy your bounds.

请先登录,再进行评论。

更多回答(0 个)

类别

Community Treasure Hunt

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

Start Hunting!

Translated by