Hello,
My own model is very large and complex so I will try to explain the problem by a simple example: The vector P is a V:1 vector. Each element of P is a positive real number. The following linear programme problem needs to be solved:
x=optimvar('x',V,1);
f=optimexpr(size(P));
for t=V:1;
f(t)=P(t)*x(t)
end
prob1=optimproblem('ObjectiveSense','minimize');
obj=sum(f);
prob1.Objective=obj;
prob1.Constraints.cons1=x<=1;
prob1.Constraints.cons2=x>=-1;
If one solves the optimization problem above, the optimization variable outcome x will be a V:1 vector with all elements having a value of -1.
Now I want to put a constrain on the definite sum of each element. i.e. the sum of vector elements should never exceed the boundary -3:
. (note that I don't want to constrain the total sum of vector x (
) but only the sum up to the t-th element. I tried introducing the following auxiliary variable to compute the constrain:
w=optimexpr(size(P));
w(t)=sum(x(1:t))
prob1.Constraints.cons3=w>=-3
When I put in the constraint, and run the solver, the optimal solution is found. However, the constraint is not taken into account by the solver since each element of vector x has a value of -1.. Is there anyone that knows a way to resolve this problem??