Forum Discussion

FICO's avatar
FICO
Community Manager
2 years ago

hey hii i have to make a variable of type set nonfinal how can i do that i am using option noautofinal but that we make all the variables non final globally so is there any way just to make that parti

please answer as soon as possible as its urgent

1 Reply

  • FICO's avatar
    FICO
    Community Manager

    Based on the observation that many sets and array dimensions remain unchanged once they have been initialized, Mosel applies 'automatic finalization' to arrays declared of dense type (that is, without a 'dynamic' or 'hashmap' marker) and to sets that are not explicitly marked as 'dynamic', in order to turn them into static structures that are handled more efficiently.

    However, automatic finalization may not be desired in all cases, and there are various ways how to disable it.

    • General setting for the whole model (not recommended):
    model "my model name"
     options noautofinal
     ...
    • For an individual 'initializations from' block:
     declarations
        MYARRAY: array(R:range) of real     ! Dense array with variable index set
     end-declarations
     setparam("autofinal", false)           ! Disable automatic finalization
     initializations from "datafile.dat"
       MYARRAY
     end-initializations
     setparam("autofinal", true)            ! Re-enable automatic finalization
    • For individual arrays or sets:
     declarations
       S: dynamic set of integer
       A: dynamic array(R:range) of real
       B: hashmap array(R) of real
     end-declarations

    With earlier versions of Mosel, the explicit use of a 'dynamic' marker for arrays was not required, starting with version 5 of Mosel (Xpress Rel8.6, 2019) it is necessary to specify explicitly the 'dynamic' or 'hashmap' marker in order to make sure that an array is treated as a sparse array and as such not impacted by automatic finalization.