Messages from list : cormas@cirad.fr

Choose a topic among the following archives :

RE: 2 problems: export model & add new element in an object

New Message Reply Date view Thread view Subject view Author view

Subject: RE: 2 problems: export model & add new element in an object
From: Nicolas Becu (becu@uni-hohenheim.de)
Date: Tue Sep 13 2005 - 15:51:53 CEST

Hi

About point 1/ (change name of model).

My experience is that making a Find&Replace in the st file with notepad or
Ms Word, doesn't work (because some characters are added by the software).

Thus I do the Find&Replace with the File Manager of VisualWorks, and this
works perfectly well.

Cheers

Nicolas

-----Original Message-----
From: owner-cormas@cirad.cirad.fr [mailto:owner-cormas@cirad.cirad.fr] On
Behalf Of Pierre Bommel
Sent: 13 September 2005 15:31
To: christophe.viavattene@ensmp.fr
Cc: cormas@cirad.fr
Subject: Re: 2 problems: export model & add new element in an object

Hello Christophe,

Le 13 sept. 05, à 07:40, Christophe Viavattene a écrit :

> Dear all,
> I have two problems with cormas...
>
> 1/
> First I would like to export my model to a new directory to develop it
> with
> other data. But if I just saved it in a new directory, I can't open
> it. I had
> the same problem if i just copy it from one to a new directory. There
> is a
> problem, I think, to open it because the namespace change. Do you know
> some
> options to export a model to a new directory ?

For the moment, it is not possible into Cormas to rename a model (and
such, to create a new directory).
You can just change the version name of your model : MyModel1.st ->
MyModel2.st etc...
If you really need to change your model name, you can do the following
things :
  - Out of Cormas, create a directory (SecondModel for ex, with
Uppercase for the first letter)
  - Copy your files MyModel.st and MyModel.ev to this new directory
  - Edit MyModel.st with TextEdit or BlockNote or something like that
  - Change all the word "MyModel" by "SecondModel" into the XML file and
save it.
  - Open Cormas and load SecondModel... normally, it works...
>
> 2/My second problem concerns the creation of a new element in an
> object. When
> I tried to count all the elements (self theCaptages size), it gives me
> always
> the initial number of Captages without taking account the new created
> captages. But if I used the tools "query ... all instances", I can
> see that
> my new elements are created and I can see them too on my simulation
> interface. So I am not really sure that my model used these new
> elements in
> each step of my models.
> Do you have some idea to correct this problem?
Yes.
   ... :)

To create a new instance of a class and to store it at the level of the
collection theCaptages, there is 2 possibilities :

  - The old one : do it by your self as it is described in the old
version of ECEC (see http://cormas.cirad.fr/pdf/CormasTutorial2.pdf) :
       - create your new instance at the level of your agent :
        reproduce
        ý newForager ý
        self energy > self class fertilityThreshold
                ifTrue:
                        [newForager : self class new init.
                        self energy: self energy - newForager energy.
                        newForager moveTo: self nearestEmptyLocation].
        ^ newForager
      - add it to the collection theXXXs at the level of the Scheduler
by using :
        * self stepDynPop: self theForagers or
        * step: t
        | newBorns repro |
        newBorns := OrderedCollection new.
        self theForagers
                do:
                        [:anAgent |
                        repro := anAgent step.
                        repro notNil ifTrue: [newBorns add: repro]].
        self update: aCollec with: newBorns
.... rather long isn't
it ?

  - The new one is much more efficient : use "newEntity:"
        newForager := self newEntity: self class
        Ex:
        reproduce
        ý newForager ý
        self energy > self class fertilityThreshold
                ifTrue:
                        [newForager := (self newEntity: self class) init.
                        self energy: self energy - newForager energy.
                        newForager moveTo: self nearestEmptyLocation].
        By using "newEntity:" the new intances are created and automatically

collected by Cormas at the level of theXXXs collection.
Make your choice...

Hope it helps...

        Pierre

>
> Thanks for your help
>
>
> --
> Viavattene Christophe
> Ecole des Mines de Paris
> Centre d'Informatique Géologique
> 35, rue Saint Honoré
> 77305 FONTAINEBLEAU Cedex
> Tel. : 01 64 69 49 15
>
>
        Pierre Bommel - CIRAD - UR Green
        Universidade de Brasilia - CDS
        SHIS QI 26, Conjunto 15, Casa 18
        71670-150
        Brasilia DF
        tel: (00 55 61) 3367 3405
        http://cormas.cirad.fr

New Message Reply Date view Thread view Subject view Author view
 

Back to home