Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question: Running a learning for additional points after some amount of points was computed #470

Open
serhiy-yevtushenko opened this issue Feb 20, 2025 · 2 comments

Comments

@serhiy-yevtushenko
Copy link

Hi

My question is the following:

how one could run a learner again after sampling a certain amount of points.

I have tried following:

run LearnerND for sampling 2000 points.

Saved them to the dataframe

Started new run.

Created new instance of LeanerND with same initial parameters and function.

Loaded points generated from old session using

learner.load_dataframe(initial_df,
                           with_default_function_args=False,
                           point_names=("x", "y"),
                           value_name="value"

)

and tried running

    points = len(initial_df)+110
    runner=BlockingRunner(learner, npoints_goal=points)
    df = learner.to_dataframe(point_names=("x", "y"))

However, I get the exception:

raise ValueError("Point already in triangulation.")

from add_point (line 629, in add_point, called from line 605, in _try_adding_pending_point_to_simplex)

@akhmerov
Copy link
Contributor

Seems like a bug; this should work. Please try to make a self-contained reproducible example.

@serhiy-yevtushenko
Copy link
Author

I managed to do reproducible example (it uses fictional function, but real inputs for convex hull boundaries and saved points.

Here it is:

import numpy as np
import pandas as pd
from adaptive import LearnerND, BlockingRunner
from scipy.spatial import ConvexHull

if __name__ == "__main__":

    def some_f(xy):
        x, y = xy
        a = 0.2
        return x + np.exp(-((x**2 + y**2 - 0.75**2) ** 2) / a**4)

    boundaries_list = [
        [0.0, 0.0],
        [100.0, 1.115142836310296e-06],
        [200.0, 2.230285672620592e-06],
        [300.0, 3.3454285089308886e-06],
        [400.0, 4.460571345241184e-06],
        [500.0, 5.57571418155148e-06],
        [600.0, 6.690857017861777e-06],
        [700.0, 7.805999854172073e-06],
        [800.0, 8.921142690482368e-06],
        [900.0, 1.0036285526792665e-05],
        [1000.0, 1.115142836310296e-05],
        [1100.0, 1.2266571199413256e-05],
        [1200.0, 1.3381714035723556e-05],
        [1300.0, 1.449685687203385e-05],
        [1400.0, 1.5611999708344146e-05],
        [1500.0, 1.6727142544654443e-05],
        [1600.0, 1.7842285380964736e-05],
        [1700.0, 1.8957428217275036e-05],
        [1800.0, 2.007257105358533e-05],
        [1900.0, 2.1187713889895622e-05],
        [2000.0, 2.230285672620592e-05],
        [2100.0, 2.3417999562516216e-05],
        [2200.0, 2.4533142398826512e-05],
        [2300.0, 2.564828523513681e-05],
        [2400.0, 2.676342807144711e-05],
        [2500.0, 2.78785709077574e-05],
        [2600.0, 2.89937137440677e-05],
        [2700.0, 3.0108856580378e-05],
        [2800.0, 3.122399941668829e-05],
        [2900.0, 3.233914225299859e-05],
        [3000.0, 3.3454285089308885e-05],
        [3100.0, 3.456942792561918e-05],
        [3200.0, 3.568457076192947e-05],
        [3300.0, 3.679971359823977e-05],
        [3400.0, 3.791485643455007e-05],
        [3500.0, 3.902999927086036e-05],
        [3600.0, 4.014514210717066e-05],
        [3700.0, 4.126028494348096e-05],
        [3800.0, 4.237542777979125e-05],
        [3900.0, 4.349057061610155e-05],
        [4000.0, 4.460571345241184e-05],
        [4100.0, 4.5720856288722135e-05],
        [4200.0, 6.814896913926772e-05],
        [4300.0, 9.86347750047832e-05],
        [4400.0, 0.0001291205808702],
        [4500.0, 0.0001596063867358],
        [4600.0, 0.0001900921926013],
        [4700.0, 0.0002205779984668],
        [4800.0, 0.0002510638043323],
        [4900.0, 0.0002815496101978],
        [5000.0, 0.0003120354160633],
        [5100.0, 0.0003425212219289],
        [5200.0, 0.0003730070277944],
        [5300.0, 0.0004034928336599],
        [5400.0, 0.0004339786395254],
        [5500.0, 0.0004644644453909],
        [5600.0, 0.0004949502512564],
        [5700.0, 0.0005254360571219],
        [5800.0, 0.0005559218629875],
        [5900.0, 0.0007147750527983],
        [5958.286720010206, 0.0191313558591815],
        [5907.6017302122045, 100.0],
        [5900.0, 114.76582808254696],
        [5855.557077950937, 200.0],
        [5802.120964299216, 300.0],
        [5800.0, 303.9180944285528],
        [5747.2470662133965, 400.0],
        [5700.0, 484.0110564366577],
        [5690.889136812792, 500.0],
        [5632.988323616697, 600.0],
        [5600.0, 655.7812882689732],
        [5573.489289877545, 700.0],
        [5512.330765927291, 800.0],
        [5500.0, 819.8310791739173],
        [5449.453695550926, 900.0],
        [5400.0, 976.7273642697368],
        [5384.783431673397, 1000.0],
        [5318.25038673062, 1100.0],
        [5300.0, 1126.9294170460528],
        [5249.768962312114, 1200.0],
        [5200.0, 1270.8848142140498],
        [5179.25599484322, 1300.0],
        [5106.615292424962, 1400.0],
        [5100.0, 1408.9603456835755],
        [5031.748474209412, 1500.0],
        [5000.0, 1541.4981221350852],
        [4954.544472334084, 1600.0],
        [4900.0, 1668.8144779856843],
        [4874.883500782354, 1700.0],
        [4800.0, 1791.1726541541148],
        [4792.629568799029, 1800.0],
        [4707.642393422194, 1900.0],
        [4700.0, 1908.82851256576],
        [4619.75309080672, 2000.0],
        [4600.0, 2022.015570709802],
        [4528.789455590954, 2100.0],
        [4500.0, 2130.934258178381],
        [4434.548819963085, 2200.0],
        [4400.0, 2235.7715308963816],
        [4336.810072561228, 2300.0],
        [4300.0, 2336.709148049797],
        [4235.316140760245, 2400.0],
        [4200.0, 2433.90362418784],
        [4129.769838029961, 2500.0],
        [4100.0, 2527.497213251217],
        [4019.862059018615, 2600.0],
        [4000.0, 2617.630617968991],
        [3905.202836411695, 2700.0],
        [3900.0, 2704.432159381163],
        [3800.0, 2788.0167593762926],
        [3785.344965272928, 2800.0],
        [3700.0, 2868.489829680557],
        [3659.776081181031, 2900.0],
        [3600.0, 2945.946859180247],
        [3527.87276759619, 3000.0],
        [3500.0, 3020.485282516302],
        [3400.0, 3092.192101198906],
        [3388.871711491372, 3100.0],
        [3300.0, 3161.145135978021],
        [3241.856209624924, 3200.0],
        [3200.0, 3227.4215041078746],
        [3100.0, 3291.0867911450027],
        [3085.6746305394568, 3300.0],
        [3000.0, 3352.2106073917794],
        [2918.8280381467725, 3400.0],
        [2900.0, 3410.8539297941925],
        [2800.0, 3467.073798524489],
        [2739.3690425123423, 3500.0],
        [2700.0, 3520.922400948519],
        [2600.0, 3572.446137385158],
        [2544.616895822353, 3600.0],
        [2500.0, 3621.69541538601],
        [2400.0, 3668.7142274073726],
        [2330.724210396878, 3700.0],
        [2300.0, 3713.54356901084],
        [2200.0, 3756.2207047353977],
        [2100.0, 3796.777361608687],
        [2091.822547917115, 3800.0],
        [2000.0, 3835.25044716744],
        [1900.0, 3871.6715389583783],
        [1818.0750272525088, 3900.0],
        [1800.0, 3906.069632377301],
        [1700.0, 3938.470724359623],
        [1600.0, 3968.8952109580896],
        [1500.0, 3997.370800627546],
        [1490.4102994496432, 4000.0],
        [1400.0, 4023.918712198653],
        [1300.0, 4048.558469218259],
        [1200.0, 4071.305295092509],
        [1100.0, 4092.1748990692186],
        [1060.0124392467872, 4100.0],
        [1000.0, 4111.1848482834],
        [900.0, 4128.348190721229],
        [800.0, 4143.676046135198],
        [700.0, 4157.173923620604],
        [600.0, 4168.855459354523],
        [500.0, 4178.7279024480495],
        [400.0, 4186.796819535569],
        [300.0, 4193.060249381895],
        [200.0, 4197.525520724352],
        [110.21120510982271, 4200.0],
        [100.0, 4200.189296956492],
        [11.409296118577458, 4201.032313198807],
        [11.26971309299113, 4200.0],
        [9.859345855831664, 4100.0],
        [9.207088443836112, 4000.0],
        [8.701469586322228, 3900.0],
        [8.271085442199967, 3800.0],
        [7.888502586309943, 3700.0],
        [7.539590097895451, 3600.0],
        [7.216017876632443, 3500.0],
        [6.912321158587411, 3400.0],
        [6.624724552852864, 3300.0],
        [6.350477146505692, 3200.0],
        [6.087548114163271, 3100.0],
        [5.834345433212333, 3000.0],
        [5.589546958407851, 2900.0],
        [5.352131461752008, 2800.0],
        [5.121242119180592, 2700.0],
        [4.896265293719253, 2600.0],
        [4.676478944932127, 2500.0],
        [4.4614068208286914, 2400.0],
        [4.250628570151294, 2300.0],
        [4.043732413888003, 2200.0],
        [3.840343010283609, 2100.0],
        [3.640252131290516, 2000.0],
        [3.443099142331329, 1900.0],
        [3.2486450191940843, 1800.0],
        [3.0566671498447104, 1700.0],
        [2.8669554821101078, 1600.0],
        [2.6793182091171377, 1500.0],
        [2.4935476601936504, 1400.0],
        [2.309445776938012, 1300.0],
        [2.1268225766767004, 1200.0],
        [1.94549506194922, 1100.0],
        [1.7652930253117367, 1000.0],
        [1.586065699183146, 900.0],
        [1.4076821682836234, 800.0],
        [1.2300220890107458, 700.0],
        [1.052987058866334, 600.0],
        [0.8764933592021794, 500.0],
        [0.7004700317462764, 400.0],
        [0.5248567780708592, 300.0],
        [0.3496022369010007, 200.0],
        [0.1746625696061707, 100.0],
    ]
    hull = ConvexHull(boundaries_list)
    initial_df=pd.read_csv("sampled_points.csv", encoding="utf-8", sep=";")

    new_learner = LearnerND(some_f, hull)
    new_learner.load_dataframe(
        initial_df, with_default_function_args=False, point_names=("x", "y")
    )

    BlockingRunner(new_learner, npoints_goal=2110)


sampled_points.csv

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants