# How to create a rolling horizon approach?

**URL:** <https://discourse.julialang.org/t/how-to-create-a-rolling-horizon-approach/117269>\
**Category:** New to Julia\
**Tags:** question\
**Created:** [July 20, 2024, 10:12am UTC](https://discourse.julialang.org/t/how-to-create-a-rolling-horizon-approach/117269 "2024-07-20T10:12:14Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jeroen\_Schilder](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jeroen_schilder/32/210784_2.png) [@Jeroen\_Schilder](https://discourse.julialang.org/u/Jeroen_Schilder)\
**Post date:** [July 20, 2024, 10:12am UTC](https://discourse.julialang.org/t/how-to-create-a-rolling-horizon-approach/117269/1 "2024-07-20T10:12:14Z")

</div>

Hi guys, I failed my first attempt for my bachelor thesis ☹ , luckily I got a chance to correct my failings, and I have to give a Julia model (link below) a ‘rolling horizon approach’, where an agents optimizes for one year at the time instead of optimizing for the whole period of the model. I’m just stuck on how to do it, is there somebody who can help me out? Please send me a message! Much appreciated! [KU Leuven Energy Systems Integration and Modeling group / ETS - NC · GitLab](https://gitlab.kuleuven.be/UCM/ets-ncc)

---

<div class="post-metadata">

**Author:** ![abraemer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/abraemer/32/51403_2.png) [@abraemer](https://discourse.julialang.org/u/abraemer)\
**Post date:** [July 20, 2024, 12:28pm UTC](https://discourse.julialang.org/t/how-to-create-a-rolling-horizon-approach/117269/2 "2024-07-20T12:28:17Z")

</div>

Hi there,  
I don’t think you will someone here that will do the work for you - if that is what you intended to ask. It would also miss the point of doing a Bachelor’s and probably break rules.

However if you have specific questions about code or how to approach an implementation and can show that you tried some things and you will find a lot of helpful persons in this place 🙂 But you need to put in effort yourself!

> [@Jeroen\_Schilder](#):
>
> I’m just stuck on how to do it

So what are you stuck on? What have you tried? What is your current understanding? Post some code you don’t understand and try to be as specific as possible as to what you don’t understand.

---

<div class="post-metadata">

**Author:** ![Jeroen\_Schilder](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jeroen_schilder/32/210784_2.png) [@Jeroen\_Schilder](https://discourse.julialang.org/u/Jeroen_Schilder)\
**Post date:** [July 20, 2024, 1:20pm UTC](https://discourse.julialang.org/t/how-to-create-a-rolling-horizon-approach/117269/3 "2024-07-20T13:20:53Z")

</div>

Thanks for your answer,

It was not my intention to have someone else do the work; I apologize if it was interpreted that way. I’ll try to be more precise.

What I have tried so far is replacing the solving function **SOLVE\_repr\_agent!(mod)** with a preliminary loop (for year in 1:data[“nyears”]  
optimize\_single\_year(year, mod, data, scenario\_overview\_row, ETS)  
Update the data and parameters for the next year,(?)  
update\_parameters\_and\_constraints  
println(“Optimizing year $(year)…”)  
end)

I have one auxiliary function for the optimization of one year:  
function optimize\_single\_year(year, mod, data, scenario\_overview\_row, ETS)  
set\_time\_horizon(mod, year)  
update\_parameters\_and\_constraints!(mod, data, scenario\_overview\_row, ETS, year)  
optimize!(mod)  
return  
end

I’m not sure where to update the parameters and how to set the time\_horizon, but I understand that it needs to be more concrete before I can get help.
