How to implement an if condition on a period

6 views
Skip to first unread message

Mahdi Ben Jelloul

unread,
Dec 13, 2018, 8:02:31 AM12/13/18
to liam2-users
Hello fellow LIAM2 users,

I am trying to implement a reform that change at some period REFORM_PERIOD.
I would like to avoid computing (and store see below) some fields.

My best implementation so far is to use while:

condition: period >= REFORM_PERIOD
while (condition):
    - some_code()
    - condition: False

Could I do better than this ?

Imagine know that I want to store the field variable_before is stored only until REFORM_PERIOD and then variable_after only after REFORM_PERIOD.
If i do not run anything involving redifining the field variable_before after period  REFORM_PERIOD, do I save writing it on disk ?
Same for variable_after ?

What if I use it by inadvertance in another formula on some period after REFORM_PERIOD ? What is the value I get ?

Thanks,

Mahdi
   

Gaëtan de Menten

unread,
Dec 13, 2018, 9:06:16 AM12/13/18
to liam2...@googlegroups.com

Hello Mahdi,

 

See my answers in the text.

 

Gaëtan

 

From: liam2...@googlegroups.com <liam2...@googlegroups.com> On Behalf Of Mahdi Ben Jelloul
Sent: Thursday, December 13, 2018 14:03
To: liam2-users <liam2...@googlegroups.com>
Subject: [liam2-users] How to implement an if condition on a period

 

Hello fellow LIAM2 users,

 

I am trying to implement a reform that change at some period REFORM_PERIOD.

I would like to avoid computing (and store see below) some fields.

 

My best implementation so far is to use while:

 

condition: period >= REFORM_PERIOD

while (condition):

    - some_code()

    - condition: False

 

Could I do better than this ?

 

No, not that I know of, but it should not be that hard to implement an "if" block in liam2 (probably named something else than if to avoid a collision with the if expression): almost a copy paste of the while code.

 

Imagine know that I want to store the field variable_before is stored only until REFORM_PERIOD and then variable_after only after REFORM_PERIOD.

If i do not run anything involving redifining the field variable_before after period  REFORM_PERIOD, do I save writing it on disk ?

Same for variable_after ?

 

What if I use it by inadvertance in another formula on some period after REFORM_PERIOD ? What is the value I get ?

 

Sorry, you lost me here. Could you adapt your example to show what you mean?



Disclaimer: This e-mail may contain confidential information which is intended only for the use of the recipient(s) named above.
If you have received this communication in error, please notify the sender immediately and delete this e-mail from your system.
Please note that e-mail messages cannot be considered as official information from the Federal Planning Bureau.

Mahdi Ben Jelloul

unread,
Dec 19, 2018, 4:09:22 AM12/19/18
to liam2...@googlegroups.com
On Thu, Dec 13, 2018 at 3:06 PM Gaëtan de Menten <g...@plan.be> wrote:

Hello Mahdi,

 

See my answers in the text.

 

Gaëtan

 

From: liam2...@googlegroups.com <liam2...@googlegroups.com> On Behalf Of Mahdi Ben Jelloul
Sent: Thursday, December 13, 2018 14:03
To: liam2-users <liam2...@googlegroups.com>
Subject: [liam2-users] How to implement an if condition on a period

 

Hello fellow LIAM2 users,

 

I am trying to implement a reform that change at some period REFORM_PERIOD.

I would like to avoid computing (and store see below) some fields.

 

My best implementation so far is to use while:

 

condition: period >= REFORM_PERIOD

while (condition):

    - some_code()

    - condition: False

 

Could I do better than this ?

 

No, not that I know of, but it should not be that hard to implement an "if" block in liam2 (probably named something else than if to avoid a collision with the if expression): almost a copy paste of the while code.

 

Imagine know that I want to store the field variable_before is stored only until REFORM_PERIOD and then variable_after only after REFORM_PERIOD.

If i do not run anything involving redifining the field variable_before after period  REFORM_PERIOD, do I save writing it on disk ?

Same for variable_after ?

 

What if I use it by inadvertance in another formula on some period after REFORM_PERIOD ? What is the value I get ?

 

Sorry, you lost me here. Could you adapt your example to show what you mean?


Image ine variable_1 and variable_2 are field of some entity with only one member.
Basically what I want to know is which value is stored in the h5 file when I proceed as follows.

condition_1: period < REFORM_PERIOD

condition_2: period >= REFORM_PERIOD


while (condition_1):

    - variable_1: 1

    - condition_1: False


while (condition_1):

    - variable_2: 2

    - show(variable_1)

    - condition_2: False


What the show produce ? (I know i can try it myself ;-))
What is stored in the h5 for each period ?

Thanks

Disclaimer: This e-mail may contain confidential information which is intended only for the use of the recipient(s) named above.
If you have received this communication in error, please notify the sender immediately and delete this e-mail from your system.
Please note that e-mail messages cannot be considered as official information from the Federal Planning Bureau.

--
You received this message because you are subscribed to the Google Groups "liam2-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to liam2-users...@googlegroups.com.
To post to this group, send email to liam2...@googlegroups.com.
Visit this group at https://groups.google.com/group/liam2-users.
--
Mahdi Ben Jelloul
Reply all
Reply to author
Forward
0 new messages