#Graphical resolution of the Poet Problem
#Create one point
x<-0
y<-0

# Plot a graph with nothing
plot(x,y, type="n", xlim=c(0,80), ylim=c(0,80), main="The Poet Problem")

#Plot constraints
lines(c(40,40), c(0,100), col="Blue", lwd=2)
text(45,0,"x=40",col="Red")
lines(c(0,100), c(50,50), col="Blue", lwd=2)
text(5,52,"y=50",col="Red")
lines(c(0,90),c(60,0), col="Blue", lwd=2)
text(50,35,"2x+3y=180",col="Red")

polygon(c(0,0,15,40,40),c(0,50,50,100/3,0), col="Red")
points(c(0,0,15,40,40),c(0,50,50,100/3,0), pch=19, cex=2, col="Black")
text(c(0,0,15,40,40)+2,c(0,50,50,100/3,0)+5, c("O","A","B","C","D"))

#Plot objective function
# Either:

abline(0/120,-3/4, col="green", lwd=2, lty=3)
abline(2000/120,-3/4, col="green", lwd=2, lty=3)
abline(4000/120,-3/4, col="green", lwd=2, lty=3)
abline(6000/120,-3/4, col="green", lwd=2, lty=3)
abline(8000/120,-3/4, col="green", lwd=2, lty=3)
abline(10000/120,-3/4, col="green", lwd=2, lty=3)

abline(7600/120,-3/4, col="green", lwd=5, lty=1)

# or: 
for (z in seq(from=0,to=10000,by=2000)) abline(z/120,-3/4, col="green", lwd=2, lty=3)
for (z in seq(from=0,to=10000,by=2000)) text(0,z/120,z)

abline(7600/120,-3/4, col="green", lwd=5, lty=1)
text(0,7600/120,"7600")

