how do i code optimum problem using two matrix?
Mostrar comentarios más antiguos
when i run this coding and i got wrong answer when i compare to manual calculation.
Facilitieslist = {'i1','i2','i3' , 'i4', 'i5'};
Locationlist = {'j1','j2', 'j3', 'j4', 'j5'};
%Create binary variables indexed by office number and name.
FL = optimvar('FL',Locationlist,Facilitieslist,...
'Type','integer','LowerBound',0,'Upperbound',1);
% Flow mwtrix: flow assigning facility i (colum) to facility k (row)
F = [0 27 85 2 1;
27 0 80 58 21;
85 80 0 3 48;
2 58 3 0 74;
1 21 48 74 0];
%distance flow: distance assigning location j (colum) to location q (row)
D = [0 21 95 82 56;
21 0 44 40 75;
95 44 0 84 12;
82 40 84 0 69;
56 75 12 69 0] ;
The objective is to minimize the cost of the assignment... Create an optimization problem and include the objective function....
sum sum sum sum (fik*djq*xij*xkq)
FLprob = optimproblem('ObjectiveSense','maximize','Objective',sum(sum(sum(sum(FL.*F*D)))));
are the error is at optimvar or optimproblem?..how can i write it correctly ?
Respuestas (1)
Mary Fenelon
el 3 de Mayo de 2018
0 votos
Your problem has a quadratic objective function. optimproblem in 18a only supports linear objectives.
You can use the ga function in Global Optimization Toolbox. It can solve problems with quadratic objectives and integer variables. It requires the matrix form of the constraints.
The ga with integer variables does not permit equality constraints so if you have those, try a >= constraint instead. The objective might force equality.
3 comentarios
sharifah shuthairah syed abdullah
el 4 de Mayo de 2018
Mary Fenelon
el 4 de Mayo de 2018
Quadprog doesn't allow integer constraints so you may get fractional values for the variables. You might be able to round the variable values to get a solution respecting the constraints but that would not give you a proven optimum, either.
sharifah shuthairah syed abdullah
el 5 de Mayo de 2018
Categorías
Más información sobre Quadratic Programming and Cone Programming en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!