Skip to content

Commit

Permalink
added Select
Browse files Browse the repository at this point in the history
  • Loading branch information
tinatorabi committed Sep 13, 2024
1 parent 391ec74 commit ed8b0f2
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/asp.jl
Original file line number Diff line number Diff line change
Expand Up @@ -140,3 +140,10 @@ function post_asp_tsvd(path, At, yt, Av, yv)

return _post.(path)
end

function select(tracer, solver, A, y) #can be called by the user to warm-start the selection
xs, in = select_solution(tracer, solver, A, y)
return Dict("C" => xs,
"path" => tracer,
"nnzs" => length( (tracer[in][:solution]).nzind) )
end
38 changes: 38 additions & 0 deletions test/test_asp.jl
Original file line number Diff line number Diff line change
Expand Up @@ -117,3 +117,41 @@ for (select, tolr, tolc) in [ (:final, 20*epsn, 1.5),
end
end


# Testing the "select" function
solver_final = ACEfit.ASP(
P = I,
select = :final,
tsvd = false,
nstore = 100,
loglevel = 0
)

results_final = ACEfit.solve(solver_final, At, yt, Av, yv)
tracer_final = results_final["path"]

# Warm-start the solver using the tracer from the final iteration
solver_warmstart = ACEfit.ASP(
P = I,
select = (:bysize, 73),
tsvd = false,
nstore = 100,
loglevel = 0
)

results_warmstart = ACEfit.select(tracer_final, solver_warmstart, Av, yv)
C_warmstart = results_warmstart["C"]

# Check if starting the solver initially with (:bysize, 73) gives the same result
solver_bysize = ACEfit.ASP(
P = I,
select = (:bysize, 73),
tsvd = false,
nstore = 100,
loglevel = 0
)

results_bysize = ACEfit.solve(solver_bysize, At, yt, Av, yv)
@test results_bysize["C"] == C_warmstart # works


0 comments on commit ed8b0f2

Please sign in to comment.