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

Wolfram SystemModeler compatibility #10

Open
tibordoma opened this issue Aug 23, 2015 · 13 comments
Open

Wolfram SystemModeler compatibility #10

tibordoma opened this issue Aug 23, 2015 · 13 comments

Comments

@tibordoma
Copy link

Your PNlib library is awesome but I miss Wolfram SystemModeler compatibility.

Do you think that it is possible to easily fix this library to work with Wolfram SystemModeler? Thank you very much!

Now I am receiving this error:
Building "PNlib.Examples.ConTest.Speed" as experiment "Speed 1" started at 14:29:23
Error: [:0:0-0:0]Error occurred while flattening model PNlib.Examples.ConTest.Speed
Error: [C:/Users/erikn_000/Documents/PNlib-1.1/PNlib/Blocks/enablingOutCon.mo:59:9-59:71]Failed to elaborate expression: enablingProb[remTAout[1:nremTAout]].
Warning: [:0:0-0:0]In component P2.enableOut, in relation arcWeightSum == 0.0, == on Real numbers is only allowed inside functions.
Warning: [:0:0-0:0]In component P2.enableIn, in relation arcWeight[i] == 0.0, == on Real numbers is only allowed inside functions.
Warning: [:0:0-0:0]In component P2.enableIn, in relation arcWeightSum == 0.0, == on Real numbers is only allowed inside functions.
Warning: [:0:0-0:0]In component P1.enableOut, in relation arcWeight[i] == 0.0, == on Real numbers is only allowed inside functions.
Warning: [:0:0-0:0]In component P1.enableOut, in relation arcWeightSum == 0.0, == on Real numbers is only allowed inside functions.
Warning: [:0:0-0:0]In component P1.enableIn, in relation arcWeight[i] == 0.0, == on Real numbers is only allowed inside functions.
Warning: [:0:0-0:0]In component P1.enableIn, in relation arcWeightSum == 0.0, == on Real numbers is only allowed inside functions.
Error: No executable generated C:/Users/ERIKN_~1/AppData/Local/Temp/sme.4.0.1_1440332963_41.exe
Error: No settings file generated C:/Users/ERIKN_~1/AppData/Local/Temp/sme.4.0.1_1440332963_41_init.sim

@tibordoma
Copy link
Author

I tried to use the most recent version (not 1.1) and now I am receiving error:
Error: [:0:0-0:0]Error occurred while flattening model PNlib.Examples.ConTest.Speed
Error: [C:/Users/erikn_000/Documents/PNlib-master/PNlib/Blocks/enablingOutCon.mo:60:9-60:71]Failed to elaborate expression: enablingProb[remTAout[1:nremTAout]].

@lochel
Copy link
Collaborator

lochel commented Oct 8, 2015

I added a branch called "SystemModeler" that doesn't contain the critical expressions which causes the flattening issue. However, I have no SystemModeler license and cannot test the changes.

@tibordoma
Copy link
Author

Thank you for adding this branch. I tried it in Wolfram System Modeler version 4.0.1

I tried SingleTD example - everything is OK.

I tried SinglePD example and there is an error:


Building "PNlib.Examples.DisTest.SinglePD" as experiment "SinglePD 1" started at 17:39:17
Error: [:0:0-0:0]Error building simulator. Build log:
Setting environment for using Microsoft Visual Studio 2010 x86 tools.

Microsoft (R) Program Maintenance Utility Version 10.00.30319.01
Copyright (C) Microsoft Corporation. All rights reserved.

"cl" /MT /EHsc /I"." /I"C:\Program Files (x86)\Wolfram Research\SystemModeler 4.0.1\bin..\include" /I"C:\Program Files (x86)\Wolfram Research\SystemModeler 4.0.1\bin..\include\platform\win32\VS2010" /I"E:/Archiv E/FEI/11 semester/DIZERT/editory PN/open modelica/PNlib-SystemModeler/PNlib/Examples/DisTest" sme.4.0.1_1452098357_27664.cpp /link /LIBPATH:"." /LIBPATH:"C:\Program Files (x86)\Wolfram Research\SystemModeler 4.0.1\bin..\lib\win32\VS2010" /LIBPATH:"E:\Archiv E\FEI\11 semester\DIZERT\editory PN\open modelica\PNlib-SystemModeler\PNlib\Examples\DisTest" sim.lib c_runtime.lib mmcom.lib lapack.lib superlu_4.3.lib blas.lib f2c.lib c_common.lib expat.lib sundials_cvodes.lib sundials_kinsol.lib sundials_nvecserial.lib winmm.lib wsock32.lib user32.lib /OUT:"sme.4.0.1_1452098357_27664.exe"
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 16.00.40219.01 for 80x86
Copyright (C) Microsoft Corporation. All rights reserved.

sme.4.0.1_1452098357_27664.cpp
sme.4.0.1_1452098357_27664.cpp(914) : error C2065: '$$P1$_enableOut$_cumEnablingProb$B1$b' : undeclared identifier
sme.4.0.1_1452098357_27664.cpp(923) : error C2065: '$$P1$_enableOut$_cumEnablingProb' : undeclared identifier
sme.4.0.1_1452098357_27664.cpp(956) : error C2065: '$$P1$_enableOut$_TEout' : undeclared identifier
sme.4.0.1_1452098357_27664.cpp(980) : error C2065: '$$P1$_enableOut$_cumEnablingProb$B1$b' : undeclared identifier
sme.4.0.1_1452098357_27664.cpp(989) : error C2065: '$$P1$_enableOut$_cumEnablingProb' : undeclared identifier
sme.4.0.1_1452098357_27664.cpp(999) : error C2065: '$$P1$_enableOut$_cumEnablingProb' : undeclared identifier
sme.4.0.1_1452098357_27664.cpp(1114) : error C2065: '$$P1$_enableIn$_cumEnablingProb$B1$b' : undeclared identifier
sme.4.0.1_1452098357_27664.cpp(1123) : error C2065: '$$P1$_enableIn$_cumEnablingProb' : undeclared identifier
sme.4.0.1_1452098357_27664.cpp(1156) : error C2065: '$$P1$_enableIn$_TEin' : undeclared identifier
sme.4.0.1_1452098357_27664.cpp(1180) : error C2065: '$$P1$_enableIn$_cumEnablingProb$B1$b' : undeclared identifier
sme.4.0.1_1452098357_27664.cpp(1189) : error C2065: '$$P1$_enableIn$_cumEnablingProb' : undeclared identifier
sme.4.0.1_1452098357_27664.cpp(1199) : error C2065: '$$P1$_enableIn$_cumEnablingProb' : undeclared identifier
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\BIN\cl.EXE"' : return code '0x2'
Stop.

Error: No executable generated C:/Users/Erik/AppData/Local/Temp/sme.4.0.1_1452098357_27664.exe

SingleTC example:


Building "PNlib.Examples.ConTest.SingleTC" as experiment "SingleTC 1" started at 17:45:14
Error: [:0:0-0:0]Error building simulator. Build log:
Setting environment for using Microsoft Visual Studio 2010 x86 tools.

Microsoft (R) Program Maintenance Utility Version 10.00.30319.01
Copyright (C) Microsoft Corporation. All rights reserved.

"cl" /MT /EHsc /I"." /I"C:\Program Files (x86)\Wolfram Research\SystemModeler 4.0.1\bin..\include" /I"C:\Program Files (x86)\Wolfram Research\SystemModeler 4.0.1\bin..\include\platform\win32\VS2010" /I"E:/Archiv E/FEI/11 semester/DIZERT/editory PN/open modelica/PNlib-SystemModeler/PNlib/Examples/ConTest" sme.4.0.1_1452098714_16021.cpp /link /LIBPATH:"." /LIBPATH:"C:\Program Files (x86)\Wolfram Research\SystemModeler 4.0.1\bin..\lib\win32\VS2010" /LIBPATH:"E:\Archiv E\FEI\11 semester\DIZERT\editory PN\open modelica\PNlib-SystemModeler\PNlib\Examples\ConTest" sim.lib c_runtime.lib mmcom.lib lapack.lib superlu_4.3.lib blas.lib f2c.lib c_common.lib expat.lib sundials_cvodes.lib sundials_kinsol.lib sundials_nvecserial.lib winmm.lib wsock32.lib user32.lib /OUT:"sme.4.0.1_1452098714_16021.exe"
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 16.00.40219.01 for 80x86
Copyright (C) Microsoft Corporation. All rights reserved.

sme.4.0.1_1452098714_16021.cpp
sme.4.0.1_1452098714_16021.cpp(916) : error C2675: unary '!' : 'boolean_array' does not define this operator or a conversion to a type acceptable to the predefined operator
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\BIN\cl.EXE"' : return code '0x2'
Stop.

Error: No executable generated C:/Users/Erik/AppData/Local/Temp/sme.4.0.1_1452098714_16021.exe

I tried it in Wolfram System Modeler 4.2.

Single TD is OK but SinglePD example is not:


Building "PNlib.Examples.DisTest.SinglePD" as experiment "SinglePD 1" started at 17:47:53
Error: [:0:0-0:0]Error: Error building simulator. Build log:

Microsoft (R) Program Maintenance Utility Version 14.00.23026.0
Copyright (C) Microsoft Corporation. All rights reserved.

"cl" /MT /EHa /c /I"C:\Program Files\Wolfram Research\SystemModeler 4.2\include" /I"C:\Program Files\Wolfram Research\SystemModeler 4.2\include\platform\win32\VS2015" /I"C:\Program Files\Wolfram Research\SystemModeler 4.2\include\fmil" /I"E:\Archiv E\FEI\11 semester\DIZERT\editory PN\open modelica\PNlib-SystemModeler\PNlib\Examples\DisTest" sme.4.2.0_1452098873_26500_main.cpp /Fo"sme.4.2.0_1452098873_26500_main.obj"
Microsoft (R) C/C++ Optimizing Compiler Version 19.00.23026 for x86
Copyright (C) Microsoft Corporation. All rights reserved.

sme.4.2.0_1452098873_26500_main.cpp
"cl" /MT /EHa /c /I"C:\Program Files\Wolfram Research\SystemModeler 4.2\include" /I"C:\Program Files\Wolfram Research\SystemModeler 4.2\include\platform\win32\VS2015" /I"C:\Program Files\Wolfram Research\SystemModeler 4.2\include\fmil" /I"E:\Archiv E\FEI\11 semester\DIZERT\editory PN\open modelica\PNlib-SystemModeler\PNlib\Examples\DisTest" sme.4.2.0_1452098873_26500_functions.cpp /Fo"sme.4.2.0_1452098873_26500_functions.obj"
Microsoft (R) C/C++ Optimizing Compiler Version 19.00.23026 for x86
Copyright (C) Microsoft Corporation. All rights reserved.

sme.4.2.0_1452098873_26500_functions.cpp
"cl" /MT /EHa /c /I"C:\Program Files\Wolfram Research\SystemModeler 4.2\include" /I"C:\Program Files\Wolfram Research\SystemModeler 4.2\include\platform\win32\VS2015" /I"C:\Program Files\Wolfram Research\SystemModeler 4.2\include\fmil" /I"E:\Archiv E\FEI\11 semester\DIZERT\editory PN\open modelica\PNlib-SystemModeler\PNlib\Examples\DisTest" sme.4.2.0_1452098873_26500_init.cpp /Fo"sme.4.2.0_1452098873_26500_init.obj"
Microsoft (R) C/C++ Optimizing Compiler Version 19.00.23026 for x86
Copyright (C) Microsoft Corporation. All rights reserved.

sme.4.2.0_1452098873_26500_init.cpp
"cl" /MT /EHa /c /I"C:\Program Files\Wolfram Research\SystemModeler 4.2\include" /I"C:\Program Files\Wolfram Research\SystemModeler 4.2\include\platform\win32\VS2015" /I"C:\Program Files\Wolfram Research\SystemModeler 4.2\include\fmil" /I"E:\Archiv E\FEI\11 semester\DIZERT\editory PN\open modelica\PNlib-SystemModeler\PNlib\Examples\DisTest" sme.4.2.0_1452098873_26500_ode.cpp /Fo"sme.4.2.0_1452098873_26500_ode.obj"
Microsoft (R) C/C++ Optimizing Compiler Version 19.00.23026 for x86
Copyright (C) Microsoft Corporation. All rights reserved.

sme.4.2.0_1452098873_26500_ode.cpp
sme.4.2.0_1452098873_26500_ode.cpp(148): error C2466: cannot allocate an array of constant size 0
sme.4.2.0_1452098873_26500_ode.cpp(152): error C2466: cannot allocate an array of constant size 0
sme.4.2.0_1452098873_26500_ode.cpp(156): warning C4838: conversion from 'int' to 'size_t' requires a narrowing conversion
sme.4.2.0_1452098873_26500_ode.cpp(160): warning C4838: conversion from 'int' to 'size_t' requires a narrowing conversion
sme.4.2.0_1452098873_26500_ode.cpp(168): error C2466: cannot allocate an array of constant size 0
sme.4.2.0_1452098873_26500_ode.cpp(173): error C2466: cannot allocate an array of constant size 0
sme.4.2.0_1452098873_26500_ode.cpp(179): warning C4838: conversion from 'int' to 'size_t' requires a narrowing conversion
sme.4.2.0_1452098873_26500_ode.cpp(182): error C2065: '$$P1$_enableOut$_cumEnablingProb$B1$b': undeclared identifier
sme.4.2.0_1452098873_26500_ode.cpp(189): error C2466: cannot allocate an array of constant size 0
sme.4.2.0_1452098873_26500_ode.cpp(193): warning C4838: conversion from 'int' to 'size_t' requires a narrowing conversion
sme.4.2.0_1452098873_26500_ode.cpp(197): error C2466: cannot allocate an array of constant size 0
sme.4.2.0_1452098873_26500_ode.cpp(201): error C2466: cannot allocate an array of constant size 0
sme.4.2.0_1452098873_26500_ode.cpp(205): warning C4838: conversion from 'int' to 'size_t' requires a narrowing conversion
sme.4.2.0_1452098873_26500_ode.cpp(209): warning C4838: conversion from 'int' to 'size_t' requires a narrowing conversion
sme.4.2.0_1452098873_26500_ode.cpp(212): error C2065: '$$P1$_enableOut$_cumEnablingProb': undeclared identifier
sme.4.2.0_1452098873_26500_ode.cpp(231): error C2466: cannot allocate an array of constant size 0
sme.4.2.0_1452098873_26500_ode.cpp(235): warning C4838: conversion from 'int' to 'size_t' requires a narrowing conversion
sme.4.2.0_1452098873_26500_ode.cpp(241): error C2466: cannot allocate an array of constant size 0
sme.4.2.0_1452098873_26500_ode.cpp(245): warning C4838: conversion from 'int' to 'size_t' requires a narrowing conversion
sme.4.2.0_1452098873_26500_ode.cpp(255): error C2466: cannot allocate an array of constant size 0
sme.4.2.0_1452098873_26500_ode.cpp(259): warning C4838: conversion from 'int' to 'size_t' requires a narrowing conversion
sme.4.2.0_1452098873_26500_ode.cpp(265): error C2466: cannot allocate an array of constant size 0
sme.4.2.0_1452098873_26500_ode.cpp(269): warning C4838: conversion from 'int' to 'size_t' requires a narrowing conversion
sme.4.2.0_1452098873_26500_ode.cpp(273): error C2065: '$$P1$_enableOut$_TEout': undeclared identifier
sme.4.2.0_1452098873_26500_ode.cpp(285): error C2466: cannot allocate an array of constant size 0
sme.4.2.0_1452098873_26500_ode.cpp(289): error C2466: cannot allocate an array of constant size 0
sme.4.2.0_1452098873_26500_ode.cpp(293): warning C4838: conversion from 'int' to 'size_t' requires a narrowing conversion
sme.4.2.0_1452098873_26500_ode.cpp(297): warning C4838: conversion from 'int' to 'size_t' requires a narrowing conversion
sme.4.2.0_1452098873_26500_ode.cpp(307): error C2466: cannot allocate an array of constant size 0
sme.4.2.0_1452098873_26500_ode.cpp(312): error C2466: cannot allocate an array of constant size 0
sme.4.2.0_1452098873_26500_ode.cpp(318): warning C4838: conversion from 'int' to 'size_t' requires a narrowing conversion
sme.4.2.0_1452098873_26500_ode.cpp(321): error C2065: '$$P1$_enableOut$_cumEnablingProb$B1$b': undeclared identifier
sme.4.2.0_1452098873_26500_ode.cpp(328): error C2466: cannot allocate an array of constant size 0
sme.4.2.0_1452098873_26500_ode.cpp(332): warning C4838: conversion from 'int' to 'size_t' requires a narrowing conversion
sme.4.2.0_1452098873_26500_ode.cpp(336): error C2466: cannot allocate an array of constant size 0
sme.4.2.0_1452098873_26500_ode.cpp(340): error C2466: cannot allocate an array of constant size 0
sme.4.2.0_1452098873_26500_ode.cpp(344): warning C4838: conversion from 'int' to 'size_t' requires a narrowing conversion
sme.4.2.0_1452098873_26500_ode.cpp(348): warning C4838: conversion from 'int' to 'size_t' requires a narrowing conversion
sme.4.2.0_1452098873_26500_ode.cpp(351): error C2065: '$$P1$_enableOut$_cumEnablingProb': undeclared identifier
sme.4.2.0_1452098873_26500_ode.cpp(357): warning C4838: conversion from 'scalar_value' to 'size_t' requires a narrowing conversion
sme.4.2.0_1452098873_26500_ode.cpp(364): warning C4838: conversion from 'modelica_integer' to 'const size_t' requires a narrowing conversion
sme.4.2.0_1452098873_26500_ode.cpp(371): error C2065: '$$P1$_enableOut$_cumEnablingProb': undeclared identifier
sme.4.2.0_1452098873_26500_ode.cpp(495): error C2466: cannot allocate an array of constant size 0
sme.4.2.0_1452098873_26500_ode.cpp(499): error C2466: cannot allocate an array of constant size 0
sme.4.2.0_1452098873_26500_ode.cpp(503): warning C4838: conversion from 'int' to 'size_t' requires a narrowing conversion
sme.4.2.0_1452098873_26500_ode.cpp(507): warning C4838: conversion from 'int' to 'size_t' requires a narrowing conversion
sme.4.2.0_1452098873_26500_ode.cpp(515): error C2466: cannot allocate an array of constant size 0
sme.4.2.0_1452098873_26500_ode.cpp(520): error C2466: cannot allocate an array of constant size 0
sme.4.2.0_1452098873_26500_ode.cpp(526): warning C4838: conversion from 'int' to 'size_t' requires a narrowing conversion
sme.4.2.0_1452098873_26500_ode.cpp(529): error C2065: '$$P1$_enableIn$_cumEnablingProb$B1$b': undeclared identifier
sme.4.2.0_1452098873_26500_ode.cpp(536): error C2466: cannot allocate an array of constant size 0
sme.4.2.0_1452098873_26500_ode.cpp(540): warning C4838: conversion from 'int' to 'size_t' requires a narrowing conversion
sme.4.2.0_1452098873_26500_ode.cpp(544): error C2466: cannot allocate an array of constant size 0
sme.4.2.0_1452098873_26500_ode.cpp(548): error C2466: cannot allocate an array of constant size 0
sme.4.2.0_1452098873_26500_ode.cpp(552): warning C4838: conversion from 'int' to 'size_t' requires a narrowing conversion
sme.4.2.0_1452098873_26500_ode.cpp(556): warning C4838: conversion from 'int' to 'size_t' requires a narrowing conversion
sme.4.2.0_1452098873_26500_ode.cpp(559): error C2065: '$$P1$_enableIn$_cumEnablingProb': undeclared identifier
sme.4.2.0_1452098873_26500_ode.cpp(578): error C2466: cannot allocate an array of constant size 0
sme.4.2.0_1452098873_26500_ode.cpp(582): warning C4838: conversion from 'int' to 'size_t' requires a narrowing conversion
sme.4.2.0_1452098873_26500_ode.cpp(588): error C2466: cannot allocate an array of constant size 0
sme.4.2.0_1452098873_26500_ode.cpp(592): warning C4838: conversion from 'int' to 'size_t' requires a narrowing conversion
sme.4.2.0_1452098873_26500_ode.cpp(602): error C2466: cannot allocate an array of constant size 0
sme.4.2.0_1452098873_26500_ode.cpp(606): warning C4838: conversion from 'int' to 'size_t' requires a narrowing conversion
sme.4.2.0_1452098873_26500_ode.cpp(612): error C2466: cannot allocate an array of constant size 0
sme.4.2.0_1452098873_26500_ode.cpp(616): warning C4838: conversion from 'int' to 'size_t' requires a narrowing conversion
sme.4.2.0_1452098873_26500_ode.cpp(620): error C2065: '$$P1$_enableIn$_TEin': undeclared identifier
sme.4.2.0_1452098873_26500_ode.cpp(632): error C2466: cannot allocate an array of constant size 0
sme.4.2.0_1452098873_26500_ode.cpp(636): error C2466: cannot allocate an array of constant size 0
sme.4.2.0_1452098873_26500_ode.cpp(640): warning C4838: conversion from 'int' to 'size_t' requires a narrowing conversion
sme.4.2.0_1452098873_26500_ode.cpp(644): warning C4838: conversion from 'int' to 'size_t' requires a narrowing conversion
sme.4.2.0_1452098873_26500_ode.cpp(654): error C2466: cannot allocate an array of constant size 0
sme.4.2.0_1452098873_26500_ode.cpp(659): error C2466: cannot allocate an array of constant size 0
sme.4.2.0_1452098873_26500_ode.cpp(665): warning C4838: conversion from 'int' to 'size_t' requires a narrowing conversion
sme.4.2.0_1452098873_26500_ode.cpp(668): error C2065: '$$P1$_enableIn$_cumEnablingProb$B1$b': undeclared identifier
sme.4.2.0_1452098873_26500_ode.cpp(675): error C2466: cannot allocate an array of constant size 0
sme.4.2.0_1452098873_26500_ode.cpp(679): warning C4838: conversion from 'int' to 'size_t' requires a narrowing conversion
sme.4.2.0_1452098873_26500_ode.cpp(683): error C2466: cannot allocate an array of constant size 0
sme.4.2.0_1452098873_26500_ode.cpp(687): error C2466: cannot allocate an array of constant size 0
sme.4.2.0_1452098873_26500_ode.cpp(691): warning C4838: conversion from 'int' to 'size_t' requires a narrowing conversion
sme.4.2.0_1452098873_26500_ode.cpp(695): warning C4838: conversion from 'int' to 'size_t' requires a narrowing conversion
sme.4.2.0_1452098873_26500_ode.cpp(698): error C2065: '$$P1$_enableIn$_cumEnablingProb': undeclared identifier
sme.4.2.0_1452098873_26500_ode.cpp(704): warning C4838: conversion from 'scalar_value' to 'size_t' requires a narrowing conversion
sme.4.2.0_1452098873_26500_ode.cpp(711): warning C4838: conversion from 'modelica_integer' to 'const size_t' requires a narrowing conversion
sme.4.2.0_1452098873_26500_ode.cpp(718): error C2065: '$$P1$_enableIn$_cumEnablingProb': undeclared identifier
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\cl.EXE"' : return code '0x2'
Stop.

Internal error: [:0:0-0:0]Internal error: Failed to build model PNlib.Examples.DisTest.SinglePD.
Error: No executable generated C:/Users/Erik/AppData/Local/Temp/sme.4.2.0_1452098873_26500.exe

Do you have any idea how to fix it? Thank you very much for your help!

@tibordoma
Copy link
Author

I have an answer from official System Modeler forum:
"
Is this the problem that you still see?


sme.4.1.0_1441279965_15636.cpp(661) : error C2675: unary '!' : 'boolean_array' does not define this operator or a conversion to a type acceptable to the predefined operator
sme.4.1.0_1441279965_15636.cpp(724) : error C2675: unary '!' : 'boolean_array' does not define this operator or a conversion to a type acceptable to the predefined operator

If soo, I guess it's the code generation that has problem with an applying not to an array of booleans, you could try to replace it with the following Modelica function to avoid the problem.


function arrayNot
input Boolean b[:];
output Boolean res[size(b, 1)];
algorithm
for i in 1:size(b,1) loop
res[i] := not b[i];
end for;

end arrayNot;


"

@lochel
Copy link
Collaborator

lochel commented Jan 14, 2016

It seems that there are multiple issues with Wolfram SystemModeler. This is what I guess from the error messages above:

  • Empty array slices cannot be handled
  • Unary not operator cannot be handled for Boolean arrays
  • There are undeclared identifiers in the C++ code

The first two issues can be fixed easily with workarounds in the library. However, I cannot do it efficiently without Wolfram SystemModeler license.
I am not sure, but maybe the third issue will just disappear once the other problems are fixed.

@xcesek
Copy link

xcesek commented Feb 13, 2016

Hi,
@lochel, thank you for your ideas.
You were right about Boolean arrays - systemmodeler cannot handle operators 'not', 'and' and 'or' for boolean arrays. Solution is quite simple, you just have to substitute all occurrence of mentioned operators with functions, e.g:
replace:
disTAout:=TAout and disTransition;
with:
disTAout := Functions.ArrayUtils.arrayAnd(TAout, disTransition);

Here are my implemented functions:

within PNlib.Functions.ArrayUtils;
function arrayAnd "n-ary boolean AND"
  input Boolean b1[:];
  input Boolean b2[:];
  output Boolean res[size(b1, 1)];
algorithm
  for i in 1:size(b1, 1) loop
    res[i] := b1[i] and b2[i];
  end for;
  annotation(Diagram(coordinateSystem(extent = {{-148.5, -105}, {148.5, 105}}, preserveAspectRatio = true, initialScale = 0.1, grid = {5, 5})));
end arrayAnd;
within PNlib.Functions.ArrayUtils;
function arrayNot "n-ary boolean NOT"
  input Boolean b[:];
  output Boolean res[size(b, 1)];
algorithm
  for i in 1:size(b, 1) loop
    res[i] := not b[i];
  end for;
  annotation(Diagram(coordinateSystem(extent = {{-148.5, -105}, {148.5, 105}}, preserveAspectRatio = true, initialScale = 0.1, grid = {5, 5})));
end arrayNot;
within PNlib.Functions.ArrayUtils;
function arrayOr "n-ary boolean OR"
  input Boolean b1[:];
  input Boolean b2[:];
  output Boolean res[size(b1, 1)];
algorithm
  for i in 1:size(b1, 1) loop
    res[i] := b1[i] or b2[i];
  end for;
  annotation(Diagram(coordinateSystem(extent = {{-148.5, -105}, {148.5, 105}}, preserveAspectRatio = true, initialScale = 0.1, grid = {5, 5})));
end arrayOr;

@lochel
Copy link
Collaborator

lochel commented Feb 13, 2016

@xcesek Thanks for your input. I will consider your changes and update the SystemModeler branch soon.

@lochel
Copy link
Collaborator

lochel commented Feb 15, 2016

The logical array operations are now working due to the workaround from @xcesek. However, there are two blockers left:

  • Wrong generated C++ code (e.g. undeclared identifiers)
  • Zero-size arrays aren’t handled properly. This is crucial for places/transitions that are used as sources/sinks.

@johanrhodin
Copy link

@lochel Feel free to submit a bug report with the two blocking issues to Wolfram.

@lochel
Copy link
Collaborator

lochel commented Feb 19, 2016

@johanrhodin What is the place for SystemModeler bug reports?

@johanrhodin
Copy link

[email protected], feel free to cc me.

@lochel
Copy link
Collaborator

lochel commented Nov 15, 2016

As far as I know, the new version of SystemModeler contains some significant front end improvements. Hence, it should be worth it to test the library once more.

@johanrhodin
Copy link

Sounds like a great idea, @modlfo should be able to help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants