# Optimal values dynamic programming and mathematical programming

4 views (last 30 days)
Luca Repetto on 31 Jul 2021
Commented: Luca Repetto on 3 Aug 2021
Hello,
I have a problem where I have to minimize the weighted tardiness of 10 jobs on one machine.
With a dynamic programming algorithm I have found that the optimal cost is 102.
To verify the correctness of the algorithm I implemented the same problem in mathematical programming and the solution, in the field of fval, has the value of 154.4.
Do you think that the fval value is the same of the cost that I've found in dynamic programming or is another different value?

John D'Errico on 31 Jul 2021
The crystal ball is very foggy today. What does it matter what we think? We know nothing about what you actually did, if the code you wrote is correct. So what we think is a bit irrelevant.
What do we know? We know that you tried to solve a problem with potentially multiple local minima. You tried to solve it twice, and you got differnt results. That MAY be due to the fact that different solvers can converge to different solutions. It may just mean you totally screwed something up, and you did not really solve the same problem twice you think you were solving. Hey, it does happen, far more often than you may "think". In fact, that is quite common. But it is also common for solvers to not converge to the same solution.
So as a guess, I "think" you don't understand that different solvers can converge to various local minima. Even running the same solver twice can do that, since some solvers are stochastic in nature.
If you really want more information, I can consult my MATLAB tarot cards, perhaps read some tea leaves. :) If you want a better response, then you would need to actually show the code you used and wrote, along with any necessary data, so that someone could verify what you did.
Luca Repetto on 3 Aug 2021
I'm sorry if I wasn't clear with the question.
Can you tell me, what value represents fval in the syntax of an optimization problem like this?
prob = optimproblem;
[sol, fval, output] = solve(prob);

R2021a

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!