| |||||||||||||||
Conditional creation of decision variables Description If an array of decision variables of type mpvar is created as a dynamic array then its entries must be created explicitly using the subroutine create (doesx.mos). It is recommended to add an explicit 'exists' condition in loops over sparse arrays to improve the performance of the enumeration (doesx1.mos).
Through the automatic finalization mechanism or via an explicit call to finalize a dynamic set is turned into
a constant set, all subsequently declared arrays that are indexed by this set will be created as static arrays (doesx2.mos). Further explanation of this example: 'Mosel User Guide', Section 3.3 Conditional generation
Source Files By clicking on a file name, a preview is opened at the bottom of this page.
Data Files doesx2.mos (!****************************************************** Mosel User Guide Example Problems ================================= file doesx2.mos ``````````````` Using 'finalize' to turn a dynamic set into a constant set. (c) 2008 Fair Isaac Corporation author: Bob Daniel, 2001, rev. Sep. 2021 *******************************************************!) model doesx2 public declarations WHICH: set of integer Obj,C: linctr end-declarations initializations from 'doesx.dat' WHICH end-initializations public declarations x: array(WHICH) of mpvar ! Here the array is _not_ dynamic end-declarations ! because the set has been finalized Obj:= sum(i in WHICH) x(i) C:= sum(i in WHICH) i * x(i) >= 5 exportprob(0, "", Obj) ! Display the resulting problem definition in Mosel end-model | |||||||||||||||
© Copyright 2024 Fair Isaac Corporation. |