Home > src > lp_maker.m

lp_maker

PURPOSE ^

LP_MAKER Makes mixed integer linear programming problems.

SYNOPSIS ^

function lp_handle = lp_maker(f,a,b,e,vlb,vub,xint,scalemode,setminim, rh)

DESCRIPTION ^

LP_MAKER  Makes mixed integer linear programming problems.

  SYNOPSIS: lp_handle = lp_maker(f,a,b,e,vlb,vub,xint,scalemode,setminim)
     make the MILP problem
       max v = f'*x
         a*x <> b
           vlb <= x <= vub
           x(int) are integer

  ARGUMENTS: The first four arguments are required:
           f: n vector of coefficients for a linear objective function.
           a: m by n matrix representing linear constraints.
           b: m vector of right sides for the inequality constraints.
           e: m vector that determines the sense of the inequalities:
                     e(i) < 0  ==> Less Than
                     e(i) = 0  ==> Equals
                     e(i) > 0  ==> Greater Than
         vlb: n vector of non-negative lower bounds. If empty or omitted,
              then the lower bounds are set to zero.
         vub: n vector of upper bounds. May be omitted or empty.
        xint: vector of integer variables. May be omitted or empty.
   scalemode: Autoscale flag. Off when 0 or omitted.
    setminim: Set maximum lp when this flag equals 0 or omitted.

  OUTPUT: lp_handle is an integer handle to the lp created.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 %LP_MAKER  Makes mixed integer linear programming problems.
0002 %
0003 %  SYNOPSIS: lp_handle = lp_maker(f,a,b,e,vlb,vub,xint,scalemode,setminim)
0004 %     make the MILP problem
0005 %       max v = f'*x
0006 %         a*x <> b
0007 %           vlb <= x <= vub
0008 %           x(int) are integer
0009 %
0010 %  ARGUMENTS: The first four arguments are required:
0011 %           f: n vector of coefficients for a linear objective function.
0012 %           a: m by n matrix representing linear constraints.
0013 %           b: m vector of right sides for the inequality constraints.
0014 %           e: m vector that determines the sense of the inequalities:
0015 %                     e(i) < 0  ==> Less Than
0016 %                     e(i) = 0  ==> Equals
0017 %                     e(i) > 0  ==> Greater Than
0018 %         vlb: n vector of non-negative lower bounds. If empty or omitted,
0019 %              then the lower bounds are set to zero.
0020 %         vub: n vector of upper bounds. May be omitted or empty.
0021 %        xint: vector of integer variables. May be omitted or empty.
0022 %   scalemode: Autoscale flag. Off when 0 or omitted.
0023 %    setminim: Set maximum lp when this flag equals 0 or omitted.
0024 %
0025 %  OUTPUT: lp_handle is an integer handle to the lp created.
0026 
0027 function lp_handle = lp_maker(f,a,b,e,vlb,vub,xint,scalemode,setminim, rh)
0028 
0029 if nargin == 0
0030         help lp_maker;
0031         return;
0032 end
0033 
0034 [m,n] = size(a);
0035 lp_handle = mxlpsolve('make_lp', m, n);
0036 mxlpsolve('set_verbose', lp_handle, 3);
0037 mxlpsolve('set_mat', lp_handle, a);
0038 mxlpsolve('set_rh', lp_handle, 0, rh);
0039 mxlpsolve('set_rh_vec', lp_handle, b);
0040 mxlpsolve('set_obj_fn', lp_handle, f);
0041 mxlpsolve('set_maxim', lp_handle); % default is solving minimum lp.
0042 
0043 for i = 1:length(e)
0044   if e(i) < 0
0045         con_type = 1;
0046   elseif e(i) == 0
0047         con_type = 3;
0048   else
0049         con_type = 2;
0050   end
0051   mxlpsolve('set_constr_type', lp_handle, i, con_type);
0052 end
0053 
0054 if nargin > 4
0055   for i = 1:length(vlb)
0056     mxlpsolve('set_lowbo', lp_handle, i, vlb(i));
0057   end
0058 end
0059 
0060 if nargin > 5
0061   for i = 1:length(vub)
0062     mxlpsolve('set_upbo', lp_handle, i, vub(i));
0063   end
0064 end
0065 
0066 if nargin > 6
0067   for i = 1:length(xint)
0068     mxlpsolve('set_int', lp_handle, xint(i), 1);
0069   end
0070 end
0071 
0072 if nargin > 7
0073   if scalemode ~= 0
0074     mxlpsolve('set_scaling', lp_handle, scalemode);
0075   end
0076 end
0077 
0078 if nargin > 8
0079   if setminim ~= 0
0080     mxlpsolve('set_minim', lp_handle);
0081   else
0082     mxlpsolve('set_maxim', lp_handle);
0083   end
0084 end

Generated on Tue 31-May-2016 19:24:56 by m2html © 2005