# How to write a master-subproblem iterative algorithm asynchronously?

**URL:** <https://discourse.julialang.org/t/how-to-write-a-master-subproblem-iterative-algorithm-asynchronously/131853>\
**Category:** General Usage\
**Tags:** question, async\
**Created:** [August 26, 2025, 11:45am UTC](https://discourse.julialang.org/t/how-to-write-a-master-subproblem-iterative-algorithm-asynchronously/131853 "2025-08-26T11:45:35Z")\
**Posts on this page:** 1\
**Showing post:** 30

<div class="post-metadata">

**Author:** ![WalterMadelim](https://avatars.discourse-cdn.com/v4/letter/w/3e96dc/32.png) [@WalterMadelim](https://discourse.julialang.org/u/WalterMadelim)\
**Post date:** [August 31, 2025, 11:53am UTC](https://discourse.julialang.org/t/how-to-write-a-master-subproblem-iterative-algorithm-asynchronously/131853/30 "2025-08-31T11:53:14Z")

</div>

> [@odow](#):
>
> It’s pretty much what you’re trying to write.

Well, to be honest I found few likeness.

Are your `SDDP.jl` scenario tree based, IIRC? Therefore you have the _node_ concept.  
Multistage stochastic programs (MSSP) are very hard to solve to optimality. (Actually my problem can be deemed a Two stage 1 scenario MIP with `J` blocks. My problem is already hard when `J` is large, let alone `>2` stage multiple scenarios.)

Seems you’re using the `Distributed` module. I currently have no idea about it.

Your algorithm:

```julia-auto
@sync for _ in 1:max_threads
        Threads.@spawn begin

```

where `max_threads` is hardware based. By comparison, my algorithm is hardware-agnostic (as long as there are multiple logical processors). And you used `@sync`, which I hadn’t use it, neither `wait` the subproblem tasks. You made use of `Channel`s, but I didn’t (as my comment in the #25 post).

One thing I’m most curious about: how can you run multiple forward-backward pass? Is this meaningful? i.e. Can the SDDP training algorithm be run in parallel?

Well, actually not that curious, since I’m not that interested on MSSP anymore. (Therefore you can opt to neglect my questions… (I’m somewhat not very spirited on this.))

* * *

Generally speaking, I think `JuMP` is more flexible than `SDDP.jl` (or some other extension packages). I find it relatively easy to write algorithms with `JuMP`—although it as well takes me years to get familiar with it. I was a noob with little experience [then](https://discourse.julialang.org/t/columns-and-constraints-generation/103813/4). But happily I’ve gained quite a few proficiency now.

> I’m unsure if I’m the first to try writing such an asynchronous cutting plane algorithm.

I’m also okay being the second.

---

_[View the full topic](https://discourse.julialang.org/t/how-to-write-a-master-subproblem-iterative-algorithm-asynchronously/131853)._
