I'm trying to optimize the weight of a truss with the constraint that the trusses don't face more stress than the material resistance.
Here is a sketch of my truss:
I have a Python function that given the list of X,Y coordinates for my fours nodes, gives the weight of the truss. Let's call it Weight(X).
I've also a function that calculates the stress in each truss: Stress(X).
Using a classical unconstrained gradient approach I've minimized the weight of my truss. I only act on Node 2's x and y coordinates (lower right node). Here is the configuration I get:
I would like now to be sure that the stresses in my trusses are not higher than the material resistance.
I've read some things on the Lagrangian dual approach. Here is an example:
The problem is to minimize $\frac{1}{2}(x_1-1)^2+\frac{1}{2}(x_2-1)^2$ with $x_1+x_2 < 1$ and $x_1>0$.
First here is the Lagrangian of the problem:
$$L(x_1,x_2,\lambda_1,\lambda_2)=\frac{1}{2}(x_1-1)²+\frac{1}{2}(x_2-1)^2 + \lambda_1(x_1+x_2-1)-\lambda_2 x_1$$
We have to find the root of derivate of $L$ regarding the prime-variables $x_1$ and $x_2$. The following are called the "primal-dual relations":
$$\begin{align} \frac{\partial L}{\partial x_1} &= (x_1-1)+\lambda_1 x_1 - \lambda_2 \\ \frac{\partial L}{\partial x_2} &= (x_2-1)+\lambda_1 x_2 \\ \therefore x_1 &= 1 - \frac{\lambda_1 - \lambda_2}{2} \\ x_2 &= 1 - \frac{\lambda_1}{2} \end{align}$$
Whith these relations, the dual fonction can be written as:
$$l(\lambda_1,\lambda_2)= -\frac{\lambda_1^2}{2}-\frac{\lambda_2^2}{4} + \frac{\lambda_1 \lambda_2}{2} + \lambda_1 - \lambda_2$$
We have then to maximize the function in terms of $\lambda_1$ and $\lambda_2$. When this $\lambda$ couple is found and with the primal-dual relations, we get back to the optimal $x_1$ and $x_2$.
Here are some questions:
Can I solve my optimization problem following this methodology?
I don't know how to do it because my cost and constraints functions are implicit (I cannot analytically derivate them toward the X-Y coordinates of my moving node).
I've writting my Lagrangian function as follows:
$$\begin{align} L(X,\lambda_1, \lambda_2, \lambda_3, \lambda_4) = &\mathrm{weight}(X) - \\ &\lambda_1(400-\mathrm{abs}(\mathrm{stress1}(X))) -\\ &\lambda_2(400-\mathrm{abs}(\mathrm{stress2}(X))) -\\ &\lambda_3(400-\mathrm{abs}(\mathrm{stress3}(X))) -\\ &\lambda_4(400-\mathrm{abs}(\mathrm{stress4}(X))) \end{align}$$
I have a Lagrangian multiplier per truss and the stress() functions give the nominal stress in each truss.
Do you think this is properly defined?
I've set $l_1\ldots l_4=1$ at the beginning, I've found the $x\ast$ and $y\ast$ that root the derivative toward $x_1$ and $x_2$. But then, I don't know what to do with these values because these are implicit relations, I don't have my primal-dual relations, isn't it?
Also, do I have to do something when my Lagrangian multipliers are negative or something?

