コード例 #1
0
ファイル: optimizer_factory.py プロジェクト: saras152/Kratos
    def optimize(self):

        timer = timer_factory.CreateTimer()
        algorithmName = self.OptimizationSettings["optimization_algorithm"][
            "name"].GetString()

        print(
            "\n> =============================================================================================================="
        )
        print("> ", timer.GetTimeStamp(),
              ": Starting optimization using the following algorithm: ",
              algorithmName)
        print(
            "> ==============================================================================================================\n"
        )

        algorithm = algorithm_factory.CreateAlgorithm(
            self.OptimizationModelPart, self.analyzer,
            self.OptimizationSettings)
        algorithm.execute()

        print(
            "\n> =============================================================================================================="
        )
        print(
            "> Finished optimization                                                                                           "
        )
        print(
            "> ==============================================================================================================\n"
        )


# ==============================================================================
コード例 #2
0
    def __init__(self, designSurface, dampingRegions, analyzer, mapper,
                 communicator, optimizationSettings):

        self.designSurface = designSurface
        self.analyzer = analyzer
        self.mapper = mapper
        self.communicator = communicator
        self.optimizationSettings = optimizationSettings

        self.maxIterations = optimizationSettings["optimization_algorithm"][
            "max_iterations"].GetInt() + 1
        self.onlyObjective = optimizationSettings["objectives"][0][
            "identifier"].GetString()
        self.initialStepSize = optimizationSettings["line_search"][
            "step_size"].GetDouble()
        self.performDamping = optimizationSettings["design_variables"][
            "damping"]["perform_damping"].GetBool()

        self.geometryTools = GeometryUtilities(designSurface)
        self.optimizationTools = OptimizationUtilities(designSurface,
                                                       optimizationSettings)
        if self.performDamping:
            self.dampingUtilities = DampingUtilities(designSurface,
                                                     dampingRegions,
                                                     self.optimizationSettings)

        self.timer = timer_factory.CreateTimer()
        self.dataLogger = optimization_data_logger_factory.CreateDataLogger(
            designSurface, communicator, optimizationSettings, self.timer)
コード例 #3
0
    def __init__(self, designSurface, analyzer, mapper, communicator,
                 optimizationSettings):

        self.designSurface = designSurface
        self.analyzer = analyzer
        self.mapper = mapper
        self.communicator = communicator
        self.optimizationSettings = optimizationSettings

        self.maxIterations = optimizationSettings["optimization_algorithm"][
            "max_iterations"].GetInt() + 1
        self.onlyObjective = optimizationSettings["objectives"][0][
            "identifier"].GetString()
        self.initialStepSize = optimizationSettings["line_search"][
            "step_size"].GetDouble()
        self.isConstraintGiven = False

        self.geometryTools = GeometryUtilities(designSurface)
        self.optimizationTools = OptimizationUtilities(designSurface,
                                                       optimizationSettings)

        self.timer = timer_factory.CreateTimer()
        self.specificVariablesToBeLogged = {"stepSize": self.initialStepSize}
        self.dataLogger = optimization_data_logger_factory.CreateDataLogger(
            designSurface, communicator, optimizationSettings, self.timer,
            self.specificVariablesToBeLogged)
コード例 #4
0
    def __init__(self, OptimizationModelPart, DesignSurface, Communicator,
                 OptimizationSettings):
        self.OptimizationModelPart = OptimizationModelPart
        self.DesignSurface = DesignSurface
        self.Communicator = Communicator
        self.OptimizationSettings = OptimizationSettings

        self.Timer = timer_factory.CreateTimer()
        self.ResponseLogger = self.__CreateResponseLogger()
        self.DesignLogger = self.__CreateDesignLogger()

        self.__CreateFolderToStoreOptimizationResults()
        self.__OutputInformationAboutResponseFunctions()
コード例 #5
0
    def optimize( self ):
        
        timer = timer_factory.CreateTimer()
        algorithmName = self.optimizationSettings["optimization_algorithm"]["name"].GetString()

        print("\n> ==============================================================================================================")
        print("> ",timer.getTimeStamp(),": Starting optimization using the following algorithm: ", algorithmName)
        print("> ==============================================================================================================\n")
    
        designSurface = self.__getDesignSurfaceFromInputModelPart()
        dampingRegions = self.__getdampingRegionsFromInputModelPart()

        mapper = mapper_factory.CreateMapper( designSurface, self.optimizationSettings ) 
        communicator = communicator_factory.CreateCommunicator( self.optimizationSettings )

        algorithm = algorithm_factory.CreateAlgorithm( designSurface, dampingRegions, self.analyzer, mapper, communicator, self.optimizationSettings )
        algorithm.execute()       

        print("\n> ==============================================================================================================")
        print("> Finished optimization                                                                                           ")
        print("> ==============================================================================================================\n")