I haven't found a topic similar so I am asking
I am dealing with optimization of mechanism where I found bunch of variables as length, coordinates and some variables are angles between 0 and 2pi. One of the restrictions in is that the angles must be consecutive angles. I am comparing the angles and penalizing the solution when it generate non-consecutives angles but I am missing when the angles are near 2*pi since a valid solution is for example: 6, 6.1, 0.1, 0.2 [rad].
if( T2_1 == min(T2_1,T2_2,T2_3,T2_4,T2_5,T2_6) and
T2_2 == min(T2_2,T2_3,T2_4,T2_5,T2_6) and
T2_3 == min(T2_3,T2_4,T2_5,T2_6) and
T2_4 == min(T2_4,T2_5,T2_6) and
T2_5 == min(T2_5,T2_6) ):
M1 = 1e3 #Penalty
I used sorted to sort the angles but I need that the script 'understand' that the angles should be consecutives and that way I need the penalty value to add it in the function I am trying to optimize.
I am obtained results but I am limiting the solutions and the minimization is not working
Any advice would be helpful
Thank you for reading
EDIT, to clarify:
This is a optimization problem of creating a four-bar mechanism and the angles represent different position angles of a bar in a four-bar mechanism. I am interested in the relative position of that bar.
By consecutives angles I mean from lowest to highest, but keeping in mind that if the angles start near 2*pi (4th quadrant) and continue enough to change to the 1st quadrant, that is a valid solution. Example: 6.0, 6.1, 0.1, 0.2, 0.3, 0.5 [rad] are consecutives angles, since I am interested in the relative position and in this case 0.1rad actually mean 0.1+2*PI; 0.2rad actually mean 0.2+2*PI; 0.3rad actually mean 0.3+2*PI and 0.5rad actually mean 0.5+2*PI.
If I analyze the values with the operation above then it receive the penalty, since T2_1=6.0 is not the minimum in those values (it may be for angles but not for decimals). Keep in mind that the values are generated randomly from 0 - 2PI and a value of 0.1rad could mean 0.1rad or 0.1+2*Pi rad as in the previous example.
Other cases:
- 0.5, 1.0, 1.5, 2.0, 2.2, 2.5 [rad] - Valid (The function above work with this case)
- 0.8, 6.1, 0.1, 0.2, 0.3, 0.5 [rad] - Invalid
- 0.5, 1.0, 1.5, 6.0, 2.2, 2.5 [rad] - Invalid
- 5.5, 6.0, 6.28, 1.0, 1.2, 1.5 [rad] - Valid
While I was writing the edit, I realized the difference between the consecutives angles must have a maximum; if not, every angle could be a consecutive from the other that give a big jump. So, maybe I need to research about the maximum jump the angle can make. However, I need the script to figure out if any angle Xrad mean Xrad or X+2*Pi rad
I am checking one of the answers that pointed me to work with the difference of the angles since I think it may work.
I am sorry for the complicated question, this is a work in progress and I know I need the investigate more, but I am stuck with the consecutive angles near 2*PI and could not find a solution anywhere.