Class exercise: Suspended beams#
Added in version v2024.2.0: After class February 26th
Solutions in text and downloads
3 beams are suspended on ropes A, B, C, D, E and G:
Fig. 9 Suspended beams#
Find the permissible total load which doesn’t exceed the maximum tension N in rope A and B, C and D, and E and G of respectively 300 N, 200 N and 100 N. What is the tension in the ropes for the permissible total load?
Exercise 32 (Model)
Write out the nonlinear programming model of this problem.
Solution to Exercise 32 (Model)
From mechanics it follows that:
The problem can be stated as follows:
This could be solved by solving the systems of equations when evaluation the constraints, or solving the systems of equation symbolically on beforehand. In the second case, we can rephrase the model as:
Exercise 33 (Method)
Now let’s solve this problem using an optimization method.
Click –> Live Code to activate live coding on this page!
import scipy as sp
import numpy as np
#YOUR CODE HERE
Solution to Exercise 33 (Method)
import scipy as sp
import numpy as np
x0 = np.array([500, 100, 2, 9])
def func(x):
return -x[0] - x[1]
# solving the systems of equations during every iteration
def nonlinconfun(x):
F_1 = x[0]
F_2 = x[1]
x_1 = x[2]
x_2 = x[3]
A = np.array([[0,0,0,0,1,1],
[0,0,0,0,0,10],
[0,0,1,1,0,-1],
[0,0,0,8,0,-6],
[1,1,-1,-1,0,0],
[0,10,-2,-10,0,0]])
b = np.array([F_2, x_2*F_2, 0, 0, F_1, F_1*x_1])
sol = np.linalg.solve(A,b)
return sol
cons = sp.optimize.NonlinearConstraint(nonlinconfun, np.array([-np.inf,-np.inf,-np.inf,-np.inf,-np.inf,-np.inf]), np.array([300,300,200,200,100,100]))
bounds = [[0, None],
[0, None],
[0, 10],
[0, 10]]
result = sp.optimize.minimize(fun = func, x0 = x0, bounds = bounds,constraints=cons)
print(result.fun)
print(result.x)
print(nonlinconfun(result.x))
-700.0000000000525
[549.95615294 150.04384706 4.7270118 3.33528152]
[300. 300. 12.51096176 37.53288529 100.
50.04384706]
x0 = np.array([1000,1000,10,10])
result = sp.optimize.minimize(fun = func, x0 = x0, bounds = bounds,constraints=cons)
print(result.fun)
print(result.x)
print(nonlinconfun(result.x))
-700.0
[500. 200. 4.4 5. ]
[300. 300. 25. 75. 100. 100.]
We get different results for different initial guesses
With initial guess: \(F_1 = 500\), \(F_2 = 100\), \(x_1 = 2\), \(x_2 = 9\):
Total permissible load \(\approx 700\)
\(F_1 \approx 550\), \(F_2 = 150\), \(x_1 = 4.73\), \(x_2 = 3.34\)
\(N_A = 300\), \(N_B = 300\), \(N_C \approx 12.5\), \(N_D \approx 37.5\), \(N_E \approx 100\), \(N_G \approx 50.0\)
With initial guess: \(F_1 = 1000\), \(F_2 = 1000\), \(x_1 = 10\), \(x_2 = 10\):
Total permissible load \(= 700\)
\(F_1 = 500\), \(F_2 = 200\), \(x_1 = 4.4\), \(x_2 = 5\)
\(N_A = 300\), \(N_B = 300\), \(N_C \approx 25\), \(N_D \approx 75\), \(N_E \approx 100\), \(N_G \approx 100.0\)