![]() In the pipeline examples, the following code is used for a function based on two parameters I want to pass the distance matrix only in this function (if possible even). To retrieve the result I have created a function based on 21 parameters. Here the distance matrix is included also. The solutions you provide are applicable to functions with single parameters, however, I have defined multiple functions that use different parameters but the value of the parameters are equal over the different functions.įor the genetic algorithm, I first have to define functions such as evaluate_capacity and the breeding of new solutions. There have been some design changes and I am encountering issues again that I have not been able to resolve myself. The following is an example with both of these solutions demonstrated: Model167.zip You still need to wrap its logic in a function, but rather than have inputs/outputs, use the global keyword at the top for all the variables. If you want to interact manually with variables, first define all input and output variables at the start of MDHFVRP_postNL_v3.py.This is the simplest and most "Pythonic" solution (I recommend it). 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. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |