No BSD License  

Highlights from
MatPlanWDM v0.5

image thumbnail

MatPlanWDM v0.5

by

 

29 Jan 2007 (Updated )

Educational network planning tool for the RWA problem in WDM networks (MILP and heuristic based)

callSolver_CPLEX.m
%  callSolver_CPLEX
% 
%>> Usage: [exitMsg exitFlag x, slack, v, rc, f_k, ninf, sinf, basis, lpiter, ...
%            glnodes, confstat, iconfstat, sa] = ...
%     callSolver_CPLEX (c,A,bVector,N,NUMBERLINKWAVELENGTHS,NUMBERINGRESSEGRESSNODEPAIRS)
%
%>> Abstract: This function is used by the MILP function to call the CPLEX
%   solver.
%
%>> Arguments:
% o In: 
%   c: Linear objective function cost coefficients, n x 1.
%
%   A: Linear constraint matrix, dense or sparse m x n matrix. cplex.m
%    converts the matrix to a sparse format.
%
%   bVector: Upper bounds on linear constraints, 1 x m.
%
%   NUMBERLINKWAVELENGTHS: Total number of available wavelengths channels
%    in the whole network. It is computed as the sum of all the wavelengths
%    in each link.
%
%   NUMBERINGRESSEGRESSNODEPAIRS: Total number of valid node pairs (node
%    pairs where the source node and the end node are different nodes). It
%    is computed as N*(N-1), where N is the number of nodes.
%
% o Out:
%  . exitMsg: Exit Message according to the output message 'Inform' from
%    the CPLEX solver.
% 
%  . exitFlag: 
%          - 0, if it is possible to find a optimal solution.
%          - 1, if it is not possible to find a feasible solution
%          - 2, otherwise (a subpotimal solution)
%
%   x: Solution vector with decision variable values (n x 1 vector).
%
%   slack: Slack variables (m x 1 vector).
%
%   v: Lagrangian multipliers (dual solution vector) (m x 1 vector)
%
%  . rc: Reduced costs. Lagrangian multipliers for simple bounds on x.
%
%   f_k: Objective function value at optimum
%  
%   ninf: Number of infeasibilities
%
%   sinf: Sum of infeasibilities
%  
%   basis:     Vector containing basis at solution
%  
%             The first m elements contain row basis information, with the
%             following possible values for non-ranged rows:
%  
%           0 associated slack/surplus/artificial variable nonbasic at value 0.0
%           1 associated slack/surplus/artificial variable basic
%  
%             and for ranged rows (both upper and lower bounded)
%  
%           0 associated slack/surplus/artificial variable nonbasic at its lower bound
%           1 associated slack/surplus/artificial variable basic
%           2 associated slack/surplus/artificial variable nonbasic at its upper bound
%  
%  
%             The last n elements, i.e. basis(m+1:m+n) contain column
%             basis information:
%  
%           0 variable at lower bound
%           1 variable is basic
%           2 variable at upper bound
%           3 variable free and nonbasic
%  
%   lpiter    Number of LP iterations
%  
%   glnodes   Number of nodes visited
%  
%   confstat   Structure with extended conflict status information. This
%              output is a replica of the Prob.CPLEX.confgrps input argument
%              with the added fields 'status' and 'istat'. confstat(k).status
%              gives a text description of the status of conflict group k;
%              the corresponding istat field is the numeric value also
%              available in iconfstat(k).
%  
%   iconfstat  Conflict status information. For an infeasible problem where
%              at least one conflict group have been supplied in the confgrps
%              input argument, this output argument contains the status of
%              each conflict group, in the same order as given in the confgrps input.
%  
%              The following values are possible:
%  
%             -1  Excluded
%              0  Possible member
%              1  Possible LB
%              2  Possible UB
%              3  Member
%              4  Upper bound
%              5  Lower bound
%  
%              If confstat is empty even though Conflict Refinement has been
%              requested, there was a problem in the refinement process.
%  
%   sa        Structure with information about the requested SA, if requested.
%             The fields:
%  
%                 obj         Ranges for the variables in the objective function.
%  
%                 rhs         Ranges for the right hand side values.
%  
%                 xl          Ranges for the lower bound values.
%  
%                 xu          Ranges for the upper bound values.
%  
%             These fields are structures themselves. All four structures
%             have identical field names:
%  
%                 status      Status of the SA operation. Possible values:
%  
%                              1  Successful
%                              0  SA not requested.
%                             -1  Error: begin is greater than end.
%                             -2  Error: The selected range (begin...end) stretches
%                                 out of available variables or constraints.
%                             -3  Error: No SA available.
%  
%                 lower       The lower range.
%  
%                 upper       The upper range
%


function [exitMsg exitFlag x, slack, v, rc, f_k, ninf, sinf, basis, lpiter, ...
           glnodes, confstat, iconfstat, sa] = ...
    callSolver_CPLEX (c,A,bVector,N,NUMBERLINKWAVELENGTHS,NUMBERINGRESSEGRESSNODEPAIRS)

   NUMBERVARIABLES = length (c);

    %We assign values to the input parameters of the solver CPLEX
    [m,n]   = size(A); %we calculate the size of A
    F=[]; %The Quadratic coefficient matrix. This matrix is empty if the problem is non-quadratic.

    %We define the integer decision variables 
    IntVars = [1:NUMBERLINKWAVELENGTHS * NUMBERINGRESSEGRESSNODEPAIRS]; 

    % Lower and upper bounds for constraints and for decision variables.
    x_L     = zeros(1,n);
    x_WavInd_U= ones(1,NUMBERLINKWAVELENGTHS * NUMBERINGRESSEGRESSNODEPAIRS);
    x_Flow_U= inf*ones(1,N^4);
    x_U     = [x_WavInd_U x_Flow_U];

    b_L     = -inf*ones( m,1);
    b_U     = bVector;  

    cpxControl = [];
%     cpxControl.EPGAP = 0.1;
    callback = [];
    PriLev = 2; %Print Level: Summary information
    % PriLev = 3; %Print Level: More Detailed Information
    Prob = [];

    PI      = [];
    SC      = [];
    SI      = [];
    sos1    = [];
    sos2    = [];

    logfile=[];
    savefile=[];
    savemode=[];
    qc=[];

    confgrps=[]; 
    conflictFile=[];
    saRequest=[];
    basis=[];
    xIP=[];
    logcon=[];

    [x, slack, v, rc, f_k, ninf, sinf, Inform, basis, lpiter, ...
    glnodes, confstat, iconfstat, sa] = cplex(c, A, x_L, x_U, b_L, b_U, ...
    cpxControl, callback, PriLev, Prob, IntVars, PI, SC, SI, ...
    sos1, sos2, F, logfile, savefile, savemode, qc, ...
    confgrps, conflictFile, saRequest, basis, xIP, logcon);


    [exitMsg exitFlag] = cplexErrorMsg (Inform);

end

Contact us