-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reading a sparse set from a 2D table #7
Comments
There seems to be a difference between the .dat reader and the table handler reader. I was able to reproduce the issue with a relational table in amplxl, odbc and the .tab handler.
and the following to a .run script
the display in AMPL shows
|
Based on Nicolau's comment I looked at the escrow/acl/tables.c and it seems that in the Add_Rows function we are inserting the the keys before check the rest of values. |
After a while I'm revisiting my comment because it was not correct, on Nicolau's example it's not equivalent with Robert example, to be equivalent it should be like this:
And then running it will get this output (that somehow match Robert example):
It seems that if there isn't data in a cell we should not include it in a call to |
With this modification to initial Robert example we can see the equivalent "LINKS' table:
|
I'm still in doubt about my second comment, it seems that there is no way from the table handler to know if it's updating a |
Finally I could find a possible fix for this issue with this commit https://github.com/ampl/escrow/commit/f85bf5c67cedf8d39cbbce5fe10e33e16f354f0c, I was correct on my first comment but I didn't understood the code at that time to be able to move the insertion on the indexed set after checking for |
Can you test the fix with the following files?
tab_data.tab
example.run
expected output:
|
Good catch ! It now produces the expected output for both of Nicolau's examples, I could not reproduce Robert example because I could not create the xlsx file that could be accepted by the table handler definition. A peer review is welcome ! |
The behavior seems to be different for different dimensions, for example with the followinf script
reading the data
AMPL does not skip the missing values and displays
|
There is also a confuse or not clear way to explain this behavior where we have a set declared with
|
It seems that the rules for reading set and parameter values together from a
I believe that these rules were chosen to correspond to the cases that are most likely to be useful. It's possible to think up situations where the opposites of the above rules would be desirable, but they are less likely cases and can be handled in other ways. Given that these are indeed the rules for |
Use AMPL .dat format files, it is possible to read a subset of pairs and an associated parameter from the same table. For example, with
and data
neither the values marked
.
or the corresponding members of LINKS are included in the data that is read:Reading from spreadsheet data should work the same, with the role of
.
played by a blank cell. But currently the entire set{NUTR,FOOD}
is read rather than just the pairs corresponding to cells that are non-blank. In this example, readingwith table definition
gives the same values but the wrong LINKS set:
The text was updated successfully, but these errors were encountered: