-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Description
General comments:
These are mainly observations looking at the examples.
- The new version of JuMP will make this whole package much easier
You will be able to have something like the following (just making syntax up, not an actual model)
emp = EMPModel(agent_models = n)
@variable(emp, x[i=1:n] >= 0)
@constraint(emp, [i=1:n], x[i] in AgentModel(i))
@constraint(emp, sum(x) >= 1)
for (i, agent) in enumerate(agents(emp))
@agentobjective(agent, Min, x[i])
end
@variable(emp, y)
@constraint(emp, (x[1], y) in VariationalPair())- I'm not sure that there is need to support Convex going forward. The new JuMP/MOI is converging towards DCP. This removes a whole heap of the conditional code loading.
- Have you seen https://github.com/StructJuMP/StructJuMP.jl? This also has multiple models with different scoping.
- Have you seen https://github.com/jalving/Plasmo.jl?
- The is the approach I would favour is almost identical to Plasmo. There are scoping issues that need to overcome, but these are just Julia problems:
agent_models = [JuMP.Model() for i in 1:2]
for agent in 1:2
# x belongs to agent_model[i]
@variable(agent_model[i], x >= 0)
@objective(agent_model[i], Min, x)
end
# x is now x[2]
emp = EMPModel(agent_models)
# but we can get x[1] via agent_models[1][:x]
@empconstraint(emp, sum(m[:x] for m in agent_models) >= 1)
solve(emp)or
agent_models = [JuMP.Model() for i in 1:2]
x = Dict{Int, JuMP.Variable}()
for i in 1:2
x[i] = @variable(agent_model[i], lower_bound = 0)
@objective(agent_model[i], Min, x[i])
end
# now we have x[1] and x[2]
emp = EMPModel(agent_models, solver=JAMSDSolver())
@empconstraint(emp, sum(x[i] for i in 1:2) >= 1)
solve(emp)It's then up to EMPModel to combine the models on the back end.
Pedantic comments:
A lot of the code design stems from the limitations of the current form of JuMP and MPB. Hence the need for the MOI redesign. The new JuMP NL implementation splits out the linear constraints from the non-linear constraints which should help resolve
Line 374 in 36d877d
| # TODO(xhub) fix this mess ... |
- You don't need to export
getsolutionetc.Line 16 in 36d877d
export @variableMP, @objectiveMP, @NLobjectiveMP, @constraintMP, @NLconstraintMP, vipair, @NLvipair, solveEMP, _solveEMP, MathPrgm, addvar!, addequ!, addovf!, getsolution, status, get_solve_result, get_solve_result_num, get_model_result, get_model_result_num, get_solve_message, get_solve_exitcode, solve
Instead of making new methods, you should import them from MPB and extend them. - In SDDP.jl, I make the user go
using SDDP, JuMP. You could also look into the https://github.com/simonster/Reexport.jl - proposal. Change all the
@constraintMPet at. macros to@empconstraint,@empnlconstraint. - For
Line 171 in 36d877d
code = :( v = @eval @variable $(mp).emp.model_ds )
you probably want something like
https://github.com/odow/SDDP.jl/blob/be885b296741b3f3ec89659aea796492290445fc/src/states.jl#L116
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels