I am trying to tweak JuMP so that I can specify and query some more specific stuff that I can not currently do with inbuilt JuMP functions and macros. See the example below:
First, I want to specify the ‘kind’ of variable I am defining. For example, in the snippet below, x[1:2]
are stage-1
variables, and y[1:5]
are stage-2
variables. So, I want to be able to specify these ‘kinds’ when declaring the variables. I understand one way is to do is as shown here; however, I would also be want to able to retrieve the variables of particular ‘kind’ later, and of course, solve a JuMP model with these new variables involved. See the code snippet below; it summarizes what I am trying to do.
using JuMP
model = Model(CPLEX.Optimizer)
#Be able to declare the 'kind' of variable
@variable(model, x[1:2] >= 0, stage1)
@variable(model, y[1:5] >= 0, stage2)
#Be able to retrieve the variable and their 'kind'
stage1_var(model) #should return x[1], x[2]
stage2_var(model) #should return y[1],..., y[5]
@constraint(model, x[1]+y[3] <= 3)
@constraint(model, x[2]+y[5] <= 10)
@objective(model, Min, sum(x[i] for i=1:2) + sum(y[i] for i=1:5))
#Be able to solve a JuMP model with the above 'new' type of variables defined
optimize!(model)
Additionally, after solving this model, I would want to use this JuMP model
variables (not their values) in another JuMP model with additional variables and constraints. How do I ‘transfer’ these variables from one model to another?
Can someone guide me on how to proceed with this, and what would be a good approach to achieve this? Any help is appreciated.
I have used JuMP to solve models before, but I am very new to extending JuMP models. I have found myself spending lots of time reading other packages and documentation. While I continue to do so, I would really appreciate ideas and feedback from people who have worked extensively with these kinds of problems. Thanks a lot!