Opened 15 years ago

Last modified 15 years ago

#1172 closed defect (fixed)

Problem with for loop in algorithm (from MathCore)

Reported by: Karin Gustafsson Owned by: Karin Gustafsson
Priority: blocker Milestone:
Component: Version:
Keywords: Cc: Karin Gustafsson, Adrian Pop

Description

See the attached model, it is a version of the Dining Philosophers Problem.

It is ok to validate the model but not to build it. The problem is in the class Mutex. It has a for loop in the algortihm section. If doing instantiateModel(Philosoper.DiningTable?) some of the code looks like:

for i in {1,2,3,4,5} loop

when mutex.request[mutex.i] then

mutex.ok[mutex.i] := true;

The index should be just "i" and not "mutex.i".

Attachments (1)

DiningTableTotal.mo (22.3 KB ) - added by Karin Gustafsson 15 years ago.

Download all attachments as: .zip

Change History (5)

by Karin Gustafsson, 15 years ago

Attachment: DiningTableTotal.mo added

comment:2 by Adrian Pop, 15 years ago

First, it should be mutex.i instead of i in the for loop
as that is in the scope of mutex.

Besides this, which seems a problem with prefixing the for index
I think that the for loop should be unrolled (should disappear and
the statements in it should be repeated n times) when it
contains when statements as otherwise the matching
variables/equations will not be correct.

comment:3 by Jan Brugård, 15 years ago

the customer is requesting information about the progress with this bug. Could you please give me an update!

comment:4 by Adrian Pop, 15 years ago

Revision 5133.

  • Iterators are now not prefixed.
  • For loops containing when statements are unrolled.



Could you please check with your back-end if the model is now working for you?

Note: See TracTickets for help on using tickets.