Skip to content

Commit

Permalink
doc: add experimental document for evoxvision
Browse files Browse the repository at this point in the history
  • Loading branch information
BillHuang2001 committed Nov 22, 2024
1 parent fa45e82 commit 1d435b3
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 0 deletions.
74 changes: 74 additions & 0 deletions docs/source/guide/experimental/evoxvision.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# EvoXVision Support\n",
"\n",
"This notebook demostrate the use of EvoXVision in EvoX.\n",
"EvoXVision requires a special binary file format that is specifically designed for evolutionary optimization workflow."
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"from evox import algorithms, problems, workflows, monitors\n",
"\n",
"import jax.numpy as jnp\n",
"from jax import random"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"exv_adapter = monitors.EvoXVisionAdapter(\"/tmp/experiment.exv\")\n",
"monitor = monitors.EvalMonitor(evoxvision_adapter=exv_adapter)\n",
"pso = algorithms.CSO(\n",
" lb=jnp.full(shape=(2,), fill_value=-32),\n",
" ub=jnp.full(shape=(2,), fill_value=32),\n",
" pop_size=100,\n",
")\n",
"ackley = problems.numerical.Ackley()\n",
"workflow = workflows.StdWorkflow(\n",
" pso,\n",
" ackley,\n",
" monitors=[monitor],\n",
")\n",
"key = random.PRNGKey(42)\n",
"state = workflow.init(key)\n",
"\n",
"# run the workflow for 100 steps\n",
"for i in range(100):\n",
" state = workflow.step(state)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "venv",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.2"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
1 change: 1 addition & 0 deletions docs/source/guide/experimental/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@
:maxdepth: 1
multidevice_algorithm
evoxvision
```

0 comments on commit 1d435b3

Please sign in to comment.