# Linear Programming Code Not Working

29 ビュー (過去 30 日間)
Richard McDonough 2018 年 12 月 14 日
コメント済み: Walter Roberson 2018 年 12 月 22 日
A problem which I am working on is shown below.
At this point in time, I have been attempting to solve the problem using the linprog command. I have written out to the best of my ability what I believe Aeq, beq, A, b, and c are, but I am getting an undesireable output. The output states:
Exiting: One or more of the residuals, duality gap, or total relative error has grown 100000 times greater than its minimum value so far:
the primal appears to be infeasible (and the dual unbounded).
(The dual residual < OptimalityTolerance=1.00e-08.)
Any help on fixing this issue would be greatly appreciated. I am not entirely sure that my matrices are all correct, but I believe they are.
xlp = linprog(c, A, b, Aeq, beq, lb, ub);

#### 5 件のコメント

Richard McDonough 2018 年 12 月 20 日
i need this question repmved as i posted my code for a class and people were copying it. please let me delete it. your answers did not help me to solve the problem as i already finished the class.
Walter Roberson 2018 年 12 月 20 日
You can tell your TA or professor that you believe that you may have been copied. Let them handle the situation.
Walter Roberson 2018 年 12 月 22 日
Richard:
Mathworks Answers is not a private consulting service. The "price" we volunteers charge is that if a volunteer has given a meaningful contribution towards solving the Question, then unless the Question violates policy, then the Question has to stay open so that everyone can learn from the Question and response. No private benefit for the volunteer answers.
If other people are copying your material then you can report that to your TA or professor or your university Office of Academic Integrity.

サインイン to comment.

### 回答 (1 件)

Alan Weiss 2018 年 12 月 14 日
I believe that this problem would be much easier to formulate using the problem-based approach rather than the solver-based approach you chose.
But to comment on the problem as you set it up. Many rows in your A matrix have only one entry. You should not have any such rows; they represent bounds, and you should not have them in the A matrix as well.
I am not sure what your control variables represent, so cannot comment further on your setup.
Good luck,
Alan Weiss
MATLAB mathematical toolbox documentation

#### 1 件のコメント

John D'Errico 2018 年 12 月 20 日
Just to expand on Alan's answer, if we eliminate the redundant constraints, we would recognize that the first 8 unknowns MUST lie between 0 and 10. The second set of 8 unknowns must lie between -5 and 5.
But not only that, since the rest of the constraints actually form cumulative sums of unknowns 9 through 16, and since those cumulative sums are more tightly constrained that the original bounds, we see a set of bounds that looks like:
lb = [zeros(8,1); 0.2; -5*ones(7,1)];
ub = [10*ones(8,1); 0.8; 5*ones(7,1)];
The difference is because that first member of the cumulative sum is now severely limited. So A becomes fairly simple now.
A = [0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0;
0 0 0 0 0 0 0 0 1 1 1 0 0 0 0 0;
0 0 0 0 0 0 0 0 1 1 1 1 0 0 0 0;
0 0 0 0 0 0 0 0 1 1 1 1 1 0 0 0;
0 0 0 0 0 0 0 0 1 1 1 1 1 1 0 0;
0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 0;
0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1;
0 0 0 0 0 0 0 0 -1 -1 0 0 0 0 0 0;
0 0 0 0 0 0 0 0 -1 -1 -1 0 0 0 0 0;
0 0 0 0 0 0 0 0 -1 -1 -1 -1 0 0 0 0;
0 0 0 0 0 0 0 0 -1 -1 -1 -1 -1 0 0 0;
0 0 0 0 0 0 0 0 -1 -1 -1 -1 -1 -1 0 0;
0 0 0 0 0 0 0 0 -1 -1 -1 -1 -1 -1 -1 0;
0 0 0 0 0 0 0 0 -1 -1 -1 -1 -1 -1 -1 -1];
b = [repmat(0.8,7,1);repmat(0.2,7,1)];
c = [4 3 2 3 7 6 5 4 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8]';
[X,FVAL,EXITFLAG] = linprog(c,A,b,Aeq,beq,lb,ub)
No feasible solution found.
Linprog stopped because no point satisfies the constraints.
X =
[]
FVAL =
[]
EXITFLAG =
-2
I'd bet you can show that the equality constraints are inconsistent with that set of bounds and linear inequalities.

サインイン to comment.

サインイン してこの質問に回答します。

R2016b

Translated by