Create a new folder named obj
when compile the program for first time.
make
We used
clang++
to compile our program, however, you can change it in theMakefile
as you wish. Since our program utilized some features of c++11, the compiler must support c++11 to compile the program.
To run this program, execute the command below in root folder of the project.
./smart_grid inputs/equipments.data inputs/nodes.pos inputs/grids.wrapper
This picture demostrates the structure of our program. Detailed explanation of the picture is in the blockquote below.
The filled arrow represents the ownership between classes, from owner to the class owned by the owner. Owning a class means that it's responsible for managing the life cycles of its objects. The hollow arrow represents the inheritance between classes, from child to parent.
The idea of this design is to seperate the fixed information from the data that we may need to change. All equipments in the smart grid is like a database storing all the static informations, and we query it only when we need to.
To achieve this, we abstract the vertices and edges from what it really is by defining a pointer pointing to its corresponding equipment instead of storing all the equipment's informations in it, causing unnecessary copys. For example, a vertex which is actually a resident will contain a pointer pointing to its corresponding resident object instead of making its own copy of the equipment's informations.
The beauty of this design is that when we have mutiple instances of a equipment, we can construct different vertices/edges referecing exactly the same equipment without the need to copy all the repetitive informations.
I wrote a web app on JS Bin to
draw graphs of grids. To draw using this tool, just upload the file
outputs/graph.json
and the result will show up instantly.
The file
outputs/graph.json
is generated by the functionGraph::OutputJSON()
using a third party library.
To make navigating codes more efficiently, we use ctags
to generate the tag
file. Use Vim or some other editors supporting ctags
to utilize the power of
it.