Push your PyGAD problem to Vilvik in 10 minutes
If you already have a PyGAD problem running locally, the fastest way to share it, run it on bigger budgets, and let collaborators tweak parameters is to push it to Vilvik. Here is the path from a local script to a live submission in about ten minutes.
What you need
- A Vilvik account. If you do not have one yet, sign up at the home page and pick a username.
- Python 3.9 or newer with PyGAD already installed.
- The
vilvikSDK, which we will install in a moment.
1. Install the SDK
Install from PyPI:
pip install vilvik
The package is published from a public repository (see the SDK overview page in our docs) and works on Linux, macOS, and Windows.
2. Authenticate
The first time you push a problem the SDK needs to know which Vilvik account to attach the run to. Authenticate from the terminal:
vilvik login
This opens a browser tab, you sign in once, and the SDK stores a long-lived token in your home directory. You will not see this step again.
3. Wrap your fitness function
Take your existing PyGAD fitness function and import it from a small top-level module. Vilvik runs your code inside a secure environment, so the module needs to be self-contained: anything your fitness function imports needs to be either part of the Python standard library or named in the problem's extra_imports. For example:
# my_problem.py
import math
def fitness_func(ga_instance, solution, solution_idx):
# Toy: minimize distance from a target point in 2D space.
target = (3.0, 4.0)
dx = solution[0] - target[0]
dy = solution[1] - target[1]
return -math.hypot(dx, dy)
That is the same fitness function you would pass to pygad.GA(...) locally. You do not need to change a line.
4. Push the problem
In a tiny driver script, the SDK pushes the problem and waits for the run to finish:
# push_to_vilvik.py
from vilvik import Vilvik
client = Vilvik()
submission = client.submissions.create(
name="Distance-to-target demo",
fitness_module="my_problem",
fitness_func="fitness_func",
num_generations=50,
sol_per_pop=10,
num_genes=2,
init_range_low=-5.0,
init_range_high=5.0,
extra_imports=["math"],
)
print("Submission:", submission.id_hashed)
print("Live page:", submission.share_url)
Run it:
python push_to_vilvik.py
The SDK uploads my_problem.py, the platform spins up a worker, and the GA starts. Within a second or two you have a URL you can open in a browser. The page streams the fitness chart and generation counter as the run progresses. You can leave the tab open or close it, the worker runs to completion either way.
5. Read the results
When the run finishes you can fetch the result programmatically:
result = submission.wait_for_result()
print("Best solution:", result.best_solution)
print("Best fitness:", result.best_fitness)
Or open the live page again and you will see the best solution, the fitness curve, generation count, and a download link for the full output bundle.
6. Share it
The result page has a share menu (X, LinkedIn, Facebook, WhatsApp, copy link) and a public URL you can hand to a collaborator. Anyone can view the result without an account. The submission's source code stays private to you.
If you would like the run to appear on your public profile too, toggle "share publicly" in the submission page.
7. Continue a run
If you want more generations than you initially asked for, the SDK lets you continue from the best solution rather than restart:
followup = submission.continue_run(num_generations=100)
print(followup.share_url)
The continuation reuses the population from the original run, so you keep all the progress.
Where to go next
Once the basic loop above is working, the Submissions documentation covers every PyGAD parameter the platform exposes and how to set it from the SDK. The SDK reference lists the client.submissions.* methods you will reach for next: filtering past runs, attaching tags, batch uploads, and fetching results into pandas.
If you push a problem and it does not produce the result you expected, the results documentation explains what each chart and number on the result page means. And once you are happy with what came out, the public-sharing documentation walks through embedding the run on your own site.
Happy optimizing.