-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Retrieve disaggregated solution (#547)
* first draft without BD * Merge master into sol_disaggregation * fix ColumnInfo and start link with BD * add disagg_result & sps_info to Optimizer and use BD.getsolutions * use BD.value methods * remove sps_info and MOI methods for SpsInfo * improve test Co-authored-by: Guillaume Marques <[email protected]>
- Loading branch information
Showing
4 changed files
with
80 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
function sol_disaggregation_tests() | ||
I = 1:3 | ||
@axis(BinsType, [1]) | ||
|
||
w = [2, 5, 7] | ||
Q = 8 | ||
|
||
coluna = JuMP.optimizer_with_attributes( | ||
Coluna.Optimizer, | ||
"params" => Coluna.Params(solver = ColumnGeneration()), | ||
"default_optimizer" => GLPK.Optimizer | ||
) | ||
|
||
model = BlockModel(coluna) | ||
|
||
@variable(model, x[k in BinsType, i in I], Bin) | ||
@variable(model, y[k in BinsType], Bin) | ||
|
||
@constraint(model, sp[i in I], sum(x[k, i] for k in BinsType) == 1) | ||
@constraint(model, ks[k in BinsType], sum(w[i] * x[k, i] for i in I) - y[k] * Q <= 0) | ||
|
||
@objective(model, Min, sum(y[k] for k in BinsType)) | ||
|
||
@dantzig_wolfe_decomposition(model, dec, BinsType) | ||
subproblems = BlockDecomposition.getsubproblems(dec) | ||
specify!.(subproblems, lower_multiplicity = 0, upper_multiplicity = BD.length(I)) # we use at most 3 bins | ||
|
||
JuMP.optimize!(model) | ||
|
||
for k in BinsType | ||
bins = BD.getsolutions(model, k) | ||
for bin in bins | ||
@test BD.value(bin) == 1.0 # value of the master column variable | ||
@test BD.value(bin, x[k, 1]) == BD.value(bin, x[k, 2]) # x[1,1] and x[1,2] in the same bin | ||
@test BD.value(bin, x[k, 1]) != BD.value(bin, x[k, 3]) # only x[1,3] in its bin | ||
@test BD.value(bin, x[k, 2]) != BD.value(bin, x[k, 3]) # only x[1,3] in its bin | ||
end | ||
end | ||
end |