diff --git a/morphemic-performance-model/.DS_Store b/morphemic-performance-model/.DS_Store index d3c95c9769b3f032f19fa37eb3c16fb04970eaba..2b01458a9ca1db09e98d4513e2b2d0908274a9c7 100644 Binary files a/morphemic-performance-model/.DS_Store and b/morphemic-performance-model/.DS_Store differ diff --git a/morphemic-performance-model/ml_code/.DS_Store b/morphemic-performance-model/ml_code/.DS_Store index 8592794b6782b58772f44cfc42e243829e087404..2b8e773b752f0d52d96f8f2b472704fa8dbba0d6 100644 Binary files a/morphemic-performance-model/ml_code/.DS_Store and b/morphemic-performance-model/ml_code/.DS_Store differ diff --git a/morphemic-performance-model/ml_code/src/activemq_logic.py b/morphemic-performance-model/ml_code/src/activemq_logic.py index 8c7ad7e0ed83b3fb6cb805efb4ce6b9cbd361da3..901200904bc15ff660dc3464c639bd8533458ece 100644 --- a/morphemic-performance-model/ml_code/src/activemq_logic.py +++ b/morphemic-performance-model/ml_code/src/activemq_logic.py @@ -285,7 +285,6 @@ class MessagingManager(Thread): if result["status"]: results.update(result["result"]) else: - print(result) error = result can_proceed = False if can_proceed: diff --git a/morphemic-performance-model/ml_code/src/ml_module.py b/morphemic-performance-model/ml_code/src/ml_module.py index 6fbaede5b6f93e148f72c375838b6634bfdbc71a..11d2ea80d29cc27ddd4170b7bcdfe0fd255b72fe 100644 --- a/morphemic-performance-model/ml_code/src/ml_module.py +++ b/morphemic-performance-model/ml_code/src/ml_module.py @@ -308,6 +308,7 @@ class MultiComponentsManager(): _exp = "{0}(".format(function) if _exp in _string: _string = _string.replace(_exp,"math.{0}(".format(function)) + _string = _string.replace("^","**") return _string def mean(self, number): @@ -319,17 +320,6 @@ class MultiComponentsManager(): _dict = {} _dict.update(variables) _dict.update({"math":math, "mean": self.mean, "add": self.add}) - for _ in range(len(list(self.formulas.keys()))): - for t, formula in self.formulas.items(): - if t == target: - continue - try: - formula = self.replaceFunction(formula) - result = eval(formula, _dict) - if not t in _dict: - _dict[t] = result - except Exception as e: - print(e) print('Formula for = {0} found {1}'.format(target, self.formulas[target])) formula = self.replaceFunction(self.formulas[target]) try: @@ -461,7 +451,7 @@ class MultiComponentsManager(): return {"status": False, "message": "could not load the dataset"} target = model.getTarget() if not target in list(data.columns): - return {"status": False, "message": 'Target field not found in the dataset'} + return {"status": False, "message": 'Target field ={0} not found in the dataset'.format(target)} data = model.filterRows(data) if data.empty: diff --git a/polymorphic_solver/src/.DS_Store b/polymorphic_solver/src/.DS_Store index 043f686201500142b168e21145e39fbc45c42f9f..056442e07c64ccd8f8c40cc5331fc10713be1fa8 100644 Binary files a/polymorphic_solver/src/.DS_Store and b/polymorphic_solver/src/.DS_Store differ diff --git a/polymorphic_solver/src/app.py b/polymorphic_solver/src/app.py index d1f8b6f825f4794e2589571a85882b02e5828446..f3181e6d6dd35d2e2605a2bce174255c0a453040 100644 --- a/polymorphic_solver/src/app.py +++ b/polymorphic_solver/src/app.py @@ -447,6 +447,9 @@ class PolymorphicSolver(): performance = data["performance"] self.archetype_manager.addLine(states, performance) + if data["request"] == "explore_solution": + self.archetype_manager.explorePolymorphicSolution() + if data["request"] == "agent_consumer_register": self.agent_consumers[data["agent"]] = data["topic"] print("Agent consumer id {0} registered with topic value = {1}".format(data["agent"], data["topic"])) diff --git a/polymorphic_solver/src/ml_models/env.py b/polymorphic_solver/src/ml_models/env.py index addb9a0757c620c3925bb4307c0a7436bce07aee..1c66ae0529a78983976e21a9f037c32ced2041d8 100644 --- a/polymorphic_solver/src/ml_models/env.py +++ b/polymorphic_solver/src/ml_models/env.py @@ -91,6 +91,7 @@ prefix_predicted_metric = os.environ.get("PREFIX_PREDICTED_METRIC","Predictions" polymorphic_solver_topic = os.environ.get("POLYMORPHIC_TOPIC","polymorphic_solver") min_deployment_size_analysis = int(os.environ.get("MINIMUM_COLLECTION_SIZE_ANALYSIS","100")) +exploring_period = int(os.environ.get("EXPLORE_PERIOD","600")) def get_value_from_name(name, _type): name = str(name) @@ -234,6 +235,11 @@ class VirtualRealApplicationInteractor(): self.publisher.setParameters(data, polymorphic_solver_topic) self.publisher.send() + def generateExploreSignal(self): + data = {"request": "explore_solution"} + self.publisher.setParameters(data, polymorphic_solver_topic) + self.publisher.send() + def generateAnalysisreRequest(self): data = {"request": "analysis"} self.publisher.setParameters(data, polymorphic_solver_topic) @@ -358,6 +364,7 @@ class Environment(gym.Env): self.interactor = VirtualRealApplicationInteractor(interactor_connection_type,interactor_connection_hostname,interactor_connection_port) self.current_state = 0 self.n_deployment_selected = 0 + self.start_exploring_period = time.time() self.obs_n = {} self.iterations = 1 self.possible_agents = [] @@ -664,7 +671,13 @@ class Environment(gym.Env): performance = self.get_performance() if not performance: performance = MIN_PERFORMANCE + + if performance > MAX_PERFORMANCE / 2 : + self.start_exploring_period = time.time() + if time.time() - self.start_exploring_period > exploring_period: + self.interactor.generateExploreSignal() + reward = self.compute_rewards(performance) rewards[agent] = np.array(reward, dtype=np.float32) if performance >= MAX_PERFORMANCE: diff --git a/polymorphic_solver/src/morphemic.py b/polymorphic_solver/src/morphemic.py index 7d55a878ef5edce4b8ea7c34e080e9705772e6d6..e1a6ecf1cdd1d03d5273455f1d33c3a9e3883306 100644 --- a/polymorphic_solver/src/morphemic.py +++ b/polymorphic_solver/src/morphemic.py @@ -134,6 +134,7 @@ class MorphemicArchetypeManager(): self.best_camel_utility = None self.application_data = None self.application_id = None + self.current_group_index = 0 self.camel_transformer = CamelTransformer() def setCamel(self, file): @@ -242,6 +243,38 @@ class MorphemicArchetypeManager(): result += archetype.getAvgPerformance() return result + def explorePolymorphicSolution(self): + print("Exploring another polymorphic solution") + all_keys = [] + for archetype in self.archetypes: + all_keys.append(archetype.getKey()) + + archetypes = None + index = 0 + for group in combinations(all_keys, self.number_of_components): + if self.isGroupIsCompleted(group): + if self.current_group_index <= index: + index +=1 + continue + archetypes = self.getArchetypesByGroup(group) + for archetype in archetypes: + archetype.setLowestHighestFromRequirements() + self.current_group_index = index + break + + if not archetypes: + print("No valid component archetype found") + return False + + filename = self.camel_transformer.archetypesToCamels(archetypes, self.camel_version, self.current_grouping) + if filename: + self.camel_version +=1 + if self.importNewCamel(filename): + self.notifyMorphemic(filename) + self.polymorphic_solver.setCurrentDeploymentConfiguration(archetypes) + self.cleanAllArchetypes() + return True + return False def initialAnalysis(self): all_keys = [] for archetype in self.archetypes: @@ -253,9 +286,9 @@ class MorphemicArchetypeManager(): archetypes = self.getArchetypesByGroup(group) for archetype in archetypes: archetype.setLowestHighestFromRequirements() + break if not archetypes: print("No valid component archetype found") - print(self.archetypes) return False filename = self.camel_transformer.archetypesToCamels(archetypes, self.camel_version, self.current_grouping)