-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CPM model #49
CPM model #49
Conversation
@wangcj05: this is the initial development of the model designed to perform critical path calculations for the plant outage optimization project. Do you mind start to take a look at it? The model is initialized by providing a set of activities and the graph connecting the activities. This is specified in a python class as of now. When a more generic format will be available this class will be expanded |
Once the main code is good on your end I will add documentation, fill comments, class documentation, etc |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mandd: I have some comments for you to consider.
src/CPM/BaseCPMmodel.py
Outdated
file2open = inputs[0].getFilename() | ||
spec = importlib.util.spec_from_file_location("project", str(file2open)) | ||
importedModule = importlib.util.module_from_spec(spec) | ||
sys.modules["project"] = importedModule | ||
spec.loader.exec_module(importedModule) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you may need to add some checks and enhancement for these lines. Here assumes the first file in the 'inputs' is the module file that you want to load, and assumes the module name is "project". If the module name is always "project", I suggest to use self variable to store it, otherwise provide an option for the users to choose which module to load.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good point, test has been added
src/CPM/BaseCPMmodel.py
Outdated
self.graph = importedModule.project.graph | ||
return Kwargs | ||
|
||
@abc.abstractmethod |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed
src/CPM/BaseCPMmodel.py
Outdated
|
||
self.pert = Pert(self.graph) | ||
|
||
end_time = self.pert.info_dict[self.pert.end_activity]['ef'] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
camelBack
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
src/CPM/BaseCPMmodel.py
Outdated
inputDict = inputDict['SampledVars'] | ||
for input in inputDict.keys(): | ||
for act in self.graph.keys(): | ||
if act.returnName()==container.mapping[input]: | ||
act.updateDuration(inputDict[input]) | ||
|
||
self.pert = Pert(self.graph) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems these can be moved to "createNewInput"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
correct, moved
src/CPM/PertMain2.py
Outdated
@@ -0,0 +1,261 @@ | |||
# Developed from: https://github.com/nofaralfasi/PERT-CPM-graph |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Regarding this file, one suggestion is to move this file into LOGOS/src/contrib/ folder. If you want to keep this file at the CPM folder and made some modifications, I would suggest to convert it to RAVEN code standards.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
file has been edited according to RAVEN code standards
tests/test_BaseCPMmodel.xml
Outdated
<ExternalModel name="CPMmodel" subType="LOGOS.BaseCPMmodel"> | ||
<variables>A,B,C,D,E,F,G,H,end_time</variables> | ||
<CPtime>end_time</CPtime> | ||
<map var='A'>start</map> | ||
<map var='B'>b</map> | ||
<map var='C'>c</map> | ||
<map var='D'>d</map> | ||
<map var='E'>end</map> | ||
<map var='F'>f</map> | ||
<map var='G'>g</map> | ||
<map var='H'>h</map> | ||
</ExternalModel> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess you need to convert the python graphModel construction into XML format
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This structure has been modified, now it is possible to import graph structure of a schedule from xml block
tests/CPMmodel/graphModel.py
Outdated
class project(): | ||
start = Activity("start", 10) | ||
b = Activity("b", 20) | ||
c = Activity("c", 5) | ||
d = Activity("d", 10) | ||
f = Activity("f", 15) | ||
g = Activity("g", 5) | ||
h = Activity("h", 15) | ||
end = Activity("end", 20) | ||
|
||
activitiesList = [start,b,c,d,f,g,h,end] | ||
|
||
graph = {start: [f,b,h], | ||
b : [c], | ||
c : [g,d], | ||
d : [end], | ||
f : [g], | ||
g : [end], | ||
h : [end], | ||
end : []} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do the users need to create the graphModel? or they only need to provide the inputs through input xml, and we can automatically create the graph model?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are two methods to import a schedule: the first one is to directly import it in an xml format in the RAVEN input file. The second one is to create a project class which contains all the activities and the graph structure. This second one will be updated once we get specifications of schedule formats coming from software scheduling tools such as P6
@wangcj05 : I think all the initial set of comments have been addressed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some general comments for you to consider. @mandd
src/CPM/PertMain2.py
Outdated
self.infoDict[activity]["slack"] = self.infoDict[activity]["lf"] - self.infoDict[activity]["ef"] | ||
|
||
# add activity to the pert | ||
def addActivity(self, activity, in_connections=[], out_connections=[]): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
camelBack to replace underscore for variables?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
src/CPM/PertMain2.py
Outdated
@ In, None | ||
@ Out, CPdict, dict, dictionary of activities included in the CP alonf with their corresponding duration | ||
""" | ||
critical_path = self.getCriticalPath() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
camelBack?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
<Sequence>simRun</Sequence> | ||
<batchSize>1</batchSize> | ||
</RunInfo> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add a TestInfo node block
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added
|
||
[./CPMmodel_map] | ||
type = 'RavenFramework' | ||
input = 'test_BaseCPMmodel_map.xml' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems you do not add this file yet.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the folder in the tests file is not correct, please update it.
tests/tests
Outdated
[./CPMmodel] | ||
type = 'RavenFramework' | ||
input = 'test_BaseCPMmodel.xml' | ||
UnorderedCsv = 'MultipleKnapsack/Print_sim_PS.csv' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please update the folder to CPMmodel
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
tests/tests
Outdated
[./CPMmodel_map] | ||
type = 'RavenFramework' | ||
input = 'test_BaseCPMmodel_map.xml' | ||
UnorderedCsv = 'MultipleKnapsack/Print_sim_PS_map.csv' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please update the folder to CPMmodel
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
Contributions from reviewer only for resolving libraries issues. |
PR checklist is good. |
Pull Request Description
What issue does this change request address? (Use "#" before the issue to link it, i.e., #42.)
Closes #50
What are the significant changes in functionality due to this change request?
For Change Control Board: Change Request Review
The following review must be completed by an authorized member of the Change Control Board.