Skip to content
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

Generate correct dependencies for ALLOCATE AVAILABLE #135

Closed
ToddFincannon opened this issue Oct 12, 2021 · 1 comment · Fixed by #136 or #190
Closed

Generate correct dependencies for ALLOCATE AVAILABLE #135

ToddFincannon opened this issue Oct 12, 2021 · 1 comment · Fixed by #136 or #190
Assignees
Labels
Milestone

Comments

@ToddFincannon
Copy link
Collaborator

The ALLOCATE AVAILABLE function requires a special second argument that uses the first element of the priority profile to indicate the entire array. This special arrangement avoids giving the full dimension name in the argument, which would then require the dimension name to appear on the LHS. Like Vensim, SDEverywhere references all elements of the priority profile based on the first element. But this results in the first element alone being listed as a reference. For instance, the command:

sde generate --list models/allocate/allocate

includes this among the references for the shipments[region] variable:

_priority_vector[_region,_ptype]

The ptype and pextra elements are constants by convention and so are not needed in the references. However, the ppriority and pwidth elements are needed as references. This happens to not be an issue in our small test model, but puts dependencies out of order in a larger model.

@ToddFincannon ToddFincannon added this to the 0.6.0 milestone Oct 12, 2021
@ToddFincannon ToddFincannon self-assigned this Oct 12, 2021
@ToddFincannon
Copy link
Collaborator Author

We need to rewrite the references for an ALLOCATE AVAILABLE variable when they are generated in EquationReader. Drop the ptype reference, but use its subscript family to find the ppriority and pwidth index names. Splice them into the original reference to derive the correct references. The listing for allocate.mdl now contains these references:

_priority_vector[_region,_ppriority], _priority_vector[_region,_pwidth]

I also corrected a mistake in the _ALLOCATE_AVAILBLE C function. The initial x value in the search should be in the midpoint of the mean extremes, but the calculation of this was wrong.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment