Skip to content
GitLab
Projects Groups Topics Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Register
  • Sign in
  • adaptive adaptive
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributor statistics
    • Graph
    • Compare revisions
  • Issues 36
    • Issues 36
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 5
    • Merge requests 5
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Container Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Quantum TinkererQuantum Tinkerer
  • adaptiveadaptive
  • Merge requests
  • !96

More efficient 'tell_many'

  • Review changes

  • Download
  • Email patches
  • Plain diff
Merged Bas Nijholt requested to merge efficient_tell_many into master Sep 13, 2018
  • Overview 21
  • Commits 4
  • Pipelines 27
  • Changes 2
import adaptive

def f(x, offset=0):
    a = 0.01
    return x + a**2 / (a**2 + (x - offset)**2)

learner = adaptive.Learner1D(f, bounds=(-1, 1))
adaptive.runner.simple(learner, goal=lambda l: l.npoints > 200)

Timing new implementation

%%timeit
learner2 = adaptive.Learner1D(f, bounds=(-1, 1))
learner2.tell_many(*zip(*learner.data.items()))

1.17 ms ± 24.9 µs per loop (mean ± std. dev. of 7 runs, 1000 loops each)

Timing old implementation

%%timeit
learner2 = adaptive.Learner1D(f, bounds=(-1, 1))
for x, y in learner.data.items():
    learner2.tell(x, y)

6.82 ms ± 447 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)

This makes it ~6 times faster for functions that return scalars and is >10 times faster for vectors.

Edited Sep 24, 2018 by Bas Nijholt
Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: efficient_tell_many