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

[MSPFormat] Can't read Problem Instance 10 (Inventory Problem with Lead Time) from MSPLib-Library #785

Closed
jk27182 opened this issue Sep 17, 2024 · 2 comments · Fixed by #786

Comments

@jk27182
Copy link

jk27182 commented Sep 17, 2024

Using the collection of problem in the MSPLib-Library, I ran into some problems reading the problem instance 10, the Inventory Problem with lead time, using

model = SDDP.MSPFormat.read_from_file(path)

with the appropriate path, which lead to
ERROR: AssertionError: term["stage"] == stage - 1

It occurs on all problem instances for problem 10, for every discretization.
Other problems, such as 4, 9 or 18 work without a problem.

I used SDDP.jl v1.7.0

@odow
Copy link
Owner

odow commented Sep 17, 2024

This instance contains state variables from previous stages other than the prior stage:

julia> import JSON

julia> data = JSON.parsefile("/Users/Oscar/Downloads/Problem_10/(10_0)_100.problem.json")
Dict{String, Any} with 5 entries:
  "name"        => "(10_0)_100"
  "variables"   => Any[Dict{String, Any}("name"=>"buy", "obj"=>Any[-3.0], "lb"=>Any[0.0], "ub"=>Any[1000.0], "stage"=>0, "type"=>"CONTINUOUS"), Dict{String, Any}("name"=>"sell", "obj"=>Any[5.0], "lb"=>Any[0.0], "ub"=>Any[Dict{String, 
  "constraints" => Any[Dict{String, Any}("name"=>"", "rhs"=>Any[0.0], "lhs"=>Any[Dict{String, Any}("name"=>"sell", "stage"=>0, "coefficient"=>Any[1.0]), Dict{String, Any}("name"=>"inventory", "stage"=>0, "coefficient"=>Any[-1.0])], "t…
  "version"     => "MSMLP 1.1"
  "maximize"    => true

julia> stages = map(data["constraints"]) do c
           return unique([term["stage"] for term in c["lhs"]])
       end
100-element Vector{Vector{Int64}}:
 [0]
 [0]
 [1]
 [1, 0]
 [2]
 [2, 1]
 [3]
 [3, 2]
 [4]
 [4, 3]
 [5]
 [5, 4]
 [6]
 [6, 5]
 [7]
 [7, 6]
 [8]
 [8, 7]
 [9]
 [9, 8]
 [10]
 [10, 9, 0]
 [11]
 [11, 10, 1]
 [12]
 [12, 11, 2]
 [13]

 [37]
 [37, 36, 27]
 [38]
 [38, 37, 28]
 [39]
 [39, 38, 29]
 [40]
 [40, 39, 30]
 [41]
 [41, 40, 31]
 [42]
 [42, 41, 32]
 [43]
 [43, 42, 33]
 [44]
 [44, 43, 34]
 [45]
 [45, 44, 35]
 [46]
 [46, 45, 36]
 [47]
 [47, 46, 37]
 [48]
 [48, 47, 38]
 [49]
 [49, 48, 39]

julia> filter!(x -> length(x) > 1, stages)
49-element Vector{Vector{Int64}}:
 [1, 0]
 [2, 1]
 [3, 2]
 [4, 3]
 [5, 4]
 [6, 5]
 [7, 6]
 [8, 7]
 [9, 8]
 [10, 9, 0]
 [11, 10, 1]
 [12, 11, 2]
 [13, 12, 3]
 [14, 13, 4]
 [15, 14, 5]
 [16, 15, 6]
 [17, 16, 7]
 [18, 17, 8]
 [19, 18, 9]
 [20, 19, 10]
 [21, 20, 11]
 [22, 21, 12]
 [23, 22, 13]
 [24, 23, 14]
 [25, 24, 15]
 [26, 25, 16]
 [27, 26, 17]
 [28, 27, 18]
 [29, 28, 19]
 [30, 29, 20]
 [31, 30, 21]
 [32, 31, 22]
 [33, 32, 23]
 [34, 33, 24]
 [35, 34, 25]
 [36, 35, 26]
 [37, 36, 27]
 [38, 37, 28]
 [39, 38, 29]
 [40, 39, 30]
 [41, 40, 31]
 [42, 41, 32]
 [43, 42, 33]
 [44, 43, 34]
 [45, 44, 35]
 [46, 45, 36]
 [47, 46, 37]
 [48, 47, 38]
 [49, 48, 39]

For example, one constraint contains variables from stage 10, stage 9, and stage 0.

SDDP.jl cannot read these files.

I'll improve the error message.

@odow
Copy link
Owner

odow commented Sep 18, 2024

I've marked #786 as "closing" this issue.

I have no plans to complicate the MSPFormat reader to handle state variables from other nodes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants