$title 'Test implicit/explicit loading in Embedded Code (execution time)' (EMBPY13,SEQ=899) $onText This test ensures that ECImplicitLoad=on/off behaves correctly with Embedded Code Python at execution time Contributor: Michael Bussieck, March 2022 $offText $log --- Using Python library %sysEnv.GMSPYTHONLIB% set uni / i1*i4, j1*j3 /; set s1(*), s2(*); * Load sets implicitly EmbeddedCode Python: gams.set('s1', ['i1', 'i2', 'i3']) gams.set('s2', ['j1', 'j2', 'j3']) endEmbeddedCode EmbeddedCode Python: if list(gams.get('s1')) != ['i1', 'i2', 'i3']: raise Exception("Unexpected Data in symbol s1") if list(gams.get('s2')) != ['j1', 'j2', 'j3']: raise Exception("Unexpected Data in symbol s2") endEmbeddedCode * Load sets explicitly option clear=s1, clear=s2; EmbeddedCode Python: gams.set('s1', ['i1', 'i3']) gams.set('s2', ['j1', 'j3']) endEmbeddedCode s1 s2 EmbeddedCode Python: if list(gams.get('s1')) != ['i1', 'i3']: raise Exception("Unexpected Data in symbol s1") if list(gams.get('s2')) != ['j1', 'j3']: raise Exception("Unexpected Data in symbol s2") endEmbeddedCode * Mix implicit and explicit loading option clear=s1, clear=s2; EmbeddedCode Python: gams.set('s1', ['i1', 'i2', 'i3']) gams.set('s2', ['j1', 'j2', 'j3']) endEmbeddedCode s2 EmbeddedCode Python: if list(gams.get('s1')) != ['i1', 'i2', 'i3']: raise Exception("Unexpected Data in symbol s1") if list(gams.get('s2')) != ['j1', 'j2', 'j3']: raise Exception("Unexpected Data in symbol s2") endEmbeddedCode * Load parameter implicitly set i / i1*i3 /, j / j1*j3 /; parameter p1(i, j); EmbeddedCode Python: s1 = gams.get('i') s2 = gams.get('j') p1 = [(i, j, 3.14) for i,j in zip(s1, s2) ] gams.set('p1', p1) endEmbeddedCode EmbeddedCode Python: if list(gams.get('p1', keyFormat=KeyFormat.FLAT)) != p1: raise Exception("Unexpected Data in symbol p1") endEmbeddedCode * Generate a domain violation with implicit loading and DomainCheckType.CHECKED abort$(execerror) 'terminate with execution errors'; option clear=p1; EmbeddedCode Python: p1 = [('i4', 'j1', 3.14)] gams.set('p1', p1, domCheck=DomainCheckType.CHECKED) endEmbeddedCode abort$(execerror=0) 'expect execution errors'; execerror = 0; EmbeddedCode Python: if len(list(gams.get('p1'))): raise Exception("Unexpected Data in symbol p1") endEmbeddedCode * Generate a domain violation (unknow UEL) with implicit loading and DomainCheckType.CHECKED abort$(execerror) 'terminate with execution errors'; option clear=p1; EmbeddedCode Python: p1 = [('i5', 'j1', 3.14)] gams.set('p1', p1, domCheck=DomainCheckType.CHECKED) endEmbeddedCode abort$(execerror=0) 'expect execution errors'; execerror = 0; EmbeddedCode Python: if len(list(gams.get('p1'))): raise Exception("Unexpected Data in symbol p1") endEmbeddedCode * Filter a domain violation with implicit loading option clear=p1; EmbeddedCode Python: p1 = [('i4', 'j1', 3.14)] gams.set('p1', p1) endEmbeddedCode EmbeddedCode Python: if len(list(gams.get('p1'))): raise Exception("Unexpected Data in symbol p1") endEmbeddedCode * Generate an execution error by loading a parameter that has not been set parameter p4(i,j); abort$(execerror) 'terminate with execution errors'; EmbeddedCode Python: pass endEmbeddedCode p4 abort$(execerror=0) 'expect execution errors'; execerror = 0; option ECImplicitLoad=off; abort$(execerror) 'terminate with execution errors'; EmbeddedCode Python: s1 = gams.get('i') s2 = gams.get('j') p1 = [(i, j, 3.14) for i,j in zip(s1, s2) ] gams.set('p1', p1) endEmbeddedCode abort$(execerror=0) 'expect execution errors'; execerror = 0;