Solved

How to assign an initial value to paramter with a unit?

  • 6 January 2023
  • 4 replies
  • 74 views

Badge

Hi everyone,

 

We are using version 4.82.3.29.

I have a parameter called VOLL, that has the (implicit quantity) unit 2010/MWh. I want this parameter to have the value 3000 2010/MWh at model start-up, which can then be modified through the UI if desired. I figured this would be straightforward but it is giving me problems.

 

If I select ‘Initial data’, and use the wizard to specify the value 3000, AIMMS inserts the following code:

However, this immediately leads to an error! "The symbol "[" is not expected.” ...

 

Using Initial Data = 3000; (so without the unit specified) leads to VOLL having the value '-nan(ind)' at model startup, and 0 after executing the procedure that reads our database (and it is unclear to me why this procedure would affect the VOLL value).

 

I also tried to use the ‘Default’ field (it is not entirely clear to me what its purpose is as opposed to ‘Initial Data’). If I enter the value 3000 there, the parameter has the value ‘inf’ on model startup and '9.98892e+12' after reading database.

 

What is happening here? How can I properly define an initial value for the parameter VOLL?

icon

Best answer by Lennart 9 January 2023, 10:57

View original

4 replies

Userlevel 4
Badge +5

Dear @Lennart 

I am curious to understand how and why your unit is €2010/MWh. In my experience, I would normally use €/MWh as the unit of a parameter and not include a value. Or, if needed, I could add k€ or M€ or MM€ for thousands and millions of Euros.

To me, using the initial data with the 3000 should work correctly without the unit included.

Can you share you definitions of the units and maybe more on what your objective is?

Thanks!

Badge

Hi luispinto!

 

We use the unit €2010 and others to correct for inflation. We simulate a wide range of years, e.g. from 2010 to 2040, and use data from different sources that use different years for their prices (e.g. some input that spans multiple years is in €2010 while other is in €2015). These are then all converted to €2010 (inflation adjustment) for consistency across the model.

These are the definitions of the currency and energy quantities. EU00_EU15 etc. are parameters that define the conversion factors. These are read from the database (a procedure that is started manually, after starting the model). Could this be the problem?

DeclarationSection quantities {
    Quantity qCurrency {
        BaseUnit: €2015;
        Conversions: {
            €2000  ->€2015 : #->#*EU00_EU15,
            €2010  ->€2015 : #->#*EU10_EU15,
            €2011  ->€2015 : #->#*EU11_EU15,
            €2019  ->€2015 : #->#/EU15_EU19,
            
            ct€2000->€2015 : #->#*ctEU00_EU15,
            ct€2010->€2015 : #->#*ctEU10_EU15,
            ct€2015->€2015 : #->#/100,
            ct2015->€2015 : #->#/100,
            euro2015->€2015 : #->#,
            euro2010->€2015 : #->#*EU10_EU15,
            euro2020->€2015 : #->#/EU15_EU20,
            
            
            k€2015->€2015 : #->#*1e3,
            
            M€2015->€2015 : #->#*1e6,
            M€2010->€2015 : #->#*MEU10_EU15
        }
    }
    Quantity SI_Energy {
        BaseUnit: J = m^2*kg/s^2;
        Conversions: {
            kJ  -> J     :  # -> # * 1000 ,
            MJ  -> J     :  # -> # * 1.0e6,
            GJ  -> J     :  # -> # * 1.0e9,
            TJ  -> J     :  # -> # * 1.0e12,
            PJ  -> J     :  # -> # * 1.0e15,
            kWh -> J     :  # -> # * 3.6e6,
            MWh -> J     :  # -> # * 3.6e9,
            GWh -> J     :  # -> # * 3.6e12,
            TWh -> J     :  # -> # * 3.6e15
        }
        Comment: {
            "Expresses the value for the capacity to do work.
            
            !!m3gas -> J   :  # -> # * energy_gas,
            !ton_coal -> J:  # -> # * energy_coal,
            !ton_oil -> J :  # -> # * energy_oil"
        }
    }
}

 

Does that make things clear?

Yes, it does! I thought you were doing some kind of multiplication in the unit itself.

Are you able to share a small project that can reproduce the problem? This will help understand what is happening practically, since I was not able to reproduce on my computer.

Badge

I have managed to solve the problem. The issue was in the unit conversion that referenced a parameter, such as €2010  ->€2015 : #->#*EU10_EU15. The parameters EU10_EU15 where defined through another parameter, e.g. Conversion_euro('2000', '2015'), however this parameter did not contain data until the ‘Read Database’ procedure was manually executed.,In other words: at model start-up the data was missing. This presumably leads to the strange behavior.

I have solved the issue by defining the EU10_EU15 parameters explicitly as the conversion factor (i.e. defined as a number, instead of as a reference to another parameter).

 

Two comments:

  1. It would be nice if AIMMS gave a warning if a unit of measurements conversion references non-existing data
  2. It is a bit ridicules that if you use the ‘Initial Data’ wizard to define a value for a parameter using a unit, that AIMMS inserts code that doesn't compile (e.g. 3000 [€2010/MWh] ;)

 

If you still want to recreate the issue but are not able to do so with the above information, let me know. Thank you for taking the time to respond to my question!

 

Reply


Didn't find what you were looking for? Try searching on our documentation pages:

AIMMS Developer & PRO | AIMMS How-To | AIMMS SC Navigator