# Writing an objective function such that the problem has an optimal solution

i know it's basic but I'm struggling with how to find the objective function of a linear program. How do i write an objective function given only two constraints of a linear program in three variables?

I need to be able to write down the objective function; as a unique optimal solution, such that the set is a line segment and that the solutions is a triangle.

(Note: i dont want to put my example up because it is my homework and i want to be able to get it myself, just after another example or a hint or step by step solution as to how i would go about this)

It really depends on your task. What should be optimized and how are the variables related to that objective. An objective function consists of at least one of your variables that is subject to minimization or maximization respectively. In case it consists of multiple variables, they must only be related to one another by addition or subtraction. You can only multiply variables with parameters in a linear model.

Make sure your variables are defined to be bigger or equal to 0 (especially for minimization). The value zero often makes sense because you cannot have a negative amount of money, crops, ... but other lower bounds could also be possible. Also, every variable must have a certain ceiling assigned to it (especially for maximization). It must not be allowed to surpass a certain value.

By this you ensure, that the objective cannot develop towards +/- infinity.

Lastly an infinite amount of solutions could exist, rather than one. This you could check manually.

Hope that helps - even though very generic.

Anton

## Edit:

Given $x,y,z \geq 0$ and $x+y+2z \leq 1$, as far I see it, many objective functions are possible. The unique optimal solution of those resulting problems, however, would have to be one corner of the polyeder in figure 1.

The blue plane is the graphical representation of $x+y+2z \leq 1$. As $x,y,z \geq 0$, the axes also span sides of the polyeder. The result is this pyramid (figure 1). Which corner of it is the unique optimal solution (if there is one) depends on your objective. Objective functions could be:

$min$ $x+y+z$ (the optimal solution would be in the origin (0,0,0))

$max$ $x$ (the optimal solution would be (1,0,0))

$max$ $2x+y$ (the optimal solution would be (1,0,0))

$max$ $x+2y$ (the optimal solution would be (0,1,0))

$max$ $x+y$ (infinite solutions, which lie on the line (edge of the polyeder) confined by the plane, the x- and y-axis.)

...

Figure 1: Constraints

• What if the constraints were $x+y+2z\le1$ and $x,y,z\ge0$ Then how do you find the objective function? – H4-math Mar 13 '18 at 23:16