Skip to content

Commit

Permalink
Added solver options and revised plotting.
Browse files Browse the repository at this point in the history
  • Loading branch information
milzj committed May 10, 2023
1 parent 6d2d6d2 commit 359f764
Show file tree
Hide file tree
Showing 15 changed files with 68 additions and 40,078 deletions.
4 changes: 2 additions & 2 deletions examples/nonconvex/tidalfarm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ using the conditional gradient method.

## Graphical illustrations

![](output/26-January-2023-12-12-15_solution_best_N=100_online_version.png)
![](output/10-May-2023-13-44-27_solution_best_n=100_online_version.png)
|:--:|
*Optimal turbine friction*
*Optimal turbine density*

Using the conditional gradient method, we can compute a tidal-stream farm layout
which maximizes energy extraction. The setting used for this application is descriped
Expand Down
20 changes: 8 additions & 12 deletions examples/nonconvex/tidalfarm/optimize.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,19 @@
set_log_level(30)

import fw4pde
from solver_options import SolverOptions

state = steady_sw(control)
u, p = split(state)

# sparsity parameter and box constraints
WtoMW = 1e-6

beta = WtoMW*4800.0
lb = Constant(0.0)
ub = Constant(0.059)

# Objective function
scaled_L1_norm = fw4pde.problem.ScaledL1Norm(control_space,beta)

# power functional appears to be implemented in https://zenodo.org/record/224251
power_functional = assemble(rho*control*inner(u,u)**1.5*site_dx(1))

ctrl = Control(control)
Expand All @@ -49,22 +49,18 @@
box_constraints = fw4pde.problem.BoxConstraints(control_space, lb, ub)
moola_box_lmo = fw4pde.algorithms.MoolaBoxLMO(box_constraints.lb, box_constraints.ub, beta)

stepsize = fw4pde.stepsize.DecreasingStepSize()
#stepsize = fw4pde.stepsize.DunnScalingStepSize()
#stepsize = fw4pde.stepsize.DemyanovRubinovOptimalStepSize()
#stepsize = fw4pde.stepsize.DemyanovRubinovAdaptiveStepSize()
#stepsize = fw4pde.stepsize.DecreasingAdaptiveStepSize()

gtol= 1e-4
ftol = -np.inf
maxiter = 10
options = {"maxiter": maxiter, "gtol": gtol, "ftol": ftol}
solver_options = SolverOptions()
options = solver_options.options
stepsize = solver_options.stepsize

solver = fw4pde.algorithms.FrankWolfe(problem, initial_point=u_moola, nonsmooth_functional=scaled_L1_norm,\
stepsize=stepsize, lmo=moola_box_lmo, options=options)

sol = solver.solve()

# Postprocessing: Plotting and saving

solution_final = sol["control_final"].data
plt.set_cmap("coolwarm")
c = plot(solution_final)
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 359f764

Please sign in to comment.