Solved

Reading zero values using DEX Library Excel

  • 8 August 2023
  • 2 replies
  • 75 views

Badge +1

I want to map data from an Excel file using DEX ExcelSheetMapping to a parameter named “Capacity”.

However, I cannot get that null (“0”) values are read into the parameter “Capacity”.

I have a constraint that imposes an upper limit over a variable named Stock, as follows:

Stock <= Capacity

I need to read null (“0”) values to impose that the variable Stock is null.

How can I do it?

Thank you

 

PS: I omit indexes for the sake of simplicity

icon

Best answer by luispinto 8 August 2023, 10:13

View original

2 replies

Userlevel 4
Badge +6

Hello Mateus,

 

AIMMS parameters have a default value in their attributes. If you have not changed this, then you capacity parameter should have a default that is empty, which means 0 for numerical identifiers such as parameters. In this case, when reading from you Excel file, no changes will be perceived in the parameter.

Now, to the second part, imposing that stock is 0.

You could simply have a constraint that does this, as per your suggestion. stock <= capacity would limit the variable to 0. 

Or, which is my suggestion, you could add a index domain to the variable and not even generate the variable. This can save processing time for matrix generation and solvers to eliminate unneeded variables.

Simple example:

Parameter p_capacity {
IndexDomain: t;
}


Variable v_stock {
IndexDomain: t | p_capacity(t) > 0;
Range: nonnegative;
}

I hope this helps.

Best regards

Userlevel 4
Badge +5

@rmateus 

When DEX reads a 0 in any supported file format into a numerical parameter that has a 0 default, then no value is stored by AIMMS. This makes a 0 encountered in a file read via DEX indistinguishable from an empty field. 

There are several ways around that:

  • Specify another default for the parameter. In this solution you may have to use the NonDefault function to prevent the non-0 default to be used when you don't want it.
  • Specify the force-dense attribute in the DEX mapping. The identifier you specify for this attribute will be set to 1 for any non-empty value encountered in a file read via DEX. You can then use this parameter to distinguish between a 0 value and an empty value.  When writing a file via DEX, 0 values will also be written back if the force-dense parameter holds a non-zero value.

Reply


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

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