How can I write a constraint for a maximization problem including different size of indices?

1 回表示 (過去 30 日間)
Hi,
I have a question regarding how to write a constraint including different size of indices? For example in the problem I provided below, I try to obtain the A matrix for intlinprog. I assume I must obtain A(t,i*k) size matrix. But I don't know how to do it with the constraint including P(i)*d(k,l)? X(i,k,t) is integer variable.
This is the code I tried to write:
i = 5;
k = 3;
l = 2;
t = 6;
d_kl = [1 3;5 1;1 5];
P_i = [2 5 6 4 7];
TR_t = [5000 5000 5000 5000 5000 5000];
X_ikt = zeros(i,k,t);
obj = X_ikt(:);
A = zeros(t,i*k);
for tt = 1:t
A = d_kl.*P_i;
end
b = zeros(t,1);
for tt = 1:t
b = TR_t'
end
Aeq = [];
beq = [];
lb = zeros(i,k,t);
ub = [];
intcon = 1:i*k*t;
x = intlinprog(obj,intcon,A,b,Aeq,beq,lb,ub)

採用された回答

Alan Weiss
Alan Weiss 2018 年 11 月 30 日
I think that this is much easier to handle using the Problem-Based Optimization Setup. For problem-based optimization you define your variables as symbolic-type arrays of any dimension, and your objective and constraints as linear functions of those variables. See the examples in Linear Programming and Mixed-Integer Linear Programming.
Alan Weiss
MATLAB mathematical toolbox documentation

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLinear Programming and Mixed-Integer Linear Programming についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by