how do i code optimum problem using two matrix?

1 vue (au cours des 30 derniers jours)
sharifah shuthairah syed abdullah
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 ?

Réponses (1)

Mary Fenelon
Mary Fenelon le 3 Mai 2018
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 commentaires
Mary Fenelon
Mary Fenelon le 4 Mai 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.
You can re-run GA to get different solutions due to its use of randomness.
sharifah shuthairah syed abdullah
thank you so much.. i didnt want to use GA because the problem i need to solve required me to search for optimum solution.. i will be using ga for other problem...

Connectez-vous pour commenter.

Community Treasure Hunt

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

Start Hunting!

Translated by