def init_db(app):
    db.init_app(app)
    if not os.path.isfile("app/database.db"):
        with app.app_context():
            db.create_all()
        log.warning("Created database from scratch")
    else:
        log.info("Initialized database")
Example #2
0
 def displayStructuralFailures(nodes):
     if len(nodes) > 0:
         print params._VISUAL_INLINE_MARKER + "Main structural issues:"
         for i in nodes:
             log.warning(
                 "Node " + str(i.node) + " seems disconnected from the VN (=graph). This corrupts the results."
             )
     else:
         print params._VISUAL_INLINE_MARKER + "Structure validates successfully."
Example #3
0
    def run(self, entity_sizes):
        # g = self.g
        ineqIN = inequality.Gini(self.__g, dao.EdgeType.INCOMING)
        ineqOUT = inequality.Gini(self.__g, dao.EdgeType.OUTGOING)

        power_indicators = []
        for ineq in [ineqIN, ineqOUT]:
            # Do hierarchical inequality measure works
            self.within_relationship_level(
                ineq
            )  # [1_ISL] Instance level, withinin relationship level: calc instance-utility
            power = self.entity_level(ineq)  # [2_ESL]stop right before gini requires results from others

            # Calculate entity size
            if len(entity_sizes) > 0:  # MANUAL entity size input
                log.warning("Entity size: Reverting to manual computation ...")  # User has overwritten the automatisms
                entity_sizes = self.normalize_manual_entity_sizes(entity_sizes)  # Make sure input sums to 1
                size = entity_sizes
            else:
                log.info(
                    "Entity size: Automatic computation..."
                )  # We investigate the business interaction volumes in the graph
                size = self.graphHelper.entity_sizes(self.__g, ineq.edgeType)  # [2_ES]

            # Call presentation of power and entity size results
            # ordered_powers = self.graphHelper.order_results(self.g, power)  # Order power
            # ordered_sizes = self.graphHelper.order_results(self.g, size)    # Order entity sizes
            # console.displayPowerSize(ordered_powers, entity_sizes)                            # Present

            # Make it a ready to use weighted indicator
            power_indicator = self.dependencyIndicatorBargainingPower(
                power, size, ineq.edgeType
            )  # [2_BP] integrates entity size and scales the result to a relative indicator
            power_indicators.append(power_indicator)

            log.info("---- phase completed ----")

        return power_indicators  # , size]
Example #4
0
 def getGraph(self):
     if self.__g == None:
         log.warning("You have not yet set the graph. This could lead to errors in the following.")
     return self.__g