Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
DrEO
sho
Commits
d5086d58
Commit
d5086d58
authored
Sep 28, 2020
by
Johann Dreo
Browse files
fix scale management in num/neighb_square
- fix snp_landscape
parent
23736e4a
Changes
2
Hide whitespace changes
Inline
Side-by-side
sho/num.py
View file @
d5086d58
...
...
@@ -49,9 +49,10 @@ def rand(dim, scale):
########################################################################
def
neighb_square
(
sol
,
scale
,
domain_width
):
"""Draw a random vector in a square of witdh `scale`
around the given on
e
."""
"""Draw a random vector in a square of witdh `scale`
in [0,1]
as a fraction of the domain width
around the given
soluti
on."""
assert
(
0
<
scale
<=
1
)
new
=
sol
+
(
np
.
random
.
random
(
len
(
sol
))
*
scale
-
scale
/
2
)
side
=
domain_width
*
scale
;
new
=
sol
+
(
np
.
random
.
random
(
len
(
sol
))
*
side
-
side
/
2
)
return
new
snp_landscapes.py
View file @
d5086d58
...
...
@@ -40,9 +40,9 @@ if __name__ == "__main__":
fixed_x
=
(
x0
,
x1
)
),
make
.
init
(
num
.
rand
,
dim
=
2
,
# Two sensors moving along y axis.
scale
=
w
),
scale
=
1.0
),
make
.
neig
(
num
.
neighb_square
,
scale
=
0.1
*
w
,
scale
=
0.1
,
domain_width
=
w
),
iters
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment