Hello, everyone, and this example is called heroin problem, so, um, we want to find out if we are
given two points like A and B and on the same side of a line called L, and we want to find out point
D, the green one on this graph in a way that the sum of the distances from A to D and also D to B are
minimal.
OK, the summation of the one plus the two are minimal.
What are the given parameters of the problem, the parameters, the data input data of the problem are
L h one and two.
OK, so both of these two quantities are known and the decision variables are X, D, one and D to actually
if we know the X, we know everything else.
OK, so the only decision variable is X in this problem.
OK, so let's write down to formulate the mathematical formulation minimization of D one plus the two
and subject to some constraints.
So on the first triangle you can see here, there is a relation between X and each one and the one X
squared plus each one is square is the one square and also on this triangle and L minus X which is here
squared plus two is square is equal to D to a square.
OK, so let's write it down in pie ten.
And first of all, like the other examples, we have to import the environment and then import non pi
if we need it.
And also we have to define a model here.
It's a concrete model and also the parameters of the model.
There are three parameters in this specific example L, H1 and H2 and we have to initialize them.
We have to tell Pisin that what are the values for them?
And also three variables.
The one D to annex.
Also the one on these two can be found using X, but since we don't know the quantity and the value,
we have to define them as valuable.
And also we need we know that the.
Arrange that one and you can change is between zero and L. OK, and we can initialize them as well.
And also an X variable is between Zero and Ellisville and initialize them as all of them equal to zero.
You can choose any other number.
And also we have to constrain C one and C to the constraint.
C one is telling us an expression equal model.
The one square is equal to model.
Each one is square plus model X is square.
And the second constraint is telling us and the two a square is equal to model actual square plus model
L minus X square.
OK, and the objective function is the summation of the one plus the two and the sense of optimization
is minimize.
Like every other optimization example, we have to run all the times one by one and then choose the
solver, which is obviously the problem is a nonlinear program because of the constraints, the constraints.
You can see the non-linearity terms.
OK, I run this one.
So I have a specify so far the solver for solving the problem and the results will contain the decision
variables, OK, and also the objective function.
So if I print the results, you can see here that the the one is three point eighty nine D2 is seven
point seventy seven and X is three point thirty three and F one is eleven point six six.
OK, and this is a non-linear kind of programming.
Thank you very much.