Home > Back-end >  Matlab questions about yalmip toolbox for the shortest path
Matlab questions about yalmip toolbox for the shortest path

Time:09-29

I use yalmip toolbox for the shortest path, but I want to specify must after 11 nodes of the shortest path optimization, when I set the constraints for a certain after 11 PM, matrix feeling is normal, the following code
B=[0, 1.5 100 0.8 100 100 100 100 100 100 100 100 100 100 100 100;
0.9 1.5 0 1 100 100 100 100 100 100 100 100 100 100 100 100.
1 0 1.5 100 100 1.3 100 100 100 100 100 100 100 100 100 100;
100 100 1.5 0.0 1.0 100 100 100 100 100 100 100 100 100 100 100;
0.8, 100, 100, 100 3 100 100 1 100 100 100 100 100 100 100;
100 100 100 0.9 3 0 0.5 100 1 100 100 100 100 100 100 100;
100 100 100 100 1.3 0.5 0 and 0.4 100 1 100 100 100 100 100 100;
0.4 0, 100, 100, 100 1 100 100 100 100 100 100 100 100 100; 1.5
1 100 100 100 100 100 100, 100, 1 100 100 100 100 100;
100 100 100 100 100 100 100 100 0 1 100 100 100 100; 1.4
100 100 100 100 110 100 100 100 100 1 0 1 100 100 100 1.3;
100 100 100 100 100 100 100 100 100 1.5 1 0, 100, 100, 100, 1.5;
1 100 100 100 100 100 100 100 100 100 100 100 100 100; 0.5
100 100 100 100 100 100 100 100 100 100 100 1.4 0.5 1.5 0. 100;
100 100 100 100 100 100 100 100 100 100 13/10 100 100 1.5 0 1;
100 100 100 100 100 100 100 100 100 100 100 100 100 1.5 1 0];
The length of the % path
N=size (B, 1);
X=binvar (n, n 'full');
% create a decision variable

Z=(sum (the sum (b. * x)));
% objective function
C=sum (x (1, :)) - the sum (x (:, 1))==1, (sum (x (16, :)) - the sum (x (:, 16))==1)];
For I="
C=C, (sum (x (I, :)) - the sum (x (: I))==0)];
End
C=C, sum (x (11, :))==1);

% routing constraints

Ops=sdpsettings (' verbose, 0);
% to solve
Result=solvesdp (C, z, ops);
If the result. The problem==0
X_star=value (x);
Z_star=value (z);
The else
Disp (' error in the process of solving)
End
Double (x)
Double (z)

And as a result of such
  • Related