Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
T
TopFarm2
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TOPFARM
TopFarm2
Commits
69005221
Commit
69005221
authored
6 years ago
by
Mads M. Pedersen
Browse files
Options
Downloads
Plain Diff
Merge branch 'added_ex_3' into 'master'
Part 2 of update to include example 3 See merge request
!63
parents
57ba39ab
3e7d1c3b
No related branches found
No related tags found
1 merge request
!63
Part 2 of update to include example 3
Pipeline
#4967
passed with warnings
6 years ago
Stage: test
Stage: deploy
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
examples/example_3_turbine_type_optimization.png
+0
-0
0 additions, 0 deletions
examples/example_3_turbine_type_optimization.png
examples/example_3_turbine_type_optimization.py
+64
-0
64 additions, 0 deletions
examples/example_3_turbine_type_optimization.py
with
64 additions
and
0 deletions
examples/example_3_turbine_type_optimization.png
0 → 100644
+
0
−
0
View file @
69005221
2.36 KiB
This diff is collapsed.
Click to expand it.
examples/example_3_turbine_type_optimization.py
0 → 100644
+
64
−
0
View file @
69005221
"""
Example: optimizing a layout with constraints
This example uses a dummy cost function to optimize a simple wind turbine
layout that is subject to constraints. The optimization pushes the wind turbine
locations to specified locations in the farm.
"""
import
os
from
matplotlib.patches
import
Polygon
import
matplotlib.pyplot
as
plt
import
numpy
as
np
from
topfarm
import
TopFarm
from
topfarm.cost_models.dummy
import
DummyCost
from
topfarm._topfarm
import
TurbineTypeOptimizationProblem
from
openmdao.drivers.doe_generators
import
FullFactorialGenerator
from
topfarm.plotting
import
TurbineTypePlotComponent
,
NoPlot
# ------------------------ INPUTS ------------------------
# define the conditions for the wind farm
positions
=
np
.
array
([[
0
,
0
],
[
6
,
6
]])
# initial turbine pos
optimal_types
=
np
.
array
([[
2
],
[
6
]])
# optimal layout
#===============================================================================
# Setup the problem and plotting
#===============================================================================
try
:
import
matplotlib.pyplot
as
plt
plt
.
gcf
()
plot_comp
=
TurbineTypePlotComponent
(
turbine_type_names
=
[
"
Turbine %d
"
%
i
for
i
in
range
(
10
)],
delay
=
0.1
)
plot
=
True
except
RuntimeError
:
plot_comp
=
NoPlot
()
plot
=
False
# create the wind farm
tf
=
TurbineTypeOptimizationProblem
(
cost_comp
=
DummyCost
(
optimal_types
,
[
'
turbineType
'
]),
turbineTypes
=
[
0
,
0
],
lower
=
0
,
upper
=
9
,
plot_comp
=
plot_comp
,
driver
=
FullFactorialGenerator
(
10
))
#===============================================================================
# # Run the optimization
#===============================================================================
state
=
{
'
turbineX
'
:
positions
[:,
0
],
'
turbineY
'
:
positions
[:,
1
]}
cost
,
state
,
recorder
=
tf
.
optimize
(
state
)
#===============================================================================
# plot and prin the the final, optimal types
#===============================================================================
print
(
state
[
'
turbineType
'
])
tf
.
evaluate
(
state
)
# save the figure
if
plot
:
plt
.
savefig
(
os
.
path
.
basename
(
__file__
).
replace
(
'
.py
'
,
'
.png
'
))
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment