Time varying constrained optimization

Dear Julia community,

This is Edgar a completely newbie in Julia that has been looking for an alternative to R and Matlab for solving optimization problems. After reading some examples available at JuliaOpt I think that is the right tool for solving my problem. However I did not fin anything relating with my specific question mentioned in the title.

Giving some context I am trying to solve the unit commitment problem . Lets denote G as the set containing generator g=1,2… and T the set containing the number of periods t=1,2… of the optimization.

My problem is that despite of having defined my objetive function (which is basically the fuel costs + the startup/shutdown costs) and the prediction of all my constrains (which basically are the power demand + the maximum available capacity depending on the weather conditions) I do not know how to implement that my lower and upper bounds of the problem (min and max capacity) are changing over the time. Basically I want to implement that:

lb_i \leq x_it \leq ub_i

Will become:

lb_it \leq x_it \leq ub_it

Has anyone tried something like that before?

Thank you in advance

Welcome Edgar! I can only offer this: Put your latex equations into $ to render them.

1 Like

I think JuMP might be a better tool for the Unit Commitment problem, you’re going to use binary variables and will want to define your constraints in a convenient way. Give it a try with a MILP solver like Cbc or GLPK.

# add the required packages
# import into working environment
using JuMP
using Cbc: CbcSolver
# start playing 

See the doc for how to express constraints

better than what? :slight_smile: He was quoting JuliaOpt, the home of JuMP.

Oh that’s on me, my poor brain parsed “Optim” instead of JuliaOpt

m = Model(solver = ClpSolver())
# x[i,t]
@variable(m, x[1:2,1:3] >= 0)
upper_bounds = [10.0 12.5 13.5;14.0 15.0 16.0]
lower_bounds = [5.0 2.5 3.5; 4.0 1.0 1.0]
@constraint(m, [i=1:2,t=1:3], x[i,t] >= lower_bounds[i,t])
@constraint(m, [i=1:2,t=1:3], x[i,t] <= upper_bounds[i,t])

An even simpler way is just:

m = Model()
@variable(m, lower_bounds[i,t] <= x[i=1:2, t=1:3] <= upper_bounds[i,t])

Sorry Mauro! I forgot to write the $, my fault :sweat_smile:

I did not express myself correctly. I was saying that Julia will be a better tool than R. For the moment all the pre-built optimization packages that I have tried (NLoptr, ROI, NlcOptim etc) did not allow these options. My original idea was to implement the lagrangian relaxation myselft (and I did it) but the program is quite slow and I have to select a duality gap to big.