-
Notifications
You must be signed in to change notification settings - Fork 18
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
Bpcg with direct solve #515
Conversation
* sparsifier active set * fix typo * added sparsifying tests * generic tolerane * remove sparsification * format * HiGHS dep
* sparsifier active set * start working on LP AS * first working quadratic * remove quadratic LP from current * cleanup * HiGHS in test deps * working reworked LP quadratic * working version generic quadratic * slow version generic quadratic * faster term manipulation * copy sufficient * remove comment * added test for quadratic * minor * simplify example * clean up code, verify error with ASQuad * Add update_weights! to fix direct solve with active_set_quadratic * remove direct solve from BPCG * rng changed --------- Co-authored-by: Sébastien Designolle <[email protected]>
reopened the branch from before |
MOI.empty!(o) | ||
λ = MOI.add_variables(o, nv) | ||
# λ ≥ 0, ∑ λ == 1 | ||
# MOI.add_constraint.(o, λ, MOI.GreaterThan(0.0)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
commented out the nonnegativity constraint
# Wolfe's pull back | ||
## Extract lambda values into a vector | ||
lambda_values = Vector{Float64}(undef, length(λ)) | ||
for idx in eachindex(λ) | ||
lambda_values[idx] = MOI.get(o, MOI.VariablePrimal(), λ[idx]) | ||
end | ||
|
||
## Load old weights into vector and do ratio test | ||
old_weights = as.weights | ||
tau_min = 1.0 | ||
for i in 1:length(lambda_values) | ||
if lambda_values[i] < old_weights[i] | ||
tau_min = min(tau_min, old_weights[i] / (old_weights[i] - lambda_values[i])) | ||
end | ||
end | ||
tau = tau_min | ||
|
||
# println("lambda_values: ", lambda_values) | ||
# println("tau: ", tau) | ||
|
||
## Compute new lambdas | ||
new_lambdas = Vector{R}(undef, length(lambda_values)) | ||
for i in 1:length(lambda_values) | ||
new_lambdas[i] = (1 - tau) * old_weights[i] + tau * lambda_values[i] | ||
end | ||
|
||
@assert all(0 .<= new_lambdas .<= 1) "All new_lambdas must be between 0 and 1" | ||
@assert isapprox(sum(new_lambdas), 1.0, atol=1e-5) "The sum of new_lambdas must be approximately 1" | ||
|
||
indices_to_remove = Int[] | ||
new_weights = R[] | ||
for idx in eachindex(λ) | ||
weight_value = new_lambdas[idx] # using new lambdas |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should implement wolfe's pullback. get the unconstrained solution. form the line segment between current solution and unconstrained solution. compute tau on the line so that you stay feasible. update lambda and use
active_set_quadratic_automatic_standard = FrankWolfe.ActiveSetQuadraticLinearSolve( | ||
FrankWolfe.ActiveSet([(1.0, copy(x00))]), | ||
grad!, | ||
MOI.instantiate(MOI.OptimizerWithAttributes(HiGHS.Optimizer, MOI.Silent() => true)), | ||
scheduler=FrankWolfe.LogScheduler(start_time=10, scaling_factor=1), | ||
) | ||
trajectoryBPCG_quadratic_automatic_standard = [] | ||
x, v, primal, dual_gap, _ = FrankWolfe.blended_pairwise_conditional_gradient( | ||
f, | ||
grad!, | ||
lmo, | ||
active_set_quadratic_automatic_standard, | ||
max_iteration=k, | ||
verbose=true, | ||
callback=build_callback(trajectoryBPCG_quadratic_automatic_standard), | ||
); | ||
|
||
|
||
active_set_quadratic_wolfe = FrankWolfe.ActiveSetQuadraticLinearSolveWolfe( | ||
FrankWolfe.ActiveSet([(1.0, copy(x00))]), | ||
grad!, | ||
MOI.instantiate(MOI.OptimizerWithAttributes(HiGHS.Optimizer, MOI.Silent() => true)), | ||
scheduler=FrankWolfe.LogScheduler(start_time=10, scaling_factor=1), | ||
) | ||
trajectoryBPCG_quadratic_wolfe = [] | ||
x, v, primal, dual_gap, _ = FrankWolfe.blended_pairwise_conditional_gradient( | ||
f, | ||
grad!, | ||
lmo, | ||
active_set_quadratic_wolfe, | ||
max_iteration=k, | ||
verbose=true, | ||
callback=build_callback(trajectoryBPCG_quadratic_wolfe), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these two runs cycle (irrespective of using the Wolfe one or the non-Wolfe one)
still some minor issue - run the direct_solve example with seed 10 @matbesancon maybe it is just numerics or some edge case. we need to check
also for the Lp-norm LMO:
|
No description provided.