The Shepherd, who Palpates his Hens

I took the matter of understanding PEO algorithms seriously, I wanted to understand it at least to a small degree – I’m not after mathematical background, because that I read about too, but rather using that license in practice and finding some golden methodology for dealing with it. Due to a lack of sources about PEO, I came into conclusion, that I had no other option but to use the “palpating” methods. However, that required formulating a problem that you could physically palpate 🙂 It ended up with the decision to mark out a point on a spline curve, in which the curvature radius reaches the minimum. That relates to a problem in my work, which I will have to face soon, i.e., template, which will generate a pressure hose along with checks for compliance with the minimum bending radiuses.

Determining the minimum curvature radiuses is no problem, using a simple formula : The problem begins, when you want to mark out the point that has that minimum curvature radius.

I’m not talking about Porcupine Analysis, which the program began to have along with some update, and which gives us a datum point that we have to generate each time we change our spline curve. I’m talking about an approach, which would provide that, during any global update of the curve.

EKL gives us the possibility to determine the value of the curvature radius in a point: Only how do I know where that point is…

I got inspired while sifting through pages of the CATIA documentation, namely:

A simple formula, provided that you have KWA, PKT (not necessarily) and PEO licenses.

– PEO – to find a point, in which the curvature value is minimum,

– KWA – to force loop optimization using the script and the reaction,

– and finally, PKT, to make a template out of everything in the form of User Defined Feature – but I aim for Power Copy – I haven’t checked yet, but my PC should be able to take it.

So the formula is: And the only weak link of that formula is the PEO – because how am I supposed to know which optimization parameters am I supposed to set, in order to be sure that what I’m getting is the optimal value… And where am I getting the inputs from – here I throw in the process of my “palpating”, i.e., the measured minimal curvature radius, which is: The first optimization with default settings:

– as the Best value it located a point, in which the value of the curvature radius equals to approximately 29 mm – my, my… that’s far from ideal… Here’s a screenshot showing, where our point is, and where it’s supposed to be (just like the minimum, but local instead of global.) : – attempt no. 2, i.e., we’ll increase the number of iterations:

– and again, no success…

– now, we’ll increase the number of iterations having not found a better result:

– still no success… although, in the previous attempts, that parameter at times drew the optimal result closer…

– another attempt, i.e., increasing the number of iterations – which did nothing, and then, getting the point closer to the minimum value through decrease in iterations:

– hurray 🙂 We’re nearly there 🙂

I’ll leave it for the readers to reflect on, as for me, I think I’ll give up using PEO in this template…

It would be nice to have some cool macro, which would extract the curvature radius value from each point set away by the amount of the CATIA error – that’s the cluster of data that I search for the minimum value in, to generate a point in that place.

One conclusion occurred to me – you can’t blindly trust PEO… It’s a useful tool, but you need to be oriented where to act – accordingly interpret the results … So far, Target value proved to be flawless for me – or maybe I just had cases that were more open to it. While in the case described, I cannot rely on the method described, especially because I’d like the optimization to work “in background” without any interference in its parameters.

Andrzej Welyczko 17 august 2016 05:01

I also have the impression that for the Optimization Type = Target Value optimization result is closer to the reality.

Define following parameters:

where xPoint is a point on MojaKrzywa  (better to define this point with the parameter Ratio of curve length, because then this parameter value is always, regardless of the length of the curve, in the range 0 <x <1)

In order to define optimization of type Target Value I suggest to create another parameter:

Then for Delta parameter Target Value = 0mm

With this optimization problem the free parameter is obviously Ratio of point xPoint. Do not set the initial value close to curve’s extremum.

I usually set 0 or 1

With Simulated Annealing algorithm I selected

Convergence speed=Fast

(High number of iterations gives system more freedom to find global optimum)
Maxiumum time=1
switch off Save optimization data (for 2000 iterations saving results to disc file takes too much time)
Run behaviour = with visualization update

Run optimization

For me it works

PS
Nice blog. Congratulations
AW

Łukasz 17 august 2016 08:34

I checked and depending on what end of the curve I start (ratio 0 or 1) I obtain again either local or global extremes. In the evening I will upload a video. I assume that in order to be sure that I get the global optimum, I will create first the point closest to the point of inflection, i.e. with the smallest measured curvature of the bunch of points generated. And I will use this point to optimize to get close to the extreme. Currently I’m working on a rule that generates a list of points, but I am encountering various obstacles that I will soon shortly describe (such as extracting the parameter name from the list and returning it to the string parameter …) – I’ve already found some ugly methods but I have to work on them and I do not know what  other obstacles will come across on the way 🙂 But the assumption  is to do it just by using CATII functionality – because I just start to slowly understand the macros
Thank you for commitment, not for the first time.

Łukasz 17 august 2016 08:50

And the DELTA parameter – it’s a nice solution for the fact that you cannot  attach an external parameter in Target Value 🙂 Perfect for my case…

Andrzej Welyczko 18 august 2016 01:13

Macro can do everything (almost).
I tried to avoid using PEO and define minimum curvature point with Knowledge Pattern!

In my startup model I have:
INPUT\MyCurve
INPUT\StartPoint >> start point on curve MyCurve

OUTPUT\XPoint >> any point on curve MyCurve defined with Ratio of curve length. In my case before KP definition and execution Ratio=0.

Value of this point Ratio is equal to external parameter XRatio (formula OUTPUT\XPoint\Ratio = XRatio)

KP code compares curvature radius of current point (on MyCurve) with MinRadius value. If difference is smaller or equal 0,001mm then KP stops.

Parameters\XRatio >> value of this parameter is calculated by KP (start value XRatio =0)

Parameters\XMinRadius >> value of this parameter is calculated by KP. At the beginning XMinRadius = 0. This parameter is not necessarily required but  I defined it to check if KP is working fine.
Finally Knowledge Pattern object:
Execution mode = Automatic execution (before root update) >> with this after any MyCurve shape modification KP is executed to find new XPoint
Options: ALL switch off!

Switch off Show stop panel option, because it is not useful.
Knowledge Pattern Lists: there is no list! (KP does not generate any 3D geometry)

KP code (maybe not optimal but working):

let I (Integer)
let K (Integer)

let Px (Point)

let xRatio (Real)
let RatioOpt (Real)
let RatioStart (Real)
let RatioEnd (Real)
let RatioRange (Real)

RatioOpt = 0
RatioStart = 0
RatioEnd = 1

K=1
{
RatioRange = RatioEnd-RatioStart
I=1
For I while I<=100
{
xRatio = RatioStart+I*RatioRange/100
set Px = pointoncurveRatio(INPUT\MyCurve, INPUT\StartPoint, xRatio, true)
set XMinRad = 1mm/curvature(INPUT\MyCurve , Px)
{
RatioOpt = xRatio
}
}
RatioStart = RatioOpt – RatioRange/5
RatioEnd = RatioOpt + RatioRange/5
}
XRatio = RatioOpt

Łukasz 19 august 2016 14:05

Thanks AW … give me a break .. I will upload it as a new topic because this is a mystery, anywhere else in the world you will not find it. I will make a post out of it 🙂