adjust internal scripts to work in the modular context
This commit is contained in:
parent
5614429883
commit
fe290b4311
5 changed files with 24 additions and 5 deletions
7
thursday/internal/__main__.py
Normal file
7
thursday/internal/__main__.py
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
from .birect import main as birect_main
|
||||||
|
from .hg import main as hg_main
|
||||||
|
from .soo import main as soo_main
|
||||||
|
|
||||||
|
birect_main()
|
||||||
|
hg_main()
|
||||||
|
soo_main()
|
|
@ -329,7 +329,7 @@ def birect(
|
||||||
return argmin, fmin
|
return argmin, fmin
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
def main():
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
|
||||||
def objective2210(x):
|
def objective2210(x):
|
||||||
|
@ -358,3 +358,7 @@ if __name__ == "__main__":
|
||||||
)
|
)
|
||||||
print("", "birect result:", *res, sep="\n")
|
print("", "birect result:", *res, sep="\n")
|
||||||
print("", "double checked:", objective2210(np.array(res[0], F)), sep="\n")
|
print("", "double checked:", objective2210(np.array(res[0], F)), sep="\n")
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
|
|
|
@ -109,9 +109,9 @@ def minimize(
|
||||||
return center, history
|
return center, history
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
def main():
|
||||||
# get this here: https://github.com/imh/hipsterplot/blob/master/hipsterplot.py
|
# get this here: https://github.com/imh/hipsterplot/blob/master/hipsterplot.py
|
||||||
from hipsterplot import plot
|
from thursday.external.hipsterplot import plot
|
||||||
|
|
||||||
prng = np.random.default_rng(42070)
|
prng = np.random.default_rng(42070)
|
||||||
|
|
||||||
|
@ -150,3 +150,7 @@ if __name__ == "__main__":
|
||||||
|
|
||||||
print("loss, before optimization: {:9.6f}".format(true_objective(init)))
|
print("loss, before optimization: {:9.6f}".format(true_objective(init)))
|
||||||
print("loss, after optimization: {:9.6f}".format(true_objective(optimized)))
|
print("loss, after optimization: {:9.6f}".format(true_objective(optimized)))
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
|
|
|
@ -110,9 +110,9 @@ def soo(obj, origin, sigma, evals, K=3, h_max=None, iters=None, _adapt=None):
|
||||||
return coords(h, p) + origin, history
|
return coords(h, p) + origin, history
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
def main():
|
||||||
# get this here: https://github.com/imh/hipsterplot/blob/master/hipsterplot.py
|
# get this here: https://github.com/imh/hipsterplot/blob/master/hipsterplot.py
|
||||||
from hipsterplot import plot
|
from thursday.external.hipsterplot import plot
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
|
||||||
def objective2210(x):
|
def objective2210(x):
|
||||||
|
@ -143,3 +143,7 @@ if __name__ == "__main__":
|
||||||
plot(np.log10(history), num_y_chars=23)
|
plot(np.log10(history), num_y_chars=23)
|
||||||
print("", "soo result:", list(optimized), history[-1], sep="\n")
|
print("", "soo result:", list(optimized), history[-1], sep="\n")
|
||||||
print("", "double checked:", objective2210(optimized), sep="\n")
|
print("", "double checked:", objective2210(optimized), sep="\n")
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
|
|
Loading…
Reference in a new issue