Skip to main content
April 29, 2014
Solved

Question

  • April 29, 2014
  • 1 reply
  • 3590 views

Hy! I've created an algorithm. I've attached it.

In this algorithm I have assigned initial values to x1,y1,p1,p2,p3,p4.

Then I inserted a "while" function. My question is: why don't the variables take the new values?

For example: Q is the new value of A. This means that x1,x2,p1,p2,p4 have new values, but the results that the algorithm gives me are still the initial values. I want the new values that variables have untill the "while" function is fulfilled.

Thanks.

Best answer by Werner_E

I guess the iteration should be sligthly different, but the main problem seems to be that the initial value for x1 and y1 are chosen in a way, that the RHS of the inequality would already yield a result greater than N if p1,p2 and p2 would be calculated the same way as shown in the iteration loop. So the iteration runs exatly one step and stops when that RHS is approx 10.7...

Solution could be to chose larger initial values for x1 and y1.

Find attached a routine which outputs a table so you can watch the values change. You will have to find suitable start values for x1 and y1.

1.png

But is it really mandatory that both x1 and y1 are changed the same way (-0.01)? I guess you are simply trying to search for values x1 and y1 which makes the RHS equal to N.

If thats true, so why not try a solve block:

2.png

Thats only one of an infinite number of solution pairs, so you could add some appropriate constraints like

3.png

or

4.png

Basically your RHS represents a surface in 3D which you have to intersect with the plane at height N:

5.png

The curve of intersection can also be drawn as a 2D plot, y1 over x1:

6.png

BTW, John Smith, isn't this question related to this one of John Air: http://communities.ptc.com/message/240228#240228 ?

1 reply

19-Tanzanite
April 29, 2014

John Smith wrote:

...My question is: why don't the variables take the new values?

Because the initial value of that long expression is less than N. Hence the while loop is never entered!

Alan

April 29, 2014

I know. But the while loop makes the value grow until that N>... is not fulfilled.

Any idea of how can the while loop be entered?

19-Tanzanite
April 29, 2014

The while loop is entered only once. The values of a, b, c, d, e are assigned the starting values of x1, y1, p1, p2, p4. Then the values of x1, y1, p1, p2, p4 are changed. The while loop is not entered a second time, so what you get are the starting guesses. If the values of a, b, c, d, e are assigned after you have assigned the values for x1, y1, p1, p2, p4 you will see the values for the last time it entered the loop, rather then the one before that.