Skip to content

Commit

Permalink
Mandd/cpm red (#52)
Browse files Browse the repository at this point in the history
* edits

* edited src file and test file

* cleaned files

* cleaned files 2

* further development

* working subpath search

* last edits before PL

* add resources to CPM model

* finalized schedule

* last fY24 edits

* cleaning PR 1

* cleaning PR 2

* tests files

* update test

* delete whitespaces

* edits

* edits

* edits

* edits

* edits

* edits

* edits

* edits

* edits

* edits

* addressing comments

* delete whispaces
  • Loading branch information
mandd authored Jan 27, 2025
1 parent 637955a commit e401e28
Show file tree
Hide file tree
Showing 9 changed files with 1,749 additions and 15 deletions.
273 changes: 273 additions & 0 deletions doc/demos/CPM/CPM_paths_analysis.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,273 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Notebook designed to test PERT class methods (Model 2)"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"import sys\n",
"sys.path.insert(0, '../../../src/CPM/')\n",
"from PertMain2 import Pert, Activity"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'start': ['a'],\n",
" 'a': ['b', 'f'],\n",
" 'b': ['c'],\n",
" 'c': ['d'],\n",
" 'd': ['e'],\n",
" 'e': ['i', 'l'],\n",
" 'f': ['g'],\n",
" 'g': ['h', 'd'],\n",
" 'h': ['e'],\n",
" 'i': ['end'],\n",
" 'l': ['end'],\n",
" 'end': []}"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"start = Activity(\"start\", 1)\n",
"a = Activity(\"a\", 3)\n",
"b = Activity(\"b\", 5)\n",
"c = Activity(\"c\", 7)\n",
"d = Activity(\"d\", 4)\n",
"e = Activity(\"e\", 8)\n",
"f = Activity(\"f\", 3)\n",
"g = Activity(\"g\", 4)\n",
"h = Activity(\"h\", 6)\n",
"i = Activity(\"i\", 2)\n",
"l = Activity(\"l\", 2)\n",
"end = Activity(\"end\", 1)\n",
"\n",
"graph = {start: [a],\n",
" a: [b, f], \n",
" b: [c], \n",
" c: [d], \n",
" d: [e], \n",
" e: [i,l], \n",
" f: [g],\n",
" g: [h,d],\n",
" h: [e],\n",
" i: [end],\n",
" l: [end], \n",
" end:[]}\n",
"\n",
"pert = Pert(graph)\n",
"pert.returnGraphSymbolic()"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"['start', 'a', 'b', 'c', 'd', 'e', 'l', 'end']"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"pert.getCriticalPathSymbolic()"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"e i end \n",
"a f g d \n",
"a f g h e \n"
]
}
],
"source": [
"paths = pert.getSubpathsParalleltoCP()\n",
"for path in paths:\n",
" pert.printPathSymbolic(path)"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"d: \n",
"e: \n",
"h: \n",
"i: \n",
"l: \n",
"end: \n",
"start: start a \n",
"b: b c \n",
"f: f g \n"
]
}
],
"source": [
"pertRed = pert.simplifyGraph()\n",
"for node in pertRed.returnGraph():\n",
" print(node.returnName() + ': ' , end =\" \")\n",
" for sub in node.returnSubActivities():\n",
" print(' ' + sub.returnName(), end =\" \")\n",
" print()\n"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'d': ['e'],\n",
" 'e': ['i', 'l'],\n",
" 'h': ['e'],\n",
" 'i': ['end'],\n",
" 'l': ['end'],\n",
" 'end': [],\n",
" 'start': ['b', 'f'],\n",
" 'b': ['d'],\n",
" 'f': ['h', 'd']}"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"pertRed.returnGraphSymbolic()"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"['start', 'b', 'd', 'e', 'l', 'end']"
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"pertRed.getCriticalPathSymbolic()"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [],
"source": [
"CP = pertRed.getCriticalPath()"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"start b d e i end \n",
"start f h e i end \n",
"start f h e l end \n",
"start f d e i end \n",
"start f d e l end \n"
]
}
],
"source": [
"paths = pertRed.getAllPathsParallelToCP()\n",
"for path in paths:\n",
" pertRed.printPathSymbolic(path)"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"start f h e \n",
"e i end \n",
"start f d \n"
]
}
],
"source": [
"subpaths = pertRed.getSubpathsParalleltoCP()\n",
"for sub in subpaths:\n",
" pertRed.printPathSymbolic(sub)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "myenv",
"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.12.3"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Loading

0 comments on commit e401e28

Please sign in to comment.