Wrap the logic inside a function with arguments (e.g., generations, population_size.In short, since MDHFVRP_postNL_v3.py serves as a script you import for your logic, here's two simple ways to refactor: As an example, here's the same problem in pure Python: image. Afaik, this isn't possible in Python - let alone with Pypeline - due to the way that importing a script works. Thanks for the explanation - and interesting idea!īased on the error and your code, I'm guessing your MDHFVRP_postNL_v3 script has its logic executed immediately and references externally defined variables. P圜nResults("import MDHFVRP_postNL_v3.py", generations, population, mutation, elite, penalty) īeta Was this translation helpful? Give feedback. String penalty = "penalty_value = " + ParPenaltyValue String mutation = "mutation_rate = " + ParMutationRate String population = "population_size = " + ParPopulationSize String generations = "generations = " + ParGenerations P圜n(String.format("penalty_value = " + ParPenaltyValue)) P圜n(String.format("mutation_rate = " + ParMutationRate)) P圜n(String.format("elite = " + ParElite)) P圜n(String.format("population_size = " + ParPopulationSize)) P圜n(String.format("generations = " + ParGenerations)) The following code does not seem to work: The names within "" are the parameters of the algorithm I would like to have anylogic send to python as I am trying to integrate sliders. I am experiencing some difficulties with sending parameter values to python in order to instigate the algorithm.
0 Comments
Leave a Reply. |