07-09-2024 01:14 PM
Good evening, I am writing to ask you for help with a problem.
I would like to make an optimization program with a genetic algorithm for some parameters, in particular I will impose the parameters from the CAN network, tests will be carried out on the system autonomously and I will receive the result from the CAN network.
The problem is not about the CAN communication of parameters and results, it is about setting up a genetic optimization system, which I have no idea how to implement.
Is there anything recent and working? I only found one example from 2009 of this. Can you help me?
Thank you in advance
07-09-2024 02:04 PM
@Nunzio1999 wrote:
Good evening, I am writing to ask you for help with a problem.
I would like to make an optimization program with a genetic algorithm for some parameters, in particular I will impose the parameters from the CAN network, tests will be carried out on the system autonomously and I will receive the result from the CAN network.
The problem is not about the CAN communication of parameters and results, it is about setting up a genetic optimization system, which I have no idea how to implement.
Is there anything recent and working? I only found one example from 2009 of this. Can you help me?
Thank you in advance
I have no idea how to guide you. You simply used the vague words optimize and parameters.
Optimize what? Describe your system and your "Optimized" ideal. Optimal efficiency? Speed? Memory usage? Error? Whatever. What inputs (parameters) do you have control of? What measurements are you taking? How? With what hardware? Are your parameters controlled in a closed loop or an open loop?
And, certainly, we will need to look at the code you have AND read your comments about whatever isn't working in it to your satisfaction.
07-09-2024 02:28 PM
I was vague because exactly I haven't built anything yet, because the main part, which is the optimizer, I don't know how to build it for now. However, I will explain the imagined system:
- the optimizer has the 3 pid values as parameters
- there is a vehicle controlled by an Arduino system which runs a speed cycle (30 seconds duration), has a target speed and evaluates the current speed, from this the PID gives an accelerator signal
Target speed and current speed are sent over the CAN network
- a LabVIEW system acquires target speed and actual speed, it makes the difference
At the end of the cycle it makes a calculation to calculate an indicative value of the accuracy of the cycle obtained with respect to the target cycle, the target value for the optimizer
You move on to the next set of values
Basically this must be done, now, I am capable of creating the entire boundary system, but I don't know how to create the genetic optimizer, I'm asking for help on this, even if you can provide me with some code examples where the genetic algorithm is applied
At the moment I can only publish the Arduino code, but I don't think it's of interest
07-09-2024 02:37 PM
I was vague because exactly I haven't built anything yet, because the main part, which is the optimizer, I don't know how to build it for now. However, I will explain the imagined system:
- the optimizer has the 3 pid values as parameters
- there is a vehicle controlled by an Arduino system which runs a speed cycle (30 seconds duration), has a target speed and evaluates the current speed, from this the PID gives an accelerator signal
Target speed and current speed are sent over the CAN network
- a LabVIEW system acquires target speed and actual speed, it makes the difference
At the end of the cycle it makes a calculation to calculate an indicative value of the accuracy of the cycle obtained with respect to the target cycle, the target value for the optimizer
You move on to the next set of values
Basically this must be done, now, I am capable of creating the entire boundary system, but I don't know how to create the genetic optimizer, I'm asking for help on this, even if you can provide me with some code examples where the genetic algorithm is applied
At the moment I can only publish the Arduino code, but I don't think it's of interest
07-09-2024 07:08 PM
A network is for communications, not for computations.
Where does the data come from?
Where should the optimization (whatever that means!) occur?
What is the model and what are the parameters?
If you found an example, why not give us the link?
Are "parameters" initial guesses and "results" optimized version of the same parameters?
As an initial attempt to work out the algorithms, can you do the optimization locally with simulated parameters where the result is known? Adding the CAN communication can be added any time later.
07-11-2024 07:53 AM
It's possible that I did something wrong in expressing myself and understanding in English, so I'll explain everything again.
The system to be optimized is a real system, which works using PID.
The parameters to be optimized are the 3 PID parameters (proportional gain, integral time and derivative time).
The result of the optimizer is an absolute value (given by the difference between the target speed and the speed obtained with the imposed parameters), which must be minimised.
The optimization I would like to do is a genetic optimization in order to obtain the best set of parameters in the shortest possible time.
So, to summarize:
- the parameter set is imposed on the real system
- the real system runs a simulation cycle and returns an objective value
The problem is that I don't know how to replicate the genetic algorithm. I link the example from 2009:
https://forums.ni.com/t5/Example-Code/Genetic-Algorithm-Code/ta-p/3490759
Thank u for help
07-11-2024 08:10 AM
To simplify you're trying to implement a cruise control-like system using PID, the process parameter and set point are both numerics that are read/written over the CAN bus.
Now, you want to find the optimal P, I, and D values for this PID controller. Does this summarize well?
07-11-2024 08:48 AM
@santo_13 wrote:
To simplify you're trying to implement a cruise control-like system using PID, the process parameter and set point are both numerics that are read/written over the CAN bus.
Now, you want to find the optimal P, I, and D values for this PID controller. Does this summarize well?
Let's ask 1 more question. Is the load constant (like cruse control driving on a flat surface) or dynamic ( like driving over hills)?
Generally speaking, a PID Loop is mostly worthless unless the system has a dynamic input that affects the measured value.
Again, what does the system measure and what inputs can you measure?