direct: update birect.py
This commit is contained in:
parent
434f70b84b
commit
ba8670bfad
1 changed files with 15 additions and 1 deletions
|
@ -1,6 +1,7 @@
|
|||
#!/usr/bin/env python3
|
||||
# based on hamming_exact3.py, but with all debug stuff removed
|
||||
|
||||
|
||||
def birect(
|
||||
obj,
|
||||
lo,
|
||||
|
@ -297,9 +298,22 @@ def birect(
|
|||
|
||||
|
||||
if __name__ == "__main__":
|
||||
from arsd_objectives import objective2210
|
||||
import numpy as np
|
||||
|
||||
def objective2210(x):
|
||||
# another linear transformation of the rosenbrock banana function.
|
||||
assert len(x) > 1, len(x)
|
||||
a, b = x[:-1], x[1:]
|
||||
|
||||
a = a / 4.0 * 2 - 12 / 15
|
||||
b = b / 1.5 * 2 - 43 / 15
|
||||
# solution: 3.60 1.40
|
||||
|
||||
return (
|
||||
np.sum(100 * np.square(np.square(a) + b) + np.square(a - 1))
|
||||
/ 499.0444444444444
|
||||
)
|
||||
|
||||
F = np.float64
|
||||
res = birect(
|
||||
lambda a: objective2210(np.array(a, F)),
|
||||
|
|
Loading…
Reference in a new issue