No feasible solution found
조회 수: 84 (최근 30일)
이전 댓글 표시
Hi. I am working on minimizing the weight of a structure that is attached to two different points as shown in the figure below.
I am getting no feasible solution when I put in the code. Here is the code I have. What is it that I am doing wrong? I have been working on this for two days now and cannot see where my error is.
clc;
clear all;
% Objective function for minimizing the total weight of the structure
f = [1, 1, 1, 1, 1, 0, 0, 0, 0, 0];
% yield stress -A <= F <= A constraints
Aineq = [
-1, 0, 0, 0, 0, 1, 0, 0, 0, 0; %-A1 <= F1
1, 0, 0, 0, 0, -1, 0, 0, 0, 0; %F1 <= A1
0, -1, 0, 0, 0, 0, 1, 0, 0, 0; %-A2 <= F2
0, 1, 0, 0, 0, 0, -1, 0, 0, 0; %F2 <= A2
0, 0, -1, 0, 0, 0, 0, 1, 0, 0; %-A3 <= F3
0, 0, 1, 0, 0, 0, 0, -1, 0, 0; %F3 <= A3
0, 0, 0, -1, 0, 0, 0, 0, 1, 0; %-A4 <= F4
0, 0, 0, 1, 0, 0, 0, 0, -1, 0; %F4 <= A4
0, 0, 0, 0, -1, 0, 0, 0, 0, 1; %-A5 <= F5
0, 0, 0, 0, 1, 0, 0, 0, 0, -1; %F5 <= A5
];
Bineq = zeros(10, 1); % All b inequalities are <= zero
%Equaltity constraints at each of the points for equilibrium conditions
Aeq = [
1, 0, 0, 0, 0, 1, 0, 0, 0, 0; %Top left attached point for horizontal force
0, 1, 0, 0, 0, 0, 1, 0, 0, 0; %Top left attached point for vertical force
-1, 0, 1, 0, 0, 0, 0, 1, 0, 0; %Top right point for horizontal force
0, -1, 0, 1, 0, 0, 0, 0, 1, 0; %Top right point for vertical force
0, 0, 0, 0, 1, 0, 0, 0, 0, 1; %Bottom right point for vertical force where p=1
];
Beq = [0; 0; 0; 0; -1]; %Applied force at the bottom right point
%Lower bounds for areas and forces of all bars
LB = zeros(10, 1);
%Upper bounds for areas and forces of all bars
UB = [1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000];
options = optimoptions('linprog', 'Display', 'iter', 'TolFun', 1e-6);
[x, fval, exitflag, output] = linprog(f, Aineq, Bineq, Aeq, Beq, LB, UB, options);
disp('Optimal cross-sectional areas:');
disp('Bar forces:');
disp(['Minimum weight of the truss:', num2str(fval)]);
댓글 수: 3
Torsten
2024년 11월 3일 20:50
I don't know about the physics behind your assignment - thus I cannot say where you made a mistake in the setup of Aineq, Aeq, bineq and/or beq. So your question is no longer a MATLAB, but a physics question.
답변 (1개)
David Goodmanson
2024년 11월 7일 12:12
편집: David Goodmanson
2024년 11월 8일 2:55
Hi Preston,
It seems likely that this is a planar structure with the diagonal elements having length sqrt(2). (If all the bars have length 1 as claimed, then you have a three-dimensional structure and a complicated solution). I am going to proceed assuming a planar structure.
There are a couple of things going on. For the matrix Aineq which concerns -A <= F <= A, the right hand inequality is -A + F <=0 which corresponds to the odd numbered rows in Aineq (although I think the comments for those lines are not right). The left hand inequality corresponds to -A -F <= 0 so the even numbered lines need to have all minus signs.
For the equalities, you only have to set the total force components = 0 for the upper right and lower right corners, four equations in all. That's good because those two corners are the only ones where the external forces are known. Since the framework is a rigid body, if those two corners are in equilibrium the support corners (where the external forces are unknown a priori) are in equilibrium as well.
I took the forces to be tension in the bars so positive F is pulling on both of its end points, and negative F would be compression. For example the lower right corner eqns are
o----1---o
\ /|
4 / | F2 + cos(theta)*F4 = P % vert
\ / | F3 + cos(theta)*F4 = 0 % horiz
\/ 2
/\ |
/ \ |
5 \ |
/ \|
o----3---o
|
P (down)
where all the angles are 45 degrees so cos(theta) = 1/sqrt(2). For both corners all together you will end up with a 4x10 matrix for Aeq where the first five elements of each row are zero since the cross sections A are not involved. The 4x1 vector beq has three zeros with the value P in the appropriate spot. The lower bound can't be zero for the forces since they can be of either sign. You can define LB as
[0 0 0 0 0 -inf -inf -inf -inf -inf]
For the objective function, since two of the rods have length sqrt(2) the f vector is
[1 1 1 sqrt(2) sqrt(2) 0 0 0 0 0]
When you incorporate all that, linprog produces (for P = 1) the result f' * X = 3.
댓글 수: 0
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!