If linprog tells you the problem is unbounded, then it is. What does that mean?
Unbounded means there is some direction you can move infinitely far out, and it can keep in decreasing the objective function. FOREVER. And this means the function has no minimum.
However, first it is important to see if you have actually written the linprog call properly. You have NOT done so. You wrote this:
Aeq=[0 0 1 0 1 0 7; 1 0 0 0 0 1 1];
The first line of Aeq says that
x3 + x5 + 7*x7 = 12
That is clearly incorrect, or, at least, is inconsistent with the equations you have written. It is most likely a typo, made when you transcribed the first equation. You need to be more careful in implementing your equations into code.
It might be easier to use a problem formulation to solve your linear programming problem. I'll do that here. I say that because now your equations can be written directly, pretty much as you wrote them. The only thing I needed to do was convert the scalar variables into a vector of variables. That is something you need to learn to do anyway.
pr.Objective = (x(1)+x(2))*0.2-(x(3)+x(4))*0.1+(x(5)+x(2)-x(6)-x(4))*0.005+(x(7)+x(5)+x(3))*0.006;
pr.Constraints.eq1 = x(7)+x(5)+x(3) == 12;
pr.Constraints.eq2 = x(7)+x(1)+x(6) == 10;
pr.Constraints.ineq1 = -3 <= (x(5)+x(2))*0.9-(x(6)+x(4))/0.9;
pr.Constraints.ineq2 = 0<=x(5)+x(2);
pr.Constraints.ineq3 = 0<=x(6)+x(4);
pr.Constraints.ineq4 = (x(5)+x(2))*0.9-(x(6)+x(4))/0.9 <= 3;
pr.Constraints.ineq5 = x(5)+x(2)<=4;
pr.Constraints.ineq6 = x(6)+x(4)<=4;
solve(pr)
Solving problem using linprog.
Problem is unbounded.
Even so, the problem is still reported as being unbounded.
You might consider reading this post I made recently explaining the situation, where I explain some common mistakes and problems people have when solving linear programming problems.
The third answer to that question explains the issues of unboundedness.
There is a reasonable chance that you really need to just assign lower and possibly upper bounds to the variables. That is, does it make sense if the variables can be negative? If not, then you need bounds on those variables. For example, you might do something as simple as this:
x.LowerBound = zeros(1,7)
x =
1×7
OptimizationVariable array with properties:
Array-wide properties:
Name: 'x'
Type: 'continuous'
IndexNames: {{} {}}
Elementwise properties:
LowerBound: [0 0 0 0 0 0 0]
UpperBound: [Inf Inf Inf Inf Inf Inf Inf]
See variables with
show.
See bounds with
showbounds.
x0 = solve(pr)
Solving problem using linprog.
Optimal solution found.
x0 =
x: [0 0 2.0000 2.7000 0 0 10.0000]
And now your problem has a unique solution. I don't know if this is reasonable for your problem, but something like that is necessary for a solution to exist.
Can we learn where the solver wants to go, such that the problem is unbounded? Probably yes. For example, try this next, since a lower bound solved the problem.
x.LowerBound = -100*ones(1,7);
x100 = solve(pr)
Solving problem using linprog.
Optimal solution found.
x100 =
x: [-100 -100 -100 -95.3000 100 98.0000 12.0000]
Do you see what it wants to do? It wants to move in this direction:
xdir = x100.x - x0.x; xdir = xdir/norm(xdir,inf)
xdir =
-0.9804 -0.9804 -1.0000 -0.9608 0.9804 0.9608 0.0196
And that tells me I could have solved the problem by creating upper bounds for the variables instead. I might even have been able to solve it by bounding only ONE of those variables. For example, I might have done this instead.
x.LowerBound = -inf(1,7);
x.UpperBound(5) = 10
x =
1×7
OptimizationVariable array with properties:
Array-wide properties:
Name: 'x'
Type: 'continuous'
IndexNames: {{} {}}
Elementwise properties:
LowerBound: [0 -Inf -Inf -Inf -Inf -Inf -Inf]
UpperBound: [Inf Inf Inf Inf 10 Inf Inf]
See variables with
show.
See bounds with
showbounds.
solve(pr)
Solving problem using linprog.
Optimal solution found.
ans =
x: [0 -10 -5.3000 0 10 2.7000 7.3000]
That was also sufficient to create a bounded solution, but I did need to adjust two of the bounds for it to succeed. Anyway, you need to consider why your problem does not have a solution as you wrote it.