Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

How to solve school bus routing problem (SBRP) using gurobi optimizer in matlab interface?

An example to solve MILP using gurobi optimizer in matlab interface is given as follows:

 

function[] = mip1()

names = {'x'; 'y'; 'z'};

try
    clear model;
    model.A = sparse([1 2 3; 1 1 0]);
    model.obj = [1 1 2];
    model.rhs = [4; 1];
    model.sense = '<>';
    model.vtype = 'B';
    model.modelsense = 'min';

    clear params;
    params.outputflag = 0;
    params.resultfile = 'mip1.lp';

    result = gurobi(model, params);

    disp(result)

    for v=1:length(names)
        fprintf('%s %d\n', names{v}, result.x(v));
    end

    fprintf('Obj: %e\n', result.objval);

catch gurobiError
    fprintf('Error reported\n');
end

end

 

======================================

 

After running this code we have output like this:

          status: 'OPTIMAL'
     versioninfo: [1x1 struct]
          objval: 1
         runtime: 0
               x: [3x1 double]
           slack: [2x1 double]
        objbound: 1
       itercount: 0
    baritercount: 0
       nodecount: 0

x 0
y 1
z 0
Obj: 1.000000e+000


=========================================

 

Now I want to generalize this code to solve school bus routing problem.

 

I have modeled SBRP problem like this:

 

minimize sum_{i!=j} c_{ij} x_{ij}

subject to sum_{j=1}^{n} x_{ij} = 1, for i=1,2,...,n

               sum_{i=1}^{n} x_{ij} = 1, for j=1,2,...,n

 

               sum_{i,j \in s} <=|s|-v(s);

               s c V\{1};

               |s|>=2;

               x_{ij} \in {0,1}; i,j =1,2,...,n; i!=j

 

c_{ij} is cost

v(s) is an lower bound on the number of vehicles required to visit all vertices of s in the optimal solution.

S is a subset of V\{1}, where V is the set of bus stops.

 


Please help me.


Thanking you,

Ajay

0 Kudos
Message 1 of 1
(4,179 Views)