# Nested optimisation problem in JuMP

**URL:** <https://discourse.julialang.org/t/nested-optimisation-problem-in-jump/107409>\
**Category:** Optimization (Mathematical)\
**Tags:** jump\
**Created:** [December 11, 2023, 3:32am UTC](https://discourse.julialang.org/t/nested-optimisation-problem-in-jump/107409 "2023-12-11T03:32:31Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![odow](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/odow/32/28685_2.png) [@odow](https://discourse.julialang.org/u/odow)\
**Post date:** [December 14, 2023, 10:51pm UTC](https://discourse.julialang.org/t/nested-optimisation-problem-in-jump/107409/6 "2023-12-14T22:51:00Z")

</div>

> Thank you for the generous help, it is greatly appreciated as I’ve been scratching my head thinking about this one for a while (and am new to Julia and JuMP).

No problem.

> I have added a dimension to the y and u matrices to accommodate the multiple networks.  
> it essentially repeats the tsp for each source on the same static distance matrix for all the nodes

This seems like the right approach for now. See also:

> [@Subtour elimination constraints](https://discourse.julialang.org/t/subtour-elimination-constraints/106902/11):
>
> I don’t understand what the y and z variables are doing, but this should point you in the right direction. (Assuming k is the different busses, that each must do a tour?) using JuMP, Gurobi c = [0.0 3.16 1.41 1.0 2.24 3.16 0.0 4.0 3.61 4.12 1.41 4.0 0.0 2.24 1.0 1.0 3.61 2.24 0.0 3.16 2.24 4.12 1.0 3.16 0.0] s = [0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 0 0 0 1 0 0 0 0 1 0 0 1 1 0 1 1 0 1 0 0 0 0 1 1 0 0 1 0 0 0 1 1 1 0 0] V = 1:size(c, 1) C, S, n = 10, 1:size(s…

> Is there a way to modify the constraints such that the TSP is run iteratively

There are other formulations, see [Traveling Salesperson Problem · JuMP](https://jump.dev/JuMP.jl/stable/tutorials/algorithms/tsp_lazy_constraints/), but I’d caution against jumping (if you will) straight to that. I’d get the MTZ formulation working for small instances, and then go from there once you have a handle on the problem.

---

_[View the full topic](https://discourse.julialang.org/t/nested-optimisation-problem-in-jump/107409)._
