Add my answers to the movescheme examples

parent 54f73add
{
"cells": [
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"import openpathsampling as paths\n",
"import openpathsampling.high_level.move_strategy as strategies"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"?strategies.OneWayShootingStrategy"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Exercise 2"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {
"collapsed": false
},
"outputs": [
{
"ename": "NameError",
"evalue": "name 'scheme' is not defined",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)",
"\u001b[0;32m<ipython-input-9-cf5e445cef40>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mscheme\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mappend\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mstrategies\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mOneWayShootingStrategy\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
"\u001b[0;31mNameError\u001b[0m: name 'scheme' is not defined"
]
}
],
"source": [
"scheme.append(strategies.SelectedPairsRepExStrategy(ensembles=[ensemble_0, ensemble_2], replace=True))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Exercise 3"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"# build strategy except for shooting\n",
"scheme.append([\n",
" strategies.NearestNeighborRepExStrategy(),\n",
" strategies.PathReversalStrategy(),\n",
" strategies.MinusMoveStrategy(engine=None),\n",
" strategies.OrganizeByMoveGroupStrategy()\n",
"])\n",
"# add shooting movers\n",
"scheme.append(strategies.OneWayShootingStrategy(ensembles=ensemble_0, group=\"shoot_0\"))\n",
"scheme.append(strategies.OneWayShootingStrategy(ensembles=ensemble_1, group=\"shoot_1\"))\n",
"scheme.append(strategies.OneWayShootingStrategy(ensembles=ensemble_2, group=\"shoot_2\"))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Exercise 4"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"shooter_0 = paths.OneWayShootingMover(ensemble=ensemble_0,\n",
" selector=paths.UniformSelector(),\n",
" engine=None)\n",
"shooter_1 = paths.OneWayShootingMover(ensemble=ensemble_1,\n",
" selector=paths.UniformSelector(),\n",
" engine=None)\n",
"shooter_2 = paths.OneWayShootingMover(ensemble=ensemble_2,\n",
" selector=paths.UniformSelector(),\n",
" engine=None)\n",
"shooting_chooser = paths.RandomChoiceMover(movers=[shooter_0, shooter_1, shooter_2])\n",
"scheme = paths.LockedMoveScheme(shooting_chooser, network)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 2",
"language": "python",
"name": "python2"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 2
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.12"
}
},
"nbformat": 4,
"nbformat_minor": 1
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment