# Here in my code I defined A vector and B vector for my linear programing, the relationship between them is Ax=<B which A is a inequlity vector and B is a RHS and x is variable. the Error is in photo which i attached .how can I solve it?

3 views (last 30 days)
Baran Mehrdad on 9 Aug 2018
Commented: Baran Mehrdad on 9 Aug 2018 this is the way I defined b_ineaualty_sec5 :
and this is the way I defined A_inequality_sec5 :
temp2=eye(N_time_slots);
[A_ineq_sec5]=generate_Cplx_Constraint_format( Vars_size, [3;9],-temp2,temp2);
the relationship between A and b is Ax=<b which A is a inequlity vector and B is a RHS and x is variable. I know the problem is with the size of b and A , but how should I define b ?
and this is vars_size and generate_cplex_format functions:
function [Vars_size]= create_variable_bundle(N_time_slots)
Vars_size=[1;N_time_slots;N_time_slots; N_time_slots; N_time_slots; N_time_slots; N_time_slots;N_time_slots;N_time_slots;N_time_slots;N_time_slots;N_time_slots ];
end
function [A_block]=generate_Cplx_Constraint_format( Vars_size, Var_select,varargin)
total_size=sum(Vars_size);
temp1= tril(ones(numel(Vars_size),numel(Vars_size)))*Vars_size;
temp1(numel(Vars_size))=[];
Start_ind= [0;temp1]+1;
temp2=size( varargin{1} ,1);
A_block=zeros(temp2,total_size);
% A x+ By < b
for i=1: numel(Var_select),
A_block(:,Start_ind(Var_select(i)): Start_ind(Var_select(i))+ Vars_size(Var_select(i))-1 )=varargin{i};
end
end

Ameer Hamza on 9 Aug 2018
This problem is happening because load_kw is probably not a scalar, wheres your code seems to indicate it is a scaler. If It is a vector, you need to take care of the dimensions of the two matrices for multiplication.

Baran Mehrdad on 9 Aug 2018 yes you were right. it's not scalar .and your alternative soulotion also worked and there is no sign of that error anymore. could you plz explain it ? and also i have a new error at the end of my code , new error is : how can i solve it? it's again related to the m file that i sent before
Ameer Hamza on 9 Aug 2018
.* is element-wise multiplication whereas * is matrix multiplication. The second operator requires the matrix dimensions to be consistent.
While for your 2nd error, It seems that you might be accidentally mixing ',' and ';'. , add elements to same row while ; creates a new row. You can add a breakpoint at that line to diagnose the error.
Baran Mehrdad on 9 Aug 2018
thank you for the feedback. your information was so useful to me. regards