Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Sielskyi Yevhenii
sho
Commits
5aee3fb3
Commit
5aee3fb3
authored
Dec 16, 2019
by
johann dreo
Browse files
fix: number of dimensions
parent
23994e2b
Changes
3
Hide whitespace changes
Inline
Side-by-side
sho/bit.py
View file @
5aee3fb3
...
...
@@ -8,11 +8,12 @@ from . import x,y,pb
# Objective functions
########################################################################
def
cover_sum
(
sol
,
domain_width
,
sensor_range
):
def
cover_sum
(
sol
,
domain_width
,
sensor_range
,
dim
):
"""Compute the coverage quality of the given array of bits."""
assert
(
0
<
sensor_range
<=
math
.
sqrt
(
2
))
assert
(
0
<
domain_width
)
assert
(
len
(
sol
)
>
0
)
assert
(
dim
>
0
)
assert
(
len
(
sol
)
>=
dim
)
domain
=
np
.
zeros
((
domain_width
,
domain_width
))
sensors
=
to_sensors
(
sol
)
cov
=
pb
.
coverage
(
domain
,
sensors
,
sensor_range
*
domain_width
)
...
...
sho/num.py
View file @
5aee3fb3
...
...
@@ -21,11 +21,12 @@ def to_sensors(sol):
return
sensors
def
cover_sum
(
sol
,
domain_width
,
sensor_range
):
def
cover_sum
(
sol
,
domain_width
,
sensor_range
,
dim
):
"""Compute the coverage quality of the given vector."""
assert
(
0
<
sensor_range
<=
domain_width
*
math
.
sqrt
(
2
))
assert
(
0
<
domain_width
)
assert
(
len
(
sol
)
>
0
)
assert
(
dim
>
0
)
assert
(
len
(
sol
)
>=
dim
)
domain
=
np
.
zeros
((
domain_width
,
domain_width
))
sensors
=
to_sensors
(
sol
)
cov
=
pb
.
coverage
(
domain
,
sensors
,
sensor_range
*
domain_width
)
...
...
snp.py
View file @
5aee3fb3
...
...
@@ -93,7 +93,8 @@ if __name__=="__main__":
val
,
sol
=
algo
.
greedy
(
make
.
func
(
num
.
cover_sum
,
domain_width
=
the
.
domain_width
,
sensor_range
=
the
.
sensor_range
),
sensor_range
=
the
.
sensor_range
,
dim
=
d
*
the
.
nb_sensors
),
make
.
init
(
num
.
rand
,
dim
=
d
*
the
.
nb_sensors
,
scale
=
the
.
domain_width
),
...
...
@@ -108,7 +109,8 @@ if __name__=="__main__":
val
,
sol
=
algo
.
greedy
(
make
.
func
(
bit
.
cover_sum
,
domain_width
=
the
.
domain_width
,
sensor_range
=
the
.
sensor_range
),
sensor_range
=
the
.
sensor_range
,
dim
=
d
*
the
.
nb_sensors
),
make
.
init
(
bit
.
rand
,
domain_width
=
the
.
domain_width
,
nb_sensors
=
the
.
nb_sensors
),
...
...
Write
Preview
Markdown
is supported
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