MILP - Multidimensional optimization

조회 수: 4 (최근 30일)
Ngai Nang Wong
Ngai Nang Wong 2018년 8월 28일
답변: BOWEN LI 2019년 7월 19일
Hi guys, I am currently working on an optimization problem:-
I have to assign my workers (i) to perform different tasks (j) under different sections (k) of different projects(L).
So I created a simple model : Maximize P = X(ijkl)*Y(ijkl) and Y(ijkl) is binary variable
The assignment method are based on the performance data X(ijlk), e.g. workers (i) have 20 marks in task (j) under section (k) in project (L).
But I have problem in creating the performance data in matlab. I have tried to create 4-D matrix but error occur. Can anyone give me some advise?
Thank you. Jim
---Updated---
Here is my code
l = {'P1','P2',};
k = {'S1','S2','S3','S4'};
j = {'T1','T2','T3','T4','T5','T6','T7', 'T8'};
i = {'W1','W2','W3','W4','W5','W6','W7','W8'};
Y = optimvar('Y',i,j,k,l,'LowerBound',0,'UpperBound',1,'Type','integer');
X = rand(8,8,4,2)
Optimprob = optimproblem('ObjectiveSense','maximize','Objective',sum(sum(Y.*X)));
[soln,fval,exitflag,output] = solve(Optimprob);
and turns out error is occur:-
Error using optimproblem (line 52) Objective must be a scalar OptimizationExpression or a struct containing a scalar OptimizationExpression.
  댓글 수: 2
Alan Weiss
Alan Weiss 2018년 8월 28일
Please show us some code and the full error message.
Alan Weiss
MATLAB mathematical toolbox documentation
Ngai Nang Wong
Ngai Nang Wong 2018년 8월 28일
I edited the question with my code, thank you so much!

댓글을 달려면 로그인하십시오.

답변 (2개)

Aurele Turnes
Aurele Turnes 2018년 9월 11일
편집: Aurele Turnes 2018년 9월 11일
Your objective is
obj = sum(sum(Y.*X))
which is not scalar, but a 1-by-1-by-4-by-2 ND array.
Currently, the problem-based optimization only supports linear and mixed-integer linear problems: https://www.mathworks.com/help/optim/problem-based-lp-milp.html
All these solvers expect the objective to return a scalar value, so the objective is expected to be a 1-by-1 expression.

BOWEN LI
BOWEN LI 2019년 7월 19일
Hi, I am working on a similar question as yours, have you solved this question?

카테고리

Help CenterFile Exchange에서 Solver Outputs and Iterative Display에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by