# How to train a biobjective problem with SDDP.jl?

**URL:** <https://discourse.julialang.org/t/how-to-train-a-biobjective-problem-with-sddp-jl/123590>\
**Category:** Optimization (Mathematical)\
**Tags:** question, jump, sddp\
**Created:** [December 8, 2024, 2:10pm UTC](https://discourse.julialang.org/t/how-to-train-a-biobjective-problem-with-sddp-jl/123590 "2024-12-08T14:10:16Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![z\_yt\_Yt](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/z_yt_yt/32/214013_2.png) [@z\_yt\_Yt](https://discourse.julialang.org/u/z_yt_Yt)\
**Post date:** [December 8, 2024, 2:10pm UTC](https://discourse.julialang.org/t/how-to-train-a-biobjective-problem-with-sddp-jl/123590/1 "2024-12-08T14:10:16Z")

</div>

Hello,

I am trying to run this [SDDP.jl/papers/biobjective\_sddp/BiObjectiveSDDP.jl at master · odow/SDDP.jl · GitHub](https://github.com/odow/SDDP.jl/blob/master/papers/biobjective_sddp/BiObjectiveSDDP.jl) and also other files in this folder [SDDP.jl/papers/biobjective\_sddp at master · odow/SDDP.jl · GitHub](https://github.com/odow/SDDP.jl/tree/master/papers/biobjective_sddp).

But I always get this warning, ERROR: UndefVarError: `SingleVariable` not defined in `MathOptInterface`  
Suggestion: check for spelling errors or missing imports.

Anyone know how to solve this??  
Thank you!!!

---

<div class="post-metadata">

**Author:** ![z\_yt\_Yt](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/z_yt_yt/32/214013_2.png) [@z\_yt\_Yt](https://discourse.julialang.org/u/z_yt_Yt)\
**Post date:** [December 8, 2024, 4:28pm UTC](https://discourse.julialang.org/t/how-to-train-a-biobjective-problem-with-sddp-jl/123590/2 "2024-12-08T16:28:25Z")

</div>

@odow Hi Oscar, could you please help me out here? Thank you!

---

<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 8, 2024, 8:10pm UTC](https://discourse.julialang.org/t/how-to-train-a-biobjective-problem-with-sddp-jl/123590/3 "2024-12-08T20:10:43Z")

</div>

This code was written for an older version of MathOptInterface.

I should have added version bounds to [SDDP.jl/papers/biobjective\_sddp/Project.toml at master · odow/SDDP.jl · GitHub](https://github.com/odow/SDDP.jl/blob/master/papers/biobjective_sddp/Project.toml), but I guess I didn’t 😬

Regardless, I don’t recommend that you run the code. What are you trying to do and why? The biobjective algorithm works in theory, but not very well in practice.

---

<div class="post-metadata">

**Author:** ![z\_yt\_Yt](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/z_yt_yt/32/214013_2.png) [@z\_yt\_Yt](https://discourse.julialang.org/u/z_yt_Yt)\
**Post date:** [December 8, 2024, 9:31pm UTC](https://discourse.julialang.org/t/how-to-train-a-biobjective-problem-with-sddp-jl/123590/4 "2024-12-08T21:31:07Z")

</div>

Thank you for the reply!

Oh I saw this file but I didn’t realize they are relevant. I will try again.

I am writing the master’s thesis, and the topic is to incorporating carbon emissions in multi-stage lot sizing model with stochastic demand. It can be modeled in two ways: 1. minimize cost and carbon emissions as a constraint; 2. minimize cost and carbon emissions same time as a bi-objective model. Both are linear integer problem.  
Thank you for asking! And I would appreciate any insights here on my topic 😊

---

<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 8, 2024, 9:43pm UTC](https://discourse.julialang.org/t/how-to-train-a-biobjective-problem-with-sddp-jl/123590/5 "2024-12-08T21:43:15Z")

</div>

The most useful part of the paper was:

- The idea of a bi-objective policy, and that you could use SDDP to build one
- The heuristic solution method from the last section.

The least useful part of the paper was the exact solution algorithm, since it relied on the internals of the solver, and was highly susceptible to numerical issues.

I’ve implemented the heuristic as `SDDP.train_biobjective`, but it isn’t well documented yet.

Take a look at this example: [Biobjective hydro-thermal · SDDP.jl](https://sddp.dev/stable/examples/biobjective_hydro/)

After training, you can use: `SDDP.set_trade_off_weight(model, weight)` to fix a particular weight and then simulate like you would with a single-objective problem.

Alternatively, you could also just solve a set of independent SDDP models for different scalarization weights.

---

<div class="post-metadata">

**Author:** ![z\_yt\_Yt](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/z_yt_yt/32/214013_2.png) [@z\_yt\_Yt](https://discourse.julialang.org/u/z_yt_Yt)\
**Post date:** [December 9, 2024, 10:28pm UTC](https://discourse.julialang.org/t/how-to-train-a-biobjective-problem-with-sddp-jl/123590/7 "2024-12-09T22:28:47Z")

</div>

Thank you for the valuable hints! I will think about them! Really appreciate that!

---

<div class="post-metadata">

**Author:** ![z\_yt\_Yt](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/z_yt_yt/32/214013_2.png) [@z\_yt\_Yt](https://discourse.julialang.org/u/z_yt_Yt)\
**Post date:** [January 12, 2025, 9:51pm UTC](https://discourse.julialang.org/t/how-to-train-a-biobjective-problem-with-sddp-jl/123590/8 "2025-01-12T21:51:07Z")

</div>

Hello Oscar @odow, I encountered another problem running the code. Here is part of the error message:

WARNING: replacing module BiObjectiveSDDP.  
WARNING: redefinition of constant thermal\_ub. This may fail, cause incorrect answers, or produce other errors.  
WARNING: redefinition of constant thermal\_lb. This may fail, cause incorrect answers, or produce other errors.  
WARNING: redefinition of constant thermal\_obj. This may fail, cause incorrect answers, or produce other errors.

It seems that there is something wrong about using the data in Brazilian\_data.jl and I don’t know how to get it right.  
Could you help me with this please? Thank you very much in advance!

---

<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:** [January 13, 2025, 12:59am UTC](https://discourse.julialang.org/t/how-to-train-a-biobjective-problem-with-sddp-jl/123590/9 "2025-01-13T00:59:13Z")

</div>

This warning happens when you `include("/path/to/file.jl")` a file multiple times. You shouldn’t do that.

---

<div class="post-metadata">

**Author:** ![z\_yt\_Yt](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/z_yt_yt/32/214013_2.png) [@z\_yt\_Yt](https://discourse.julialang.org/u/z_yt_Yt)\
**Post date:** [January 13, 2025, 11:15am UTC](https://discourse.julialang.org/t/how-to-train-a-biobjective-problem-with-sddp-jl/123590/10 "2025-01-13T11:15:05Z")

</div>

Thank you for the quick reply!

Strange, I have not changed anything in the .zip file I downloaded, but I am still getting this error.

I searched from “include” in the files in biobjective\_SDDP, no dulplicates as expected. I tried “if !@isdefined(BiObjectiveSDDP)  
include(joinpath(@ **DIR** , “BiObjectiveSDDP.jl”))  
end” as well, same error. I wonder what could be wrong here…

Besides, I should run “brazilian\_example.jl” right? And it is supposed to generate some content like “simple\_example.jl” does?

I really want to get this running, so far still trying haha

---

<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:** [January 13, 2025, 8:28pm UTC](https://discourse.julialang.org/t/how-to-train-a-biobjective-problem-with-sddp-jl/123590/11 "2025-01-13T20:28:35Z")

</div>

I assume that you are running this file multiple times:

> <https://github.com/odow/SDDP.jl/blob/master/papers/biobjective_sddp/brazilian_example.jl>

It has two includes:

> <https://github.com/odow/SDDP.jl/blob/aec55e2279c4abbd2a15ab1a430f6bb5a526976e/papers/biobjective_sddp/brazilian_example.jl#L6>

> <https://github.com/odow/SDDP.jl/blob/aec55e2279c4abbd2a15ab1a430f6bb5a526976e/papers/biobjective_sddp/brazilian_example.jl#L15>

You must include these files only once.

including the file does not produce output by default. It was intended to be run from the command line:

> <https://github.com/odow/SDDP.jl/blob/aec55e2279c4abbd2a15ab1a430f6bb5a526976e/papers/biobjective_sddp/brazilian_example.jl#L274-L314>

But I will caution you again: I don’t think there is value in attempting to run this code.

---

<div class="post-metadata">

**Author:** ![z\_yt\_Yt](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/z_yt_yt/32/214013_2.png) [@z\_yt\_Yt](https://discourse.julialang.org/u/z_yt_Yt)\
**Post date:** [January 14, 2025, 11:49pm UTC](https://discourse.julialang.org/t/how-to-train-a-biobjective-problem-with-sddp-jl/123590/12 "2025-01-14T23:49:08Z")

</div>

Thank you so much for the detailed answer!

I understood, I will definitely try to implement my model using the heuristic.

Really appreciate your help!
