big M constraints bringing an infeasinle solution

Here Tins is a decision variable of size=(24,1) in my optimization problem. The value of Tins(min_des) =20 while value of Tins(max_des) = 23.
I have tried using the following constraints for the above equation in MILP problem.
(Tmin - Tins) - M1*(1-BCac) <= 0 where M1 is an upper bound on (Tmin - Tins)
(Tins - Tmax) - M2*BCac <= 0 where M2 is an upper bound on (Tins - Tmax)
But if its supposed that Tins=27
then my first constraint gets satisfied with both BCac=1 and BCac=0
although the second constraint is satisfied at BCac=1 only, which is correct.
But due to the first constraint, my program is getting an infeasible solution.
Any help would be deeply appreciated.

5 Comments

We would need to see your code.
This is giving me an infeasible solution
powerprob=optimproblem;
% Continous Variables
Pgrid=optimvar('Pgrid',24,1,'LowerBound',0,'UpperBound',7); % for grid power
Tins=optimvar('Tins',24,1,'LowerBound',20,'UpperBound',23); % Inside Temperature of room
% Binary Variables
BCac = optimvar('BCac',24,1,'Type','integer','LowerBound',0,'UpperBound',1);
BHac = optimvar('BHac',24,1,'Type','integer','LowerBound',0,'UpperBound',1);
% Parameters
Hr2end=2:24; Time=1:24;
Cgrid=[0.033 0.027 0.020 0.017 0.017 0.029 0.033 0.054 0.215...
0.572 0.572 0.572 0.215 0.572 0.286 0.279 0.086 0.059 0.050 0.061...
0.181 0.077 0.043 0.037];
A=200;e=0.9;u=0.5;Tout=repmat(35,24,1);
Pac=1.15;
%
gridCost = sum(Pgrid.*Cgrid');
Dth=(Pac*(BCac+BHac));
% Objective
powerprob.Objective= gridCost;
% Equality Constraints
powerprob.Constraints.PowerBalance = Pgrid == Dth; % Power Balance equation
powerprob.Constraints.C22 = Tins(Hr2end) == (e*Tins(Hr2end-1)) + (1-e)*(Tout(Hr2end) - ((u*BCac(Hr2end)*Pac)/A));
powerprob.Constraints.C23 = Tins(Hr2end) == (e*Tins(Hr2end-1)) + (1-e)*(Tout(Hr2end) + ((u*BHac(Hr2end)*Pac)/A));
% Inequality Constraints
powerprob.Constraints.C13 = BCac + BHac <=1;
powerprob.Constraints.C14 = (20-Tins(Time))-20*(1-BCac(Time))<=0;
powerprob.Constraints.C15 = (Tins(Time)-23)-23*(BCac(Time))<=0;
powerprob.Constraints.C16 = (Tins(Time)-20)-20*(BHac(Time)-1)<=0;
powerprob.Constraints.C17 = (23-Tins(Time))-23*(BHac(Time))<=0;
%
% Options for the optimization algorithm, here we set the max time it can run for
options=optimoptions('intlinprog','Maxtime',1000);
% Call the optimization solver to find the best solution
[sol,TotalCost,exitflag,output]=solve(powerprob,'options',options);
The code you've posted does not run:
Error using optim.problemdef.OptimizationProblem/solve
options is not a valid solver. Use 'linprog' or 'intlinprog' instead.
Error in test (line 37)
[sol,TotalCost,exitflag,output]=solve(powerprob,'options',options);
Sorry, the code is running in my software. But the result is no feasible solution. Here, check it out in the pic below:
Paramvir is using the new syntax for specifying solve options introduced in 18a.
Paramvir, here a couple of suggestions to diagnose the infeasibility:
  • Write a text version of the problem with writeproblem and make sure your constraints are as you expect
  • Often, it's one group of constraints that lead to infeasibility. Try to identify that group by commenting out groups of constraints.

Sign in to comment.

 Accepted Answer

Thanks a lot Mam, I too figured it out that solve options is introduced recently in the 2018a version of Matlab. I was giving out of bounds initial value to the Tins variable. Moreover, one of the big M constraint in my main program was given a wrong form. Also there were two equality constraints of Tins variable(both containing its formula for cooling and heating version), I edited that formula and now my program is giving satisfactory results.
Thanks a lot to Matt J for helping me out.

More Answers (0)

Categories

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!