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

warmstart p.w.l. variable #21

Open
stumarcus314 opened this issue Jan 3, 2018 · 1 comment
Open

warmstart p.w.l. variable #21

stumarcus314 opened this issue Jan 3, 2018 · 1 comment

Comments

@stumarcus314
Copy link

Is it possible to warmstart a p.w.l. variable from a previous, related p.w.l. variable? When I use the code excerpt below to try this and set the solver to CBC, I get the error below. In the code below, the number of segments used in the p.w.l. variable log_x increases with each iteration.

WARNING: Ignoring partial starting solution. Cbc requires a feasible value to be specified for all variables.

Construct the piecewise linear approximation of log(x), log(y), and log(z).

num_seg = Array{UInt8}(3)
dx = Array{Array{Float64}}(3)
@variable(m,log_x[1:3]) # piecewise linear approximation of log(x)
@variable(m,log(lower_volume)<=log_volume<=log(upper_volume))
for iter=3:5

  ns = 2^iter
  num_seg[1] = ns # Number of segments used to approximate log x.
  num_seg[2] = ns # Number of segments used to approximate log y.
  num_seg[3] = ns # Number of segments used to approximate log z.

  for d=1:3
    dx[d] = linspace(getlowerbound(x[d]),getupperbound(x[d]),num_seg[d]+1)
    log_x[d] = piecewiselinear(m,x[d],dx[d],log,method=method)
  end
  #@constraint(m,log_volume == sum(log_x))
  #@objective(m,Min,log_volume)
  @objective(m,Min,sum(log_x))
  @time status = solve(m)

  sol_volume = prod(getvalue(x))
  println("solution volume: ",lower_volume," <= ",sol_volume," <= ",upper_volume)
  println("minimum volume: ",min_volume,". volume gap: ",sol_volume-min_volume,".")
  println("solution [x,y,z]: ",lower_x," <= ",getvalue(x)," <= ",upper_x)
  println("optimal [x,y,z]: ",opt_x)
end
@joehuchette
Copy link
Contributor

As the warning suggests, Cbc requires you to warmstart each variable. All the formulations in this package add additional variables, so you would need to warmstart those values that are hidden from you at the moment.

This would be a reasonable thing to implement in the future, but it's not a simple addition. It's also unclear how much warmstarting would improve your solution time, but you could experiment with a solver such as Gurobi that accepts partial warmstart solutions.

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

No branches or pull requests

2 participants