Download - Slides and Notes to Unit 4 3 Brute Force (1)
-
8/10/2019 Slides and Notes to Unit 4 3 Brute Force (1)
1/29
-
8/10/2019 Slides and Notes to Unit 4 3 Brute Force (1)
2/29
This example is about a gear milling machine.
The red cylinder is a blank to become a spurgear.
There is a rotating form cutter going through the blank to remove the tooth gaps. !or
simplicity the drive of the form cutter and the bearing of the form cutter is not shown.
The feed motion is reali"ed via a rotating axle having a trape"oidal thread.
#ach feed travel produces one tooth gap.$etween milling one tooth gap and milling the next tooth gap, the blank has to be
turned according to the gap distance. This is not shown.
%aving done all tooth gaps, the result is a spurtoothed gear.
If you want to produce a skewedtoothed gear, you have to turn the blank while milling.
&
-
8/10/2019 Slides and Notes to Unit 4 3 Brute Force (1)
3/29
%ere you see a schematic gearing system to turn the red blanket during milling in order
to make a skew toothed gearing.
In order to adust the skew angle, there is a gear box with gears 1 to ' which can be
changed.
In order to ad(ust the skew angle, the right gear ratio n')n1 has to be reali"ed.
*
-
8/10/2019 Slides and Notes to Unit 4 3 Brute Force (1)
4/29
+emember chapter *, when arin talked about brain storming- This was my first sketch
for the gear milling machine.
'
-
8/10/2019 Slides and Notes to Unit 4 3 Brute Force (1)
5/29
ow how can we ad(ust the gear ratio-
Assume we have ' different boxes, each containing wheels for one position in the gear
box/
!or the first wheel position we can pick a wheel with a radius from 0 to 00 in steps of 0.
!or the second position we choose from 1 to 10 again with steps of 0.
The third wheel2s radius ranges again from 0 to 00.
And the last wheel can be taken from 1 to 10.
This makes 11 different wheels for each wheel position.
ow the task for brute force is/
!ind a combination that best reali"es a gear ratio of .&03
0
-
8/10/2019 Slides and Notes to Unit 4 3 Brute Force (1)
6/29
-
8/10/2019 Slides and Notes to Unit 4 3 Brute Force (1)
7/29
So one approach to partition the work could be:
Mr. Jones should generate all possible combinations of r1,r2,r3,r4
Mr. Smith should find out how to calculate the gear ratio as a function ofr1,r2,r3,r4
Mr. Miller will memorize the best combination Mr. Jones generated and Mr. Smith
evaluated.
7
-
8/10/2019 Slides and Notes to Unit 4 3 Brute Force (1)
8/29
%ow (ones creates the combinations will be shown live in 8atlab.
9
-
8/10/2019 Slides and Notes to Unit 4 3 Brute Force (1)
9/29
Now we have to leave Matlab for a short time, because before Smith can start his
Matlab work, he has to do some calculations on a piece of paper.
Here are his thoughts on how to calculate the gear ratio of a combination.
What is a gear tooth system good for?
Avoid slippage, thus the translational velocities of gear 1 and gear 2 are identical.
The same is true for gear 3 and gear 4.
Gear wheel 2 and Gear wheel 3 or on the same shaft, therefor they have the
same angular velocity:
From that after some basic steps we get the final Gear ratio R
In the matlab code, the desired Gear ratio is denoted as RD. And first we start
with RD=0.02.
:
-
8/10/2019 Slides and Notes to Unit 4 3 Brute Force (1)
10/29
This is our first working code as it was (ust developed in matlab. It works very well to
find combinations with a ;ear +atio of .& or if I change the value of +4 for any ;ear
+atio which is possible without an error. $ut as we have a limited choice of gear wheels,not all ;ear +atios can be reali"ed without an error.
If we change +4 for example to .&0, there is no combination matching this value,
thus our bestcombi array is empty.
$ecause of the small difference +
-
8/10/2019 Slides and Notes to Unit 4 3 Brute Force (1)
11/29
%ere is an approach to overcome this problem.
ow =mith calculates the error
of each of his combinations.
8iller then picks the combinations with the smallest error instead of the combinations
with error . Thus we always get suggestions.
In this example we still get ' combinations with an error as small as 1.something times
1 to the power of 0.
11
-
8/10/2019 Slides and Notes to Unit 4 3 Brute Force (1)
12/29
The version we have right now, has the advantage, that it is easy to understand as we
only have a few lines of code. $ut stylewise it resembles a mixture of two programming
paradigms within matlab/
>se loops and nothing special
>se special functions for matrices.
As matlab ?remember the full name matrix laboratory @ is speciali"ed in 8atrix
operations, it2s full elegance and beauty only shows up if you use matrix functions.
n the other side, a lot of people are no native matlab programmers, they started their
career in B or Cavaprogramming. These people like to have it in a more close to Bstyle.
=o letDs look on two more styleconsistent solutions.
1&
-
8/10/2019 Slides and Notes to Unit 4 3 Brute Force (1)
13/29
This version does not use a loop at all, but employs the function allcomb to produce all
possible combinations. This function is not part of matlab, but can be found within
matlab central, where matlabwi""ards from all over the world add useful functions thatare not included in the official matlab releases.
1*
-
8/10/2019 Slides and Notes to Unit 4 3 Brute Force (1)
14/29
This version only uses loops.
There are two changes to the work of Cones/ The si"e of combi is precalculated by the
command combi
-
8/10/2019 Slides and Notes to Unit 4 3 Brute Force (1)
15/29
This version only uses one loop and no array at all.
10
-
8/10/2019 Slides and Notes to Unit 4 3 Brute Force (1)
16/29
ow the controller of your company says/ it is not possible to deliver four different boxes
with each machine. Cust two boxes have to suffice. !irst think about whether this makes
sense. Then change the code to meet this new re5uirement.
16
-
8/10/2019 Slides and Notes to Unit 4 3 Brute Force (1)
17/29
The highlighted part of the code is added. All combinations are generated, but only
those that satisfy the condition r1 being different form r* and r& being different from r'
are used.
It is 5uite common, that you do not have a good scheme to come up only with those
combinations, that are interesting. Therefor you generate all and filter out the misfits.
17
-
8/10/2019 Slides and Notes to Unit 4 3 Brute Force (1)
18/29
=o far, we accepted combinations with different locations of shaft '. Assuming shaft 1
fix, the relative location of shaft ' would be r1Fr&r*r'. ow this relative position shall
be "ero Thus/ r1Fr&
-
8/10/2019 Slides and Notes to Unit 4 3 Brute Force (1)
19/29
In the highlighted region of the code the condition r1Fr&
-
8/10/2019 Slides and Notes to Unit 4 3 Brute Force (1)
20/29&
-
8/10/2019 Slides and Notes to Unit 4 3 Brute Force (1)
21/29
The ideal distance for the axis is that one, which maximi"es the number of possible
combinations. =o finding the optimal axis distance is a brute force problem by itself.
Gariable rfBombis counts for each distance d, how many valid combinations arepossible. The first two conditions in line 1 refer to the right distance of the gears, the
last one reflects , that each gear si"e is available only once. Hou could add a condition
r&Jr', but that one is logically included from the other * conditions.
&1
-
8/10/2019 Slides and Notes to Unit 4 3 Brute Force (1)
22/29
With the fixed distance d, r& is determined by d and r1K as well as r' is determined by d
and r*. Thus we only need two loops.
&&
-
8/10/2019 Slides and Notes to Unit 4 3 Brute Force (1)
23/29
-
8/10/2019 Slides and Notes to Unit 4 3 Brute Force (1)
24/29
An unknown weight W
has to be determined
using a beam balance.
The weight W is an integer multiply of 1 kg and is smaller or e5ual Wmax.
Hou can choose ' reference weights to make this possible.
According to 4ivide and con5uer the solution is subdivided in two steps/
=tep1Learn %ow to decide whether a certain weight can be determined with a given set of W1
to W'.
=tep&
>se step one to find a set of W1 to W' suitable to measure all weights smaller e5ual
Wmax.
!or the first step/
The unknown Weight W is always placed on the left scale pan. The weights W1 to W'
&'
-
8/10/2019 Slides and Notes to Unit 4 3 Brute Force (1)
25/29
can either be placed on the left pan ?coded by Mosition M< 1@
or on the right pan ?coded by M
-
8/10/2019 Slides and Notes to Unit 4 3 Brute Force (1)
26/29
The weight W and the Weights W1 to W' are passed to the function Positions as
arguments.
The four for loops try all possible weighting configurations for the ' Weights W1 to W'.
In line 6 we check if both pans balance.
If yes, we stop the function ?keyword return@ the return values are the current values of
M1 to M'. If no working weighting combination is found, we return the impossible
positions & which stands for no success.
&0
-
8/10/2019 Slides and Notes to Unit 4 3 Brute Force (1)
27/29
ow all possible combinations of weights W1 to W' are tried ?lines & to 0@ . If a
combination fails to measure one of the weights ?test in line 9@, the next combination is
tried ?break command in line 1@.
If a combination worked ?condition Works in line 1*@ then the program is finished.
therwise the program ends, when all combinations are tried without success. In this
case Works has the value false.
&6
-
8/10/2019 Slides and Notes to Unit 4 3 Brute Force (1)
28/29
As the last extension of this problem, let2s determine the biggest maximum weight, that
is possible with ' weights. ur old program is turned into a function. A new one looks
for the maximum weight. This version may take some time ?on my machine : s@. If youwant to stop the execution you can hit Ncontrol cO.
=ome details on the code/
We increase Wmax after we find a possible weight set. This means we recogni"e '
works then increase to '1 and find that '1 does not work. =o the last working Wmax is
Wmax leaving the loop minus 1.
Mositions
-
8/10/2019 Slides and Notes to Unit 4 3 Brute Force (1)
29/29
!or simplicity, the code for wmax did not include an output of the final weight set. The
final weight set can be seen running the previous code with Wmax