# Different objective state functions for different stages SDDP.jl

**URL:** <https://discourse.julialang.org/t/different-objective-state-functions-for-different-stages-sddp-jl/116812>\
**Category:** Optimization (Mathematical)\
**Tags:** sddp\
**Created:** [July 9, 2024, 8:47am UTC](https://discourse.julialang.org/t/different-objective-state-functions-for-different-stages-sddp-jl/116812 "2024-07-09T08:47:36Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![tumpelopumpelo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tumpelopumpelo/32/208489_2.png) [@tumpelopumpelo](https://discourse.julialang.org/u/tumpelopumpelo)\
**Post date:** [July 9, 2024, 8:47am UTC](https://discourse.julialang.org/t/different-objective-state-functions-for-different-stages-sddp-jl/116812/1 "2024-07-09T08:47:36Z")

</div>

Hi,

I am quite new to optimization with SDDP so may be a silly question. I am working on optimising a bidding strategy for a wind power producer in consecutive markets (day ahead, Intraday, ancillary) using SDDP, with uncertainty regarding market prices and wind generation. My current formulation relies on having different objective state update functions for different stages. However, I am not sure if this is supported. Am I able to do this, or do I have to come up with another alternative?

Thanks for the help!

---

<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:** [July 13, 2024, 12:33am UTC](https://discourse.julialang.org/t/different-objective-state-functions-for-different-stages-sddp-jl/116812/2 "2024-07-13T00:33:02Z")

</div>

Hi @tumpelopumpelo, welcome to the forum 😄

I take it you are meaning this: [Objective states · SDDP.jl](https://sddp.dev/stable/tutorial/objective_states/)?

The objective state must be the same inn every node, but you can have transition functions that depend on `t`. For example:

```julia
   SDDP.add_objective_state(
        subproblem,
        initial_value = 50.0,
        lipschitz = 10_000.0,
        lower_bound = 50.0,
        upper_bound = 150.0,
    ) do fuel_cost, ω
        if t < 10
            return ω.fuel * fuel_cost # multiplicative error
        else
            return fuel_cost + ω.fuel # additive error 
        end
    end

```

---

<div class="post-metadata">

**Author:** ![tumpelopumpelo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tumpelopumpelo/32/208489_2.png) [@tumpelopumpelo](https://discourse.julialang.org/u/tumpelopumpelo)\
**Post date:** [July 22, 2024, 6:42am UTC](https://discourse.julialang.org/t/different-objective-state-functions-for-different-stages-sddp-jl/116812/3 "2024-07-22T06:42:02Z")

</div>

Wonderful, thanks a lot! I implemented this now, however I am running into quite a strange error:

“Unable to write cuts to file because model contains objective states or belief states.”

Do you have any idea what could cause this?

---

<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:** [July 22, 2024, 7:31am UTC](https://discourse.julialang.org/t/different-objective-state-functions-for-different-stages-sddp-jl/116812/4 "2024-07-22T07:31:17Z")

</div>

You cannot write cuts to file if you use objective states.
