A person with weight *Q* stands on a ladder. This ladder is leaning against a vertical wall. What is the maximum position *x* this person can reach before the ladder starts sliding? This *ladder against a wall problem* is depicted in the following figure (with on the right-hand side a free body diagram).

The following R code demonstrates how to use linear programming for solving the ladder against the wall problem.

Note that the ladder against the wall problem (and its analytical solution) is described by Gross and colleagues in their 2013 book *Engineering mechanics 1: statics* (2nd. Ed.).

For readers interested in linear programming, I would like to refer to the excellent introduction by Doris Lloyd Grosh in her 2010 book *Linear programming for beginners*.

Suggestions and/or questions? Please contact Stefan Gelissen (email: info at datall-analyse.nl).

See this page for an overview of all of Stefan’s *R code* blog posts.

**Frictionless wall**

For solving the ladder against a wall problem we need to express 1) the equilibrium conditions, and 2) the conditions of static friction.

If the ladder is leaning against a frictionless wall, we can state the following 3 equilibrium conditions (see figure above, and note that the force *H _{b}* is zero since there is no friction between the wall and the top of the ladder):

1) The sum of the forces in the horizontal direction: *N _{b} – H_{a} = 0*

*2) The sum of the forces is the vertical direction:*

*N*

_{a}– Q = 03) The sum of the moments about point A:

*x*Q – h*N*

_{b}= 0The condition of static friction (in case of a rough floor and frictionless wall) is expressed as:

*H _{a} ≤ μ_{floor}*N_{a}* (where

*μ*is the static friction coefficient between the floor and the base of the ladder).

_{floor}It is also possible to formulate the same problem as a ** maximization problem**:

Maximize the objective function: *x = (h/Q)*N _{b}*

Subject to the 3 constraints:

1) *N _{b} – H_{a} = 0*

2)

*N*

_{a}= Q3)

*H*

_{a}– μ_{floor}*N_{a}≤ 0This maximization problem can be solved using

**.**

*linear programming***R code**

```
library(lpSolve)
#initialize values
Q <- 70*9.81 #person has a mass of 70kg
h <- 2
mu <- .5 #static friction coefficient between floor and ladder
#angle between ladder and wall
alpha <- 30
#convert degrees to radians (by multiplying with pi/180), and calculate tangent of angle
tanAlpha <- tan(alpha*pi/180)
#specify linear programming problem
#objective function:
#x = (h/Q)*Nb+0*Ha+0*Na
fObj <- c(h/Q,0,0)
names(fObj) <- c("Nb", "Ha", "Na")
#constraints:
#1*Nb-1*Ha+0*Na=0
#0*Nb+0*Ha+1*Na=Q
#0*Nb+1*Ha-mu*Na<=0
fConstr <- matrix(c(1,-1,0,0,0,1,0,1,-mu), nrow=3, byrow=TRUE)
fDir <- c("==", "==", "<=")
fRhs <- c(0,Q,0)
names(fRhs) <- c("c1", "c2", "c3")
#solve linear programming problem using the revised simplex method
solLp <- lp("max", fObj, fConstr, fDir, fRhs)
solLp
#max value (=x) of objective function
solLp$objval
#note: this value is identical to the analytical solution (which is: x<=mu*h)
#also note that the analytical solution of the distance x depends only
#on the static friction coefficient (mu) and the height (h),
#but not on the weight (Q) of the person
#similarly, the linear programming solution for x also depends only on mu and h,
#and not Q (try it yourself!)
#reaction forces (Nb, Ha, Na, respectively) at optimal solution
solLp$solution
#the computed distance x for our problem is 1
#the ladder starts sliding if the person exceeds this distance of 1
#in our case this is a potentially dangerous situation since the
#distance b (see figure) is equal to
h*tanAlpha
#this distance b is larger than the computed distance x
#hence, stability of the ladder is not ensured!
```

*Friction between the ladder and both the floor and wall*

If both the floor and wall have rough surfaces, then we can state the following 3 equilibrium conditions (again, see figure above):

1) The sum of the forces in the horizontal direction: *N _{b} – H_{a} = 0*

2) The sum of the forces is the vertical direction:

*N*

_{a}+ H_{b}= Q3) The sum of the moments about point A:

*x*Q – h*N*

_{b}– (h*tan(α))*H_{b}= 0The conditions of static friction in case of a rough wall and floor are expressed as:

*H*_{b}≤ μ_{wall}*N_{b}

where μ_{wall}is the static friction coefficient between the wall and the top of the ladder*H*_{a}≤ μ_{floor}*N_{a}

where μ_{floor}is the static friction coefficient between the floor and the base of the ladder.

Note that this is a *statically indeterminate* problem (i.e., 3 equilibrium equations, yet 4 unknown reaction forces). According to Gross et al. is solving this problem not straightforward. However, once we formulate this problem as a ** maximization problem** it is possible to solve it using

**:**

*linear programming*Maximize the objective function: *x = (h/Q)*N _{b} + ((h*tan(α))/Q)*H_{b}*

Subject to the 4 constraints:

1) *N _{b} – H_{a} = 0*

2)

*N*

_{a}+ H_{b}= Q3)

*H*

_{b}– μ_{wall}*N_{b}≤ 04)

*H*

_{a}– μ_{floor}*N_{a}≤ 0**R code**

```
library(lpSolve)
#initialize values
Q <- 70*9.81
h <- 2
muFloor <- .5
muWall <- 1.2
alpha <- 30
tanAlpha <- tan(alpha*pi/180)
#objective function:
#x = ((h*tanAlpha)/Q)*Hb+(h/Q)*Nb+0*Ha+0*Na
fObj <- c((h*tanAlpha)/Q,h/Q,0,0)
names(fObj) <- c("Hb", "Nb", "Ha", "Na")
#constraints:
#0*Hb+1*Nb-1*Ha+0*Na=0
#1*Hb+0*Nb+0*Ha+1*Na=Q
#1*Hb-muWall*Nb+0*Ha+0*Na<=0
#0*Hb+0*Nb+1*Ha-muFloor*Na<=0
fConstr <- matrix(c(0,1,-1,0,1,0,0,1,1,-muWall,0,0,0,0,1,-muFloor), nrow=4, byrow=TRUE)
fDir <- c("==", "==", "<=", "<=")
fRhs <- c(0,Q,0,0)
names(fRhs) <- c("c1", "c2", "c3", "c4")
#revised simplex method
solLp <- lp("max", fObj, fConstr, fDir, fRhs)
solLp
#max value (=x) of objective function
#again, the linear programming solution for x depends only on muFloor, muWall, and h,
#but not on Q (try it yourself!)
solLp$objval
#reaction forces (Hb, Nb, Ha, Na, respectively) at optimal solution
solLp$solution
#despite the roughness of the wall, our problem situation is still potentially dangerous
#remember that the distance b (see figure) is equal to
h*tanAlpha
#and this distance b is larger than the computed distance x (=1.06)
#thus, stability of the ladder is still not ensured!
```

*Next blog post?*

In my next blog post I will present a solution strategy (including R code) for finding the minimum angle such that a ladder doesn’t slip down.