Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Performance enhance (Direct Model) #768

Closed
Thuener opened this issue Jul 31, 2024 · 2 comments
Closed

Performance enhance (Direct Model) #768

Thuener opened this issue Jul 31, 2024 · 2 comments

Comments

@Thuener
Copy link
Collaborator

Thuener commented Jul 31, 2024

I'm dealing with a very big model and trying to increase its performance. I saw some mentions of direct_model in the code. Can we use the JuMP direct model with SDDP? Even with binary and Interger variables? What are the implications of using it?

@odow
Copy link
Owner

odow commented Jul 31, 2024

Use the undocumented

direct_mode::Bool = false,

model = SDDP.PolicyGraph(; direct_mode = true, optimizer = Gurobi.Optimizer) do sp, node
    # ...
end

What are the implications of using it?

Sometimes faster, sometimes slower. Always lower memory usage. Sometimes it will error. You're usually safe with Gurobi though.

@odow
Copy link
Owner

odow commented Aug 5, 2024

Note that

# These arguments are deprecated
bellman_function = nothing,
direct_mode::Bool = false,

I realized the reason:

SDDP.jl/src/algorithm.jl

Lines 295 to 306 in 73dd799

function attempt_numerical_recovery(model::PolicyGraph, node::Node)
if JuMP.mode(node.subproblem) == JuMP.DIRECT
@warn(
"Unable to recover in direct mode! Remove `direct = true` when " *
"creating the policy graph."
)
else
model.ext[:numerical_issue] = true
MOI.Utilities.reset_optimizer(node.subproblem)
optimize!(node.subproblem)
end
if !_has_primal_solution(node)

We can't attempt numerical recovery, and it is common enough that the problems I used direct-mode on just led to problems.

So I think I'm going to close this as won't-fix. You can use it if you want, but I don't want to document it for less-experienced users 😄

@odow odow closed this as completed Aug 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants