Changeset 13800 for branches/dev-5819
- Timestamp:
- Oct 22, 2019 11:31:16 AM (7 weeks ago)
- Location:
- branches/dev-5819
- Files:
-
- 69 edited
- 12 copied
Legend:
- Unmodified
- Added
- Removed
-
branches/dev-5819
- Property svn:mergeinfo changed
-
branches/dev-5819/CHANGELOG.txt
r13651 r13800 1 1 ================= Unreleased ================== 2 # Feature ; Minor ; Compiler; #5837 3 Added a pre-compiled evaluator used for evaluating external functions 4 during the compilation (for performance). Activated by the option 5 "external_constant_evaluation_dynamic" 6 7 # Fixed ; Minor ; Compiler ; #5855 8 Nominal are now always positive in the FMI model description. 9 2 10 # Fixed ; Minor ; Compiler; #5844 3 11 Improved attribute evaluation robustness for some cases. Parametric -
branches/dev-5819/Compiler/FmiXMLCodeGen/test/modelica/FmiXMLTests.mo
r13651 r13800 2543 2543 end ParametricAttributes1; 2544 2544 2545 2546 model NegativeNominal1 2547 Real x1(nominal=-1); // Negative integer nominal 2548 Real x2(nominal=-1.0); // Negative real nominal 2549 equation 2550 x1 = time; 2551 x2 = time; 2552 annotation(__JModelica(UnitTesting(tests={ 2553 FmiXMLCodeGenTestCase( 2554 description="Nominals are always non-negative in FMI", 2555 fmi_version="2.0", 2556 template=" 2557 $modelVariables$ 2558 ", generatedCode=" 2559 <ModelVariables> 2560 <!-- Variable with index #1 --> 2561 <ScalarVariable name=\"x1\" valueReference=\"0\" causality=\"local\" variability=\"continuous\" initial=\"calculated\"> 2562 <Real relativeQuantity=\"false\" nominal=\"1\" /> 2563 </ScalarVariable> 2564 <!-- Variable with index #2 --> 2565 <ScalarVariable name=\"x2\" valueReference=\"0\" causality=\"local\" variability=\"continuous\" initial=\"calculated\"> 2566 <Real relativeQuantity=\"false\" nominal=\"1.0\" /> 2567 </ScalarVariable> 2568 </ModelVariables> 2569 ")}))); 2570 end NegativeNominal1; 2571 2545 2572 end FmiXMLTests; -
branches/dev-5819/Compiler/GenericCodeGen/src/jastadd/GenericXMLGenerator.jrag
r13651 r13800 217 217 variable.isInput() || variable.isDifferentiatedVariable()) { 218 218 try { 219 String value = attributeExp.ceval().xmlValue(); 219 CValue cvalue = attributeExp.ceval(); 220 if (name.equals("nominal")) { 221 cvalue = cvalue.absoluteValue(); 222 } 223 String value = cvalue.xmlValue(); 220 224 generateAttribute(name, value, printer); 221 225 } catch (ConstantEvaluationException e) { -
branches/dev-5819/Compiler/ModelicaCBackEnd/src/jastadd/CCodeGen/CCodeGenExpressions.jrag
r13600 r13800 1353 1353 } 1354 1354 1355 /** 1356 * Generate the initialization of delay blocks. 1357 */ 1358 public void FDelayExp.genInit_C(CodePrinter p, CodeStream str, String indent) { 1359 FExp maxDelayExp = myMaxDelayExp(); 1355 private void FClass.genDelayInitVarDecls_C(CodePrinter p, CodeStream str, String indent) { // Hook to facilitate extensions 1356 for (FDelayExp d : myDelayExps()) { 1357 d.genInitVarDecls_C(p, str, indent); 1358 } 1359 for (FSpatialDistExp d : mySpatialDistExps()) { 1360 d.genInitVarDecls_C(p, str, indent); 1361 } 1362 } 1363 1364 private void FClass.genDelayInitAssignments_C(CodePrinter p, CodeStream str, String indent) { // Hook to facilitate extensions 1365 for (FDelayExp d : myDelayExps()) { 1366 d.genInit_C(p, str, indent); 1367 } 1368 for (FSpatialDistExp d : mySpatialDistExps()) { 1369 d.genInit_C(p, str, indent); 1370 } 1371 } 1372 1373 public void FClass.genDelayInit_C(CodeStream genPrinter) { 1374 CodePrinter p = ASTNode.printer_C; 1375 String indent = p.indent(""); 1376 genDelayInitVarDecls_C(p, genPrinter, indent); 1377 genDelayInitAssignments_C(p, genPrinter, indent); 1378 } 1379 1380 private void FDelayExp.prepareInit_C(CodePrinter p, CodeStream str, String indent, int delayIndex) { 1381 FExp maxDelayExp = myMaxDelayExp(); 1360 1382 boolean fixed = isTimeEventGenerating(); 1361 1383 p.printPreSteps(getFExp(), str, indent); 1362 1384 p.printPreSteps(maxDelayExp, str, indent); 1363 1364 str.format("%sjmi_delay_init(jmi, %d, ", indent, myDelayIndex()); 1385 str.format("%sjmi_delay_init(jmi, %d, ", indent, delayIndex); 1365 1386 str.print(boolValue_C(fixed)); // jmi_boolean fixed 1366 1387 str.print(", "); … … 1368 1389 str.print(", "); 1369 1390 p.print(fixed ? getDelay() : maxDelayExp, str, indent); // jmi_real_t max_delay 1370 str.print(", "); 1371 p.print(getFExp(), str, indent); // jmi_real_t y0 1372 str.println(");"); 1373 1391 str.print(", "); 1392 1393 } 1394 1395 private void FDelayExp.finalizeInit_C(CodePrinter p, CodeStream str, String indent) { 1396 str.println(");"); 1374 1397 p.printPostSteps(getFExp(), str, indent); 1375 p.printPostSteps(maxDelayExp, str, indent); 1398 p.printPostSteps(myMaxDelayExp(), str, indent); 1399 } 1400 1401 /** 1402 * Generate the initialization of delay blocks. 1403 */ 1404 public void FDelayExp.genInit_C(CodePrinter p, CodeStream str, String indent) { 1405 prepareInit_C(p, str, indent, myDelayIndex()); 1406 p.print(getFExp(), str, indent); // jmi_real_t y0 1407 finalizeInit_C(p, str, indent); 1376 1408 } 1377 1409 syn FExp FDelayExp.myMaxDelayExp() = hasMax() ? getMax() : getDelay(); -
branches/dev-5819/Compiler/ModelicaCBackEnd/src/jastadd/CCodeGen/CCodeGenExternalCeval.jrag
r12306 r13800 248 248 Collection<ExternalArgument> res = new LinkedHashSet<>(); 249 249 if (hasReturnVar()) { 250 res.add(getReturnVar().externalArgument()); 251 } 250 res.add(returnVarToSerialize()); 251 } 252 res.addAll(argVarsToSerialize()); 253 return res; 254 } 255 256 syn ExternalArgument FExternalStmt.returnVarToSerialize() = getReturnVar().externalArgument(); 257 syn Collection<ExternalArgument> FExternalStmt.argVarsToSerialize() { 258 Collection<ExternalArgument> res = new LinkedHashSet<>(); 252 259 for (FExp e : getArgs()) { 253 260 res.add(e.externalArgument()); … … 288 295 } 289 296 return functionArgs; 297 } 298 299 300 syn String FType.cMappedTypeString() = cMappedTypeStringScalar() + (isArray() ? "v" : ""); 301 302 syn String FType.cMappedTypeStringScalar() { 303 throw new InternalCompilerError("cMappedTypeStringScalar() is not supported for class type " + getClass().getSimpleName()); 304 } 305 eq FArrayType.cMappedTypeStringScalar() = getFPrimitiveType().cMappedTypeStringScalar(); 306 eq FIntegerType.cMappedTypeStringScalar() = "i"; 307 eq FEnumType.cMappedTypeStringScalar() = "i"; 308 eq FBooleanType.cMappedTypeStringScalar() = "i"; 309 eq FRealType.cMappedTypeStringScalar() = "d"; 310 eq FStringType.cMappedTypeStringScalar() = "s"; 311 eq FRecordType.cMappedTypeStringScalar() { 312 String o = "R["; 313 for (FRecordComponentType rType: getComponents()) { 314 o = o.concat(rType.getFType().cMappedTypeStringScalar()); 315 o = o.concat(","); 316 } 317 return o.concat("]"); 318 } 319 320 syn String FExternalStmt.functionReturnArgSerialized() { 321 if (hasReturnVar()) { 322 return returnVarToSerialize().type().cMappedTypeString(); 323 } else { 324 return "void"; 325 } 326 } 327 328 syn String FExternalStmt.functionArgsSerialized() { 329 String input = ""; 330 for (ExternalArgument var : argVarsToSerialize()) { 331 if (var.isOutput()) { 332 input = input.concat("*"); 333 } 334 input += var.type().cMappedTypeString() + ","; 335 } 336 return input; 290 337 } 291 338 … … 347 394 } 348 395 } 396 } 397 398 public String FClass.externalCTypes() { 399 StringBuilder sb = new StringBuilder(); 400 for (FExternalStmt stmt : myExternals()) { 401 if (stmt.dynamicEvaluatorEnabled()) { 402 sb.append(stmt.getName()); 403 sb.append("\n"); 404 sb.append(stmt.functionReturnArgSerialized()); 405 sb.append("\n"); 406 sb.append(stmt.functionArgsSerialized()); 407 sb.append("\n"); 408 } 409 } 410 return sb.toString(); 349 411 } 350 412 -
branches/dev-5819/Compiler/ModelicaCBackEnd/src/jastadd/CCodeGen/CGenerator.jrag
r12423 r13800 21 21 22 22 import java.io.*; 23 24 aspect CGenerator { 23 25 24 26 public class CGenerator extends GenericGenerator { … … 1246 1248 1247 1249 public void generate(CodeStream genPrinter) { 1248 genPrinter.print(fclass.myDelayExps().size());1250 genPrinter.print(fclass.numberOfDelaysInCCode()); 1249 1251 } 1250 1252 } … … 1304 1306 1305 1307 public void generate(CodeStream genPrinter) { 1306 CodePrinter p = ASTNode.printer_C; 1307 String indent = p.indent(""); 1308 for (FDelayExp d : fclass.myDelayExps()) { 1309 d.genInitVarDecls_C(p, genPrinter, indent); 1310 } 1311 for (FSpatialDistExp d : fclass.mySpatialDistExps()) { 1312 d.genInitVarDecls_C(p, genPrinter, indent); 1313 } 1314 for (FDelayExp d : fclass.myDelayExps()) { 1315 d.genInit_C(p, genPrinter, indent); 1316 } 1317 for (FSpatialDistExp d : fclass.mySpatialDistExps()) { 1318 d.genInit_C(p, genPrinter, indent); 1319 } 1308 fclass.genDelayInit_C(genPrinter); 1320 1309 } 1321 1310 } … … 1578 1567 } 1579 1568 } 1569 1570 syn int FClass.numberOfDelaysInCCode() = myDelayExps().size(); // Hook to facilitate extensions 1571 } -
branches/dev-5819/Compiler/ModelicaCBackEnd/templates/ceval_external_template.c
r11746 r13800 14 14 */ 15 15 16 #include <stdio.h> 17 #include <stdlib.h> 18 #include <string.h> 19 #include "jmi.h" 20 #include "jmi_dyn_mem.h" 21 #include "ModelicaUtilities.h" 22 #include <fcntl.h> 16 #include "jmi_evaluator_util.h" 17 18 /* Must be defined here in order to override the methods from jmi_global.c */ 19 void jmi_global_log(int warning, const char* name, const char* fmt, const char* value) { 20 _jmi_global_log(warning, name, fmt, value); 21 } 22 void jmi_throw() { 23 _jmi_throw(); 24 } 25 void* jmi_global_calloc(size_t n, size_t s) { 26 return _jmi_global_calloc(n,s); 27 } 23 28 24 29 $ECE_external_includes$ 25 30 26 /* Manual debugging */27 #define JMCEVAL_DEBUG 028 #define JMCEVAL_DBGP(x) if (JMCEVAL_DEBUG) { printf(x); fflush(stdout);}29 30 /* Format specifier when printing jmi_real_t */31 #define JMCEVAL_realFormat "%.16f"32 33 31 /* Used record definitions */ 34 32 $ECE_record_definitions$ 35 36 /* Parses ND dimensions into dimension buffer d*/37 #define JMCEVAL_parseArrayDims(ND) \38 for (di = 0; di < ND; di++) { scanf("%d",&d[di]); }39 40 /* Parse/print basic types */41 double JMCEVAL_parseReal() {42 /* Char buffer when reading jmi_real_t. This is necessary43 since "%lf" is not allowed in c89. */44 char buff[32];45 JMCEVAL_DBGP("Parse number: ");46 scanf("%s",buff);47 return strtod(buff, 0);48 }49 50 void JMCEVAL_printReal(double x) {51 printf(JMCEVAL_realFormat, x); \52 printf("\n"); \53 fflush(stdout); \54 }55 56 char* JMCEVAL_parseString() {57 int d[1];58 char* str;59 size_t si,di;60 JMCEVAL_parseArrayDims(1);61 getchar();62 str = ModelicaAllocateString(d[0]);63 JMCEVAL_DBGP("Parse string: ");64 for (si = 0; si < d[0]; si++) str[si] = getchar();65 str[d[0]] = '\0';66 return str;67 }68 69 void JMCEVAL_printString(const char* str) {70 printf("%u\n%s\n", (unsigned)strlen(str), str);71 fflush(stdout);72 }73 74 #define JMCEVAL_parseInteger() JMCEVAL_parseReal()75 #define JMCEVAL_parseBoolean() JMCEVAL_parseInteger()76 #define JMCEVAL_parseEnum() JMCEVAL_parseInteger()77 #define JMCEVAL_printInteger(X) JMCEVAL_printReal(X)78 #define JMCEVAL_printBoolean(X) JMCEVAL_printInteger(X)79 #define JMCEVAL_printEnum(X) JMCEVAL_printInteger(X)80 #define JMCEVAL_parse(TYPE, X) X = JMCEVAL_parse##TYPE()81 #define JMCEVAL_print(TYPE, X) JMCEVAL_print##TYPE(X)82 83 /* Parse/print arrays */84 #define JMCEVAL_parseArray(TYPE,ARR) for (vi = 1; vi <= ARR->num_elems; vi++) { JMCEVAL_parse(TYPE, jmi_array_ref_1(ARR,vi)); }85 #define JMCEVAL_printArray(TYPE,ARR) for (vi = 1; vi <= ARR->num_elems; vi++) { JMCEVAL_print(TYPE, jmi_array_val_1(ARR,vi)); }86 87 /* Used by ModelicaUtilities */88 void jmi_global_log(int warning, const char* name, const char* fmt, const char* value)89 {90 printf("LOG\n");91 JMCEVAL_printInteger((double)warning);92 JMCEVAL_printString(name);93 JMCEVAL_printString(fmt);94 JMCEVAL_printString(value);95 }96 97 jmp_buf jmceval_try_location;98 99 #define JMCEVAL_try() (setjmp(jmceval_try_location) == 0)100 101 void jmi_throw()102 {103 longjmp(jmceval_try_location, 1);104 }105 106 jmi_dynamic_function_memory_t* dyn_fcn_mem = NULL;107 108 jmi_dynamic_function_memory_t* jmi_dynamic_function_memory() {109 if (dyn_fcn_mem == NULL) { dyn_fcn_mem = jmi_dynamic_function_pool_create(1024*1024); }110 return dyn_fcn_mem;111 }112 113 void* jmi_global_calloc(size_t n, size_t s)114 {115 return jmi_dynamic_function_pool_direct_alloc(dyn_fcn_mem, n*s, 1);116 }117 118 void JMCEVAL_setup() {119 #ifdef _WIN32120 /* Prevent win from translating \n to \r\n */121 _setmode(fileno(stdout), _O_BINARY);122 #endif123 }124 125 int JMCEVAL_cont(const char* word) {126 char l[10];127 char* s = fgets(l, 10, stdin);128 if (strlen(s) == 1) {129 s = fgets(l, 10, stdin); /* Extra call to fix stray newline */130 }131 if (s == NULL) {132 exit(2);133 }134 if (strlen(s) == strlen(word)) {135 return strncmp(l, word, strlen(word)) == 0;136 }137 return 0;138 }139 140 void JMCEVAL_check(const char* str) {141 printf("%s\n",str);142 fflush(stdout);143 }144 145 void JMCEVAL_failed() {146 JMCEVAL_check("ABORT");147 }148 33 149 34 /* Main */ … … 195 80 JMCEVAL_failed(); 196 81 } 197 jmi_dynamic_function_pool_destroy(dyn_fcn_mem);82 _jmi_dynamic_function_pool_destroy(); 198 83 JMCEVAL_check("END"); 199 84 return 0; -
branches/dev-5819/Compiler/ModelicaCBackEnd/test/modelica/CCodeGenExternalCevalTests.mo
r13600 r13800 17 17 18 18 package CCodeGenExternalCevalTests 19 20 model ExtDynFcn1 21 type E = enumeration(A,B); 22 function f 23 input Real a1; 24 input Integer a2; 25 input Boolean a3; 26 input String a4; 27 input E a5; 28 output Real b1; 29 output Integer b2; 30 output Boolean b3; 31 output String b4; 32 output E b5; 33 external; 34 end f; 35 36 Real x1; 37 Integer x2; 38 Boolean x3; 39 String x4; 40 E x5; 41 equation 42 (x1,x2,x3,x4,x5) = f(1,2,true,"s",E.A); 43 44 annotation(__JModelica(UnitTesting(tests={ 45 FClassMethodTestCase( 46 name="ExtDynFcn1", 47 methodName="externalCTypes", 48 description="Test that the different primitive types generates the correct C mapping", 49 external_constant_evaluation_dynamic=true, 50 methodResult=" 51 f 52 void 53 d,i,i,s,i,*d,*i,*i,*s,*i, 54 ")}))); 55 end ExtDynFcn1; 56 57 model ExtDynFcn2 58 type E = enumeration(A,B); 59 function f 60 input Real[:] a1; 61 input Integer[:] a2; 62 input Boolean[:] a3; 63 input String[:] a4; 64 input E[:] a5; 65 output Real[size(a1,1)] b1; 66 output Integer[size(a2,1)] b2; 67 output Boolean[size(a3,1)] b3; 68 output String[size(a4,1)] b4; 69 output E[size(a5,1)] b5; 70 external; 71 end f; 72 Real[1] x1; 73 Integer[1] x2; 74 Boolean[1] x3; 75 String[1] x4; 76 E[1] x5; 77 equation 78 (x1,x2,x3,x4,x5) = f({1},{2},{true},{"s"},{E.A}); 79 80 annotation(__JModelica(UnitTesting(tests={ 81 FClassMethodTestCase( 82 name="ExtDynFcn2", 83 methodName="externalCTypes", 84 description="Test that the different primitive types (arrays of) generates the correct C mapping", 85 external_constant_evaluation_dynamic=true, 86 methodResult=" 87 f 88 void 89 dv,i,iv,i,iv,i,sv,i,iv,i,*dv,i,*iv,i,*iv,i,*sv,i,*iv,i, 90 ")}))); 91 end ExtDynFcn2; 92 93 model ExtDynFcn3 94 type E = enumeration(A,B); 95 record R 96 Real a1; 97 Integer a2; 98 Boolean a3; 99 String a4; 100 E a5; 101 R2 r2; 102 end R; 103 record R2 104 Real x; 105 end R2; 106 107 function f 108 input R a; 109 output R b; 110 external f(a,b); 111 end f; 112 113 R r = f(R(1,2,true,"s",E.A, R2(3))); 114 115 annotation(__JModelica(UnitTesting(tests={ 116 FClassMethodTestCase( 117 name="ExtDynFcn3", 118 methodName="externalCTypes", 119 description="Test that records generates the correct C mapping", 120 external_constant_evaluation_dynamic=true, 121 methodResult=" 122 f 123 void 124 R[d,i,i,s,i,R[d,],],*R[d,i,i,s,i,R[d,],], 125 ")}))); 126 end ExtDynFcn3; 127 19 128 20 129 model Scalar … … 789 898 end ExtObj5; 790 899 900 model ExtDynObj1 901 function use1 902 input Os.Obj1 o1; 903 output Real x; 904 external annotation(Library="extObjectsUse", Include="#include \"extObjectsUse.h\"", 905 LibraryDirectory="modelica://Library2", IncludeDirectory="Include2"); 906 end use1; 907 908 Os.Obj1 o1 = Os.Obj1(3.13, 3, true, "A message"); 909 Real x = use1(o1); 910 911 annotation(__JModelica(UnitTesting(tests={ 912 FClassMethodTestCase( 913 name="ExtDynObj1", 914 methodName="externalCTypes", 915 description="Verifies that external objects are not handled by the dynamic evaluator", 916 methodResult=" 917 ")}))); 918 end ExtDynObj1; 919 920 791 921 model Dgelsx 792 922 function dgelsx -
branches/dev-5819/Compiler/ModelicaCompiler/module.options
r12895 r13800 136 136 external objects during compilation.If less than 1, no processes will be kept 137 137 alive, i.e. this feature is turned off." 138 139 ******************************************************************************** 140 BOOLEAN external_constant_evaluation_dynamic compiler experimental false 141 142 "If enabled, calls to external functions will be evaluated during compilation 143 using a pre-compiled program (instead of generating and compiling one), if 144 possible." 138 145 139 146 ******************************************************************************** … … 458 465 459 466 ******************************************************************************** 460 -
branches/dev-5819/Compiler/ModelicaCompiler/runtime.options
r11347 r13800 221 221 "Compares the analytic block jacobians with the finite difference block 222 222 jacobians during block evaluation. An error is given if the relative error is 223 to big."223 too big." 224 224 225 225 ******************************************************************************** -
branches/dev-5819/Compiler/ModelicaCompiler/src/jastadd/DebugCompiler.jrag
r11966 r13800 130 130 mc.setLogger(out); 131 131 ModelicaCompiler.TargetObject targ = (ModelicaCompiler.TargetObject) target.getSelectedItem(); 132 mc.compileModel(new String[] { file.getAbsolutePath() }, name, targ, null , null);132 mc.compileModel(new String[] { file.getAbsolutePath() }, name, targ, null); 133 133 } catch (Exception ex) { 134 134 out.writeException(ex); -
branches/dev-5819/Compiler/ModelicaCompiler/src/jastadd/ModelicaCompiler.jrag
r13600 r13800 348 348 hooks.packFmu(this, fc, dir); 349 349 } 350 fc.root().getUtilInterface().packFmu(fc );350 fc.root().getUtilInterface().packFmu(fc, dir.toPath()); 351 351 } 352 352 … … 358 358 hooks.fmuPacked(this, fc, path); 359 359 } 360 fc.root().getUtilInterface().fmuPacked(fc, path );360 fc.root().getUtilInterface().fmuPacked(fc, path.toPath()); 361 361 } 362 362 … … 811 811 * Compile mo-file and generate code for all templates that are not null. 812 812 */ 813 String flatName = null; 814 if (!Files.isDirectory(compileTo)) { 815 flatName = compileTo.getFileName().toString(); 816 int i = flatName.lastIndexOf('.'); 817 if (i > 0) { 818 flatName = flatName.substring(0, i); 819 } 820 } 821 FClass fc = compileModel(fileName, className, target, flatName, compileTo); 813 FClass fc = compileModel(fileName, className, target, compileTo); 822 814 823 815 if (!target.getCodeGenFlag()) { … … 832 824 */ 833 825 hookCheckAbort(); 834 doCompileCCode(target, fc , className, flatName);826 doCompileCCode(target, fc); 835 827 836 828 /* … … 838 830 */ 839 831 ASTNode.beginStep("packUnit()"); 840 FileunitPath = packUnit(className, target, fc);832 Path unitPath = packUnit(className, target, fc); 841 833 unit = log.logCompiledUnit(unitPath, warnings, fc.numberOfComponents()); 842 834 ASTNode.endStep("packUnit()"); … … 1266 1258 /* Temporary fix to problems with long compilation times due to later evaluations */ 1267 1259 getExternalFunctionCache().tearDown(); 1268 options. setIntegerOption("external_constant_evaluation",0);1260 options.external_constant_evaluation.setValue(0); 1269 1261 1270 1262 hookModelTransformed(fc); … … 1369 1361 ASTNode.beginStep("generateCode()"); 1370 1362 log.info("Generating code..."); 1363 1371 1364 String name = fc.nameUnderscore(); 1372 1373 1365 Templates templates = target.getTemplates(getOptions()); 1374 1375 templates.generateCFiles(this, fc, createCGenerator(fc), sourceDir, name); 1376 templates.generateXMLFiles(this, fc, target.getXMLGenerator(fc), outDir, "modelDescription"); 1366 1367 generateAllFiles(fc, target, templates, name); 1377 1368 hookCodeGenerated(fc, outDir); 1378 1369 … … 1960 1951 * @param target 1961 1952 * The target object for the compiler. 1962 * @param flatName1963 * Name of the unit/flat model supplied by the user, if any.1964 1953 * 1965 1954 * @return A flat representation of the class specified by <code>cl</code>. … … 1983 1972 * @deprecated Use {@link #compileModel(Path[], String, TargetObject, String, Path)} instead 1984 1973 */ 1985 public FClass ModelicaCompiler.compileModel(String files[], String cl, TargetObject target, String flatName, StringcompileTo)1974 public FClass ModelicaCompiler.compileModel(String files[], String cl, TargetObject target, String compileTo) 1986 1975 throws ModelicaException, FileNotFoundException, IOException, beaver.Parser.Exception { 1987 return compileModel(stringsToPaths(files), cl, target, flatName,compileTo == null ? null : Paths.get(compileTo));1976 return compileModel(stringsToPaths(files), cl, target, compileTo == null ? null : Paths.get(compileTo)); 1988 1977 } 1989 1978 … … 1999 1988 * @param target 2000 1989 * The target object for the compiler. 2001 * @param flatName2002 * Name of the unit/flat model supplied by the user, if any.2003 1990 * 2004 1991 * @return A flat representation of the class specified by <code>cl</code>. … … 2022 2009 * @deprecated Use {@link #compileModel(Path[], String, TargetObject, String, Path)} instead 2023 2010 */ 2024 public FClass ModelicaCompiler.compileModel(Path files[], String cl, TargetObject target, String flatName,Path compileTo)2011 public FClass ModelicaCompiler.compileModel(Path files[], String cl, TargetObject target, Path compileTo) 2025 2012 throws ModelicaException, FileNotFoundException, IOException, beaver.Parser.Exception { 2026 2013 boolean doTearDown = true; 2027 2014 try { 2028 2015 doTearDown = trySetUp(); 2029 return doCompileModel(files, cl, target, flatName,compileTo);2016 return doCompileModel(files, cl, target, compileTo); 2030 2017 } finally { 2031 2018 tryTearDown(doTearDown); … … 2033 2020 } 2034 2021 2035 public FClass ModelicaCompiler.doCompileModel(String name[], String cl, TargetObject target, String flatName, String compileTo) 2036 throws ModelicaException, FileNotFoundException, IOException, beaver.Parser.Exception { 2037 return doCompileModel(stringsToPaths(name), cl, target, flatName, compileTo == null ? null : Paths.get(compileTo)); 2038 } 2039 2040 2041 public FClass ModelicaCompiler.doCompileModel(Path name[], String cl, TargetObject target, String flatName, Path compileTo) 2022 2023 public FClass ModelicaCompiler.doCompileModel(Path name[], String cl, TargetObject target, Path compileTo) 2042 2024 throws ModelicaException, FileNotFoundException, IOException, beaver.Parser.Exception { 2043 2025 if (target.equals(TargetObject.PARSE)) { … … 2062 2044 // compute instance tree 2063 2045 InstClassDecl icl = instantiateModel(name, cl, target); 2064 2046 UtilInterface util = icl.root().getUtilInterface(); 2047 String flatName = null; 2065 2048 if (compileTo != null) { 2066 File unitFile = makePackagingDirs(cl, compileTo.toFile(), target); 2067 icl.root().getUtilInterface().setCompilationOutputPath(unitFile); 2049 Path unitFile = makePackagingDirs(cl, compileTo, target); 2050 util.setCompilationOutputPath(unitFile); 2051 flatName = computeFlatName(compileTo, util); 2068 2052 } 2069 2053 … … 2207 2191 * Packs an FMU (helper function for {@link #compileUnit()}). 2208 2192 */ 2209 protected FileModelicaCompiler.packUnit(String className,2193 protected Path ModelicaCompiler.packUnit(String className, 2210 2194 TargetObject target, FClass fClass) throws PackingFailedException { 2211 2212 File unitFile = fClass.root().getUtilInterface().getCompilationOutputPath(); 2213 2195 Path unitFile = fClass.root().getUtilInterface().getCompilationOutputPath(); 2196 2214 2197 hookPackFmu(fClass, outDir); 2198 hookCheckAbort(); 2199 packUnit(className, target, fClass, unitFile); 2200 hookFmuPacked(fClass, unitFile.toAbsolutePath().toFile()); 2201 2202 return unitFile; 2203 } 2204 2205 private void ModelicaCompiler.packUnit(String className, TargetObject target, FClass fClass, Path unitFile) { 2215 2206 try { 2216 hookCheckAbort();2217 2207 copySourceFiles(fClass, sourceDir, outDir); 2218 2219 OutputStream dest = new BufferedOutputStream(new FileOutputStream(unitFile)); 2220 ZipOutputStream out = new ZipOutputStream(new BufferedOutputStream(dest)); 2221 out.setMethod(ZipOutputStream.DEFLATED); 2222 2223 zipDir(outDir, out); 2224 out.close(); 2225 } catch (CompilationAbortedException e) { 2226 throw e; 2208 try (ZipOutputStream out = new ZipOutputStream(new BufferedOutputStream(Files.newOutputStream(unitFile)))) { 2209 out.setMethod(ZipOutputStream.DEFLATED); 2210 zipDir(outDir, out); 2211 } 2227 2212 } catch (Exception e) { 2228 2213 throw new PackingFailedException(String.format("Could not write to '%s'.", unitFile), e); 2229 2214 } 2230 2231 hookFmuPacked(fClass, unitFile.getAbsoluteFile());2232 return unitFile;2233 2215 } 2234 2216 … … 2248 2230 } 2249 2231 2250 private void ModelicaCompiler.doCompileCCode(TargetObject target, FClass fc , String className, String flatName) {2232 private void ModelicaCompiler.doCompileCCode(TargetObject target, FClass fc) { 2251 2233 if (target.getMakeFileFlag() != null) { 2252 2234 ASTNode.beginStep("compileCCode()"); 2253 String cFileName = (flatName != null) ? flatName : FClass.convertClassNameToUnderscore(className);2235 String cFileName = fc.nameUnderscore(); 2254 2236 CCompilerDelegator ccompiler = getCCompiler(); 2255 2237 CCompilerArguments ccArgs = new CCompilerArguments(cFileName, fc.myOptions(), target, fc.externalLibraries(), fc.externalLibraryDirectories(), … … 2264 2246 /** 2265 2247 * Calculates the destination directory for a packaged unit. If the specified destination is a file its directory 2266 * is chosen as destination. If the destination does not exist, it is created (using {@link File #mkdirs()}).2248 * is chosen as destination. If the destination does not exist, it is created (using {@link Filed#createDirectories()}). 2267 2249 * 2268 2250 * @param className … … 2273 2255 * A {@link TargetObject} containing information about the target. 2274 2256 * @return 2275 * the path to the destination directoryof the packaged unit.2257 * the path to the destination file of the packaged unit. 2276 2258 */ 2277 private File ModelicaCompiler.makePackagingDirs(String className, File destination, TargetObject target) { 2278 File dest = new File(destination.getAbsolutePath()); 2279 if (dest.isDirectory()) { 2259 private Path ModelicaCompiler.makePackagingDirs(String className, Path destination, TargetObject target) 2260 throws IOException { 2261 Path dest = destination.toAbsolutePath(); 2262 if (Files.isDirectory(dest)) { 2280 2263 String mangledName = FClass.convertClassNameToUnderscore(className); 2281 dest = new File(dest,mangledName + "." + target.getUnitSuffix());2264 dest = dest.resolve(mangledName + "." + target.getUnitSuffix()); 2282 2265 } else { 2283 File destDir = dest.getParentFile();2284 if (destDir != null && ! destDir.isDirectory()) {2285 dest.getParentFile().mkdirs();2266 Path destDir = dest.getParent(); 2267 if (destDir != null && !Files.isDirectory(destDir)) { 2268 Files.createDirectories(dest.getParent()); 2286 2269 } 2287 2270 } 2288 2271 return dest; 2272 } 2273 2274 private void ModelicaCompiler.generateAllFiles(FClass fc, TargetObject target, Templates templates, String name) 2275 throws FileNotFoundException { 2276 templates.generateCFiles(this, fc, createCGenerator(fc), sourceDir, name); 2277 templates.generateXMLFiles(this, fc, target.getXMLGenerator(fc), outDir, "modelDescription"); 2278 } 2279 2280 private String ModelicaCompiler.computeFlatName(Path compileTo, UtilInterface util) { 2281 String flatName = null; 2282 if (!Files.isDirectory(compileTo)) { 2283 flatName = compileTo.getFileName().toString(); 2284 int i = flatName.lastIndexOf('.'); 2285 if (i > 0) { 2286 flatName = flatName.substring(0, i); 2287 } 2288 } 2289 return flatName; 2289 2290 } 2290 2291 -
branches/dev-5819/Compiler/ModelicaCompiler/src/jastadd/UtilInterface.jrag
r13600 r13800 41 41 * Called after code has been compiled. 42 42 */ 43 public void packFmu(FClass fc ) {}43 public void packFmu(FClass fc, Path outDir) {} 44 44 45 45 /** 46 46 * Called after code has been compiled. 47 47 */ 48 public void fmuPacked(FClass fc, File path) {}48 public void fmuPacked(FClass fc, Path outDir) {} 49 49 50 50 /** … … 72 72 private ExternalFunctionCache efc; 73 73 private GUIDManager guidManager; 74 private FilecompilationOutputPath;74 private Path compilationOutputPath; 75 75 76 protected UtilInterface(ModelicaCompiler mc, OptionRegistry options, IErrorHandler eh, ExternalFunctionCache efc, FilecompilationOutputPath) {76 protected UtilInterface(ModelicaCompiler mc, OptionRegistry options, IErrorHandler eh, ExternalFunctionCache efc, Path compilationOutputPath) { 77 77 this.mc = mc; 78 78 this.options = options; … … 110 110 } 111 111 112 public FilegetCompilationOutputPath() {112 public Path getCompilationOutputPath() { 113 113 return compilationOutputPath; 114 114 } 115 115 116 public void setCompilationOutputPath( FilecompilationOutputPath) {116 public void setCompilationOutputPath(Path compilationOutputPath) { 117 117 this.compilationOutputPath = compilationOutputPath; 118 118 } … … 146 146 } 147 147 148 public void UtilInterface.packFmu(FClass fc ) {148 public void UtilInterface.packFmu(FClass fc, Path outDir) { 149 149 for (Interfacer interfacer : interfacers) { 150 interfacer.packFmu(fc );150 interfacer.packFmu(fc, outDir); 151 151 } 152 152 } 153 153 154 public void UtilInterface.fmuPacked(FClass fc, File path) {154 public void UtilInterface.fmuPacked(FClass fc, Path outDir) { 155 155 for (Interfacer interfacer : interfacers) { 156 interfacer.fmuPacked(fc, path);156 interfacer.fmuPacked(fc, outDir); 157 157 } 158 158 } -
branches/dev-5819/Compiler/ModelicaCompiler/src/java/org/jmodelica/util/ccompiler/CCompilerDelegator.java
r13274 r13800 351 351 }; 352 352 } 353 354 public abstract Set<String> expandCompilerSpecificLibraryPaths(ModelicaLogger log, AbstractOptionRegistry options, 355 Set<String> extLibDirs, String platform); 353 356 } 354 357 -
branches/dev-5819/Compiler/ModelicaCompiler/src/java/org/jmodelica/util/ccompiler/GccCompilerDelegator.java
r13300 r13800 26 26 import java.util.Set; 27 27 28 import org.jmodelica.common.options.AbstractOptionRegistry; 28 29 import org.jmodelica.util.EnvironmentUtils; 29 30 import org.jmodelica.util.exceptions.CcodeCompilationException; … … 106 107 vars.put("AR", new File(mingw_bin, "ar").getPath()); 107 108 } 109 } 110 111 @Override 112 public Set<String> expandCompilerSpecificLibraryPaths(ModelicaLogger log, AbstractOptionRegistry options, Set<String> extLibDirs, String platform) { 113 Set<String> expandedLibDirs = expandLibraries(extLibDirs, platform, "gcc" + compilerVersionNumber()); 114 return expandedLibDirs; 108 115 } 109 116 -
branches/dev-5819/Compiler/ModelicaCompilerCasADi/src/jastadd/FExpToCasADi.jrag
r12770 r13800 31 31 target.setDefaultOptions(options); 32 32 try { 33 return compileModel(name, cl, target, null , null);33 return compileModel(name, cl, target, null); 34 34 } finally { 35 35 options.copyAllOptions(tempOptions); -
branches/dev-5819/Compiler/ModelicaFlatTree/src/jastadd/Arrays.jrag
r13017 r13800 4314 4314 for (CommonForIndex fi : forIndices) { 4315 4315 indexMap.put(fi.name(), new FIntegerLitExp(ii[j])); 4316 fi.setEvaluationValue( new CValueInteger(ii[j]));4316 fi.setEvaluationValue(CValueInteger.valueOf(ii[j])); 4317 4317 j++; 4318 4318 } -
branches/dev-5819/Compiler/ModelicaFlatTree/src/jastadd/ConstantEvaluation/ConstantEvaluation.jrag
r13651 r13800 80 80 * Copy this constant value. 81 81 */ 82 @Override 82 83 public CValue clone() { 83 84 try { … … 117 118 */ 118 119 public CValue convertInteger() { 119 return new CValueInteger(intValue());120 return CValueInteger.valueOf(intValue()); 120 121 } 121 122 … … 124 125 */ 125 126 public CValue convertReal() { 126 return new CValueReal(realValue());127 return CValueReal.valueOf(realValue()); 127 128 } 128 129 … … 131 132 */ 132 133 public CValue convertBoolean() { 133 return new CValueBoolean(booleanValue());134 return CValueBoolean.valueOf(booleanValue()); 134 135 } 135 136 … … 299 300 */ 300 301 public class CValueInteger extends CValue { 301 private int value; 302 303 /** 304 * Constructor. 305 * 306 * @param i Integer value. 307 */ 308 public CValueInteger(int i) { 302 private final int value; 303 304 private CValueInteger(int i) { 309 305 this.value = i; 306 } 307 308 private static final CValueInteger ZERO = new CValueInteger(0); 309 310 public static CValueInteger valueOf(int i) { 311 if (i == 0) { 312 return ZERO; 313 } 314 return new CValueInteger(i); 310 315 } 311 316 … … 420 425 return true; 421 426 } 427 428 @Override 429 public CValueInteger clone() { 430 return this; 431 } 422 432 } 423 433 … … 426 436 */ 427 437 public class CValueReal extends CValue { 428 private double value;438 private final double value; 429 439 430 440 /** … … 433 443 * @param d Double value. 434 444 */ 435 p ublicCValueReal(double d) {445 private CValueReal(double d) { 436 446 this.value = d; 447 } 448 449 private static final CValueReal ZERO = new CValueReal(0.0); 450 451 public static CValueReal valueOf(double d) { 452 if (d == 0.0 && (Double.doubleToLongBits(d) & 0x8000000000000000L) == 0L) { 453 return ZERO; 454 } 455 return new CValueReal(d); 437 456 } 438 457 … … 548 567 return true; 549 568 } 569 570 @Override 571 public CValueReal clone() { 572 return this; 573 } 574 550 575 } 551 576 … … 560 585 public static final CValueBoolean TRUE = new CValueBoolean(true); 561 586 562 private boolean value;587 private final boolean value; 563 588 564 589 /** … … 567 592 * @param b Boolean value. 568 593 */ 569 public CValueBoolean(boolean b) { 570 this.value = b; 594 private CValueBoolean(boolean b) { 595 this.value = b; 596 } 597 598 public static CValueBoolean valueOf(boolean b) { 599 return b ? TRUE : FALSE; 571 600 } 572 601 … … 650 679 return true; 651 680 } 681 682 @Override 683 public CValueBoolean clone() { 684 return this; 685 } 652 686 } 653 687 … … 656 690 */ 657 691 public class CValueString extends CValue { 658 private String value;692 private final String value; 659 693 660 694 /** … … 716 750 return true; 717 751 } 752 753 @Override 754 public CValueString clone() { 755 return this; 756 } 757 718 758 } 719 759 … … 1614 1654 public class CValueEnum extends CValue { 1615 1655 1616 private FEnumType type;1617 private String value;1618 private int index;1656 private final FEnumType type; 1657 private final String value; 1658 private final int index; 1619 1659 1620 1660 /** … … 1627 1667 this.type = (FEnumType) type; 1628 1668 this.value = value; 1629 in dex = 0;1669 int temp_index = 0; 1630 1670 int n = this.type.getNumFEnumLiteralType(); 1631 for (int i = 0; i < n && index == 0; i++) 1632 if (this.type.getFEnumLiteralType(i).getName().equals(value)) 1633 index = i + 1; 1671 for (int i = 0; i < n && temp_index == 0; i++) { 1672 if (this.type.getFEnumLiteralType(i).getName().equals(value)) { 1673 temp_index = i + 1; 1674 } 1675 } 1676 index = temp_index; 1634 1677 } 1635 1678 … … 1705 1748 * @return an CommonAccessExp pointing to the literal in the FEnumDecl. 1706 1749 */ 1750 @Override 1707 1751 public FExp buildLiteral() { 1708 1752 return type.createLiteral(index); … … 1719 1763 } 1720 1764 1765 @Override 1721 1766 public CValue constrainWithin(CValue min, CValue max) { 1722 1767 if (!min.isUnknown() && min.intValue() > index) … … 1726 1771 return this; 1727 1772 } 1773 1774 @Override 1775 public CValueEnum clone() { 1776 return this; 1777 } 1728 1778 1729 1779 } … … 1746 1796 public CValue FType.zeroCValueScalar() { return CValue.UNKNOWN; } 1747 1797 public CValue FArrayType.zeroCValueScalar() { return getFPrimitiveType().zeroCValueScalar(); } 1748 public CValue FRealType.zeroCValueScalar() { return new CValueReal(0.0); }1749 public CValue FIntegerType.zeroCValueScalar() { return new CValueInteger(0); }1798 public CValue FRealType.zeroCValueScalar() { return CValueReal.valueOf(0.0); } 1799 public CValue FIntegerType.zeroCValueScalar() { return CValueInteger.valueOf(0); } 1750 1800 public CValue FEnumType.zeroCValueScalar() { return new CValueEnum(this, 1); } 1751 1801 public CValue FStringType.zeroCValueScalar() { return new CValueString(""); } 1752 public CValue FBooleanType.zeroCValueScalar() { return new CValueBoolean(false); }1802 public CValue FBooleanType.zeroCValueScalar() { return CValueBoolean.FALSE; } 1753 1803 1754 1804 public CValue FType.createCValue(int v) { … … 1763 1813 } 1764 1814 1765 public CValue FType.createCValueScalar(int v) { return new CValueInteger(v); }1766 public CValue FRealType.createCValueScalar(int v) { return new CValueReal(v); }1815 public CValue FType.createCValueScalar(int v) { return CValueInteger.valueOf(v); } 1816 public CValue FRealType.createCValueScalar(int v) { return CValueReal.valueOf(v); } 1767 1817 1768 1818 public CValue FType.convert(CValue v) { return v; } … … 1773 1823 1774 1824 public CValue FType.limitCValueScalar(boolean high) { return CValue.UNSUPPORTED; } 1775 public CValue FRealType.limitCValueScalar(boolean high) { return new CValueReal( high ? Double.MAX_VALUE : -Double.MAX_VALUE); }1776 public CValue FIntegerType.limitCValueScalar(boolean high) { return new CValueInteger( high ? Integer.MAX_VALUE : Integer.MIN_VALUE); }1777 public CValue FBooleanType.limitCValueScalar(boolean high) { return new CValueBoolean( high ? true : false); }1825 public CValue FRealType.limitCValueScalar(boolean high) { return CValueReal.valueOf( high ? Double.MAX_VALUE : -Double.MAX_VALUE); } 1826 public CValue FIntegerType.limitCValueScalar(boolean high) { return CValueInteger.valueOf( high ? Integer.MAX_VALUE : Integer.MIN_VALUE); } 1827 public CValue FBooleanType.limitCValueScalar(boolean high) { return CValueBoolean.valueOf(high); } 1778 1828 public CValue FEnumType.limitCValueScalar(boolean high) { return new CValueEnum(this, high ? getNumFEnumLiteralType() : 1); } 1779 1829 … … 2387 2437 2388 2438 FType t = type(); 2389 CValue sum = new CValueInteger(0);2439 CValue sum = CValueInteger.valueOf(0); 2390 2440 CValueArray l = getLeft().ceval(evaluator).array(); 2391 2441 CValueArray r = getRight().ceval(evaluator).array(); … … 2481 2531 2482 2532 eq FEndExp.cevalCalc(VariableEvaluator evaluator) = mySize().ceval(evaluator, 0); 2483 eq FNdimsExp.cevalCalc(VariableEvaluator evaluator) = new CValueInteger(getFExp().ndims());2533 eq FNdimsExp.cevalCalc(VariableEvaluator evaluator) = CValueInteger.valueOf(getFExp().ndims()); 2484 2534 2485 2535 eq FSubscriptedExp.cevalCalc(VariableEvaluator evaluator) { … … 2490 2540 eq FCardinality.cevalCalc(VariableEvaluator evaluator) { 2491 2541 final int v = getFExp().cardinalityValue(); 2492 return (v <= 0) ? CValue.UNKNOWN : new CValueInteger(v);2542 return (v <= 0) ? CValue.UNKNOWN : CValueInteger.valueOf(v); 2493 2543 } 2494 2544 … … 2500 2550 eq FConnBoolOp.cevalCalc(VariableEvaluator evaluator) { 2501 2551 if (connectionGraph != null && connectionGraph.builtTreesDone()) 2502 return new CValueBoolean(cevalFromGraph());2552 return CValueBoolean.valueOf(cevalFromGraph()); 2503 2553 else 2504 2554 throw new ConstantEvaluationNotReadyException(); … … 2547 2597 public CValue Size.ceval(VariableEvaluator evaluator, int d) { 2548 2598 int s = get(d); 2549 return (s == Size.UNKNOWN) ? CValue.UNKNOWN : new CValueInteger(s);2599 return (s == Size.UNKNOWN) ? CValue.UNKNOWN : CValueInteger.valueOf(s); 2550 2600 } 2551 2601 … … 2614 2664 /** Set the value for initial() to evaluate to. */ 2615 2665 public static void FInitialExp.setIsInitial(boolean value) { 2616 evaluationValue = new CValueBoolean(value);2666 evaluationValue = CValueBoolean.valueOf(value); 2617 2667 } 2618 2668 … … 2629 2679 eq FMaxExp.selectLesser() = false; 2630 2680 2631 eq FRealLitExp.cevalCalc(VariableEvaluator evaluator) = new CValueReal(getValue());2632 eq FIntegerLitExp.cevalCalc(VariableEvaluator evaluator) = new CValueInteger(getValue());2633 eq FBooleanLitExpTrue.cevalCalc(VariableEvaluator evaluator) = new CValueBoolean(true);2634 eq FBooleanLitExpFalse.cevalCalc(VariableEvaluator evaluator) = new CValueBoolean(false);2681 eq FRealLitExp.cevalCalc(VariableEvaluator evaluator) = CValueReal.valueOf(getValue()); 2682 eq FIntegerLitExp.cevalCalc(VariableEvaluator evaluator) = CValueInteger.valueOf(getValue()); 2683 eq FBooleanLitExpTrue.cevalCalc(VariableEvaluator evaluator) = CValueBoolean.TRUE; 2684 eq FBooleanLitExpFalse.cevalCalc(VariableEvaluator evaluator) = CValueBoolean.FALSE; 2635 2685 eq FStringLitExp.cevalCalc(VariableEvaluator evaluator) = new CValueString(unEscape()); 2636 2686 eq FEnumLitExp.cevalCalc(VariableEvaluator evaluator) = new CValueEnum(type(), getValue()); … … 2689 2739 eq FAbstractDerExp.cevalUse(VariableEvaluator evaluator) { 2690 2740 if (getFAccess().variability().discreteOrLess()) 2691 return new CValueInteger(0);2741 return CValueInteger.valueOf(0); 2692 2742 FAbstractVariable decl = myFV(); 2693 2743 return decl == null ? CValue.UNKNOWN : evaluator.ceval(decl); … … 2706 2756 eq InstGlobalAccess.ceval(VariableEvaluator evaluator, Index i) = getInstAccess().ceval(evaluator, i); 2707 2757 eq InstNamedAccess.ceval(VariableEvaluator evaluator, Index i) { 2708 CValue res = unknownCValue();2758 CValue res; 2709 2759 if (myInstComponentDecl().isAssignable()) { 2710 2760 Index iHere = Index.NULL; … … 2728 2778 res = res.getCell(iHere); 2729 2779 } else if (myInstClassDecl().isEnum()) { 2730 res = new CValueInteger(myInstClassDecl().enumLiterals().size());2780 res = CValueInteger.valueOf(myInstClassDecl().enumLiterals().size()); 2731 2781 } else if (myInstClassDecl().isBoolean()) { 2732 res = new CValueInteger(2); 2782 res = CValueInteger.valueOf(2); 2783 } else { 2784 res = unknownCValue(); 2733 2785 } 2734 2786 return res; … … 2786 2838 eq FAbsExp.cevalCalc(VariableEvaluator evaluator) = type().abs(getFExp().ceval(evaluator)); 2787 2839 eq FSignExp.cevalCalc(VariableEvaluator evaluator) = type().sign(getFExp().ceval(evaluator)); 2788 eq FSqrtExp.cevalCalc(VariableEvaluator evaluator) = new CValueReal(StrictMath.sqrt(getFExp().ceval(evaluator).realValue()));2840 eq FSqrtExp.cevalCalc(VariableEvaluator evaluator) = CValueReal.valueOf(StrictMath.sqrt(getFExp().ceval(evaluator).realValue())); 2789 2841 eq FEnumIntegerExp.cevalCalc(VariableEvaluator evaluator) = getFExp().ceval(evaluator).convertInteger(); 2790 2842 eq FStringExp.cevalCalc(VariableEvaluator evaluator) { … … 2889 2941 eq FIntegerFuncExp.cevalCalc(VariableEvaluator evaluator) = getX().ceval(evaluator).convertInteger(); 2890 2942 2891 eq FSinExp.cevalCalc(VariableEvaluator evaluator) = new CValueReal(StrictMath.sin(getFExp().ceval(evaluator).realValue()));2892 eq FCosExp.cevalCalc(VariableEvaluator evaluator) = new CValueReal(StrictMath.cos(getFExp().ceval(evaluator).realValue()));2893 eq FTanExp.cevalCalc(VariableEvaluator evaluator) = new CValueReal(StrictMath.tan(getFExp().ceval(evaluator).realValue()));2894 eq FAsinExp.cevalCalc(VariableEvaluator evaluator) = new CValueReal(StrictMath.asin(getFExp().ceval(evaluator).realValue()));2895 eq FAcosExp.cevalCalc(VariableEvaluator evaluator) = new CValueReal(StrictMath.acos(getFExp().ceval(evaluator).realValue()));2896 eq FAtanExp.cevalCalc(VariableEvaluator evaluator) = new CValueReal(StrictMath.atan(getFExp().ceval(evaluator).realValue()));2897 eq FAtan2Exp.cevalCalc(VariableEvaluator evaluator) = new CValueReal(StrictMath.atan2(getFExp().ceval(evaluator).realValue(),2943 eq FSinExp.cevalCalc(VariableEvaluator evaluator) = CValueReal.valueOf(StrictMath.sin(getFExp().ceval(evaluator).realValue())); 2944 eq FCosExp.cevalCalc(VariableEvaluator evaluator) = CValueReal.valueOf(StrictMath.cos(getFExp().ceval(evaluator).realValue())); 2945 eq FTanExp.cevalCalc(VariableEvaluator evaluator) = CValueReal.valueOf(StrictMath.tan(getFExp().ceval(evaluator).realValue())); 2946 eq FAsinExp.cevalCalc(VariableEvaluator evaluator) = CValueReal.valueOf(StrictMath.asin(getFExp().ceval(evaluator).realValue())); 2947 eq FAcosExp.cevalCalc(VariableEvaluator evaluator) = CValueReal.valueOf(StrictMath.acos(getFExp().ceval(evaluator).realValue())); 2948 eq FAtanExp.cevalCalc(VariableEvaluator evaluator) = CValueReal.valueOf(StrictMath.atan(getFExp().ceval(evaluator).realValue())); 2949 eq FAtan2Exp.cevalCalc(VariableEvaluator evaluator) = CValueReal.valueOf(StrictMath.atan2(getFExp().ceval(evaluator).realValue(), 2898 2950 getY().ceval(evaluator).realValue())); 2899 eq FSinhExp.cevalCalc(VariableEvaluator evaluator) = new CValueReal(StrictMath.sinh(getFExp().ceval(evaluator).realValue()));2900 eq FCoshExp.cevalCalc(VariableEvaluator evaluator) = new CValueReal(StrictMath.cosh(getFExp().ceval(evaluator).realValue()));2901 eq FTanhExp.cevalCalc(VariableEvaluator evaluator) = new CValueReal(StrictMath.tanh(getFExp().ceval(evaluator).realValue()));2902 eq FExpExp.cevalCalc(VariableEvaluator evaluator) = new CValueReal(StrictMath.exp(getFExp().ceval(evaluator).realValue()));2903 eq FLogExp.cevalCalc(VariableEvaluator evaluator) = new CValueReal(StrictMath.log(getFExp().ceval(evaluator).realValue()));2904 eq FLog10Exp.cevalCalc(VariableEvaluator evaluator) = new CValueReal(StrictMath.log10(getFExp().ceval(evaluator).realValue()));2951 eq FSinhExp.cevalCalc(VariableEvaluator evaluator) = CValueReal.valueOf(StrictMath.sinh(getFExp().ceval(evaluator).realValue())); 2952 eq FCoshExp.cevalCalc(VariableEvaluator evaluator) = CValueReal.valueOf(StrictMath.cosh(getFExp().ceval(evaluator).realValue())); 2953 eq FTanhExp.cevalCalc(VariableEvaluator evaluator) = CValueReal.valueOf(StrictMath.tanh(getFExp().ceval(evaluator).realValue())); 2954 eq FExpExp.cevalCalc(VariableEvaluator evaluator) = CValueReal.valueOf(StrictMath.exp(getFExp().ceval(evaluator).realValue())); 2955 eq FLogExp.cevalCalc(VariableEvaluator evaluator) = CValueReal.valueOf(StrictMath.log(getFExp().ceval(evaluator).realValue())); 2956 eq FLog10Exp.cevalCalc(VariableEvaluator evaluator) = CValueReal.valueOf(StrictMath.log10(getFExp().ceval(evaluator).realValue())); 2905 2957 2906 2958 eq FExInStream.cevalCalc(VariableEvaluator evaluator) { … … 2931 2983 div += flow; 2932 2984 } 2933 return new CValueReal(sum / div);2985 return CValueReal.valueOf(sum / div); 2934 2986 } 2935 2987 } … … 2940 2992 syn CValue FSubscript.ceval(VariableEvaluator evaluator) = CValue.UNSUPPORTED; 2941 2993 eq FExpSubscript.ceval(VariableEvaluator evaluator) = getFExp().ceval(evaluator); 2942 eq FIntegerSubscript.ceval(VariableEvaluator evaluator) = new CValueInteger(getValue());2994 eq FIntegerSubscript.ceval(VariableEvaluator evaluator) = CValueInteger.valueOf(getValue()); 2943 2995 2944 2996 syn int FSubscript.value() = ceval(defaultVariableEvaluator()).intValue(); … … 3177 3229 eq InstPrimitive.attributeCValueDefault(String name) { 3178 3230 if (name.equals(FAttribute.FIXED)) 3179 return new CValueBoolean(isConstant() || isParameter() || isString());3231 return CValueBoolean.valueOf(isConstant() || isParameter() || isString()); 3180 3232 CValue res = attributeCValueDefaultMap().get(name); 3181 3233 return (res == null) ? CValue.UNKNOWN : res; … … 3203 3255 real.put(FAttribute.UNIT, emptyStr); 3204 3256 real.put(FAttribute.DISPLAY_UNIT, emptyStr); 3205 real.put(FAttribute.START, new CValueReal(0.0));3257 real.put(FAttribute.START, CValueReal.valueOf(0.0)); 3206 3258 // TODO: add stateSelect, but how to get type? 3207 3259 REAL_DEFAULT_ATTRIBUTES = real; 3208 3260 Map<String,CValue> integer = new HashMap<String,CValue>(); 3209 3261 integer.put(FAttribute.QUANTITY, emptyStr); 3210 integer.put(FAttribute.START, new CValueInteger(0));3262 integer.put(FAttribute.START, CValueInteger.valueOf(0)); 3211 3263 INTEGER_DEFAULT_ATTRIBUTES = integer; 3212 3264 Map<String,CValue> bool = new HashMap<String,CValue>(); … … 4231 4283 return CValue.UNKNOWN; 4232 4284 } 4233 return new CValueReal(v1.realValue() + v2.realValue());4285 return CValueReal.valueOf(v1.realValue() + v2.realValue()); 4234 4286 } 4235 4287 … … 4238 4290 return CValue.UNKNOWN; 4239 4291 } 4240 return new CValueInteger(v1.intValue() + v2.intValue());4292 return CValueInteger.valueOf(v1.intValue() + v2.intValue()); 4241 4293 } 4242 4294 … … 4261 4313 return CValue.UNKNOWN; 4262 4314 } 4263 return new CValueReal(v1.realValue() - v2.realValue());4315 return CValueReal.valueOf(v1.realValue() - v2.realValue()); 4264 4316 } 4265 4317 … … 4268 4320 return CValue.UNKNOWN; 4269 4321 } 4270 return new CValueInteger(v1.intValue() - v2.intValue());4322 return CValueInteger.valueOf(v1.intValue() - v2.intValue()); 4271 4323 } 4272 4324 … … 4284 4336 return CValue.UNKNOWN; 4285 4337 } 4286 return new CValueReal(v1.realValue() * v2.realValue());4338 return CValueReal.valueOf(v1.realValue() * v2.realValue()); 4287 4339 } 4288 4340 … … 4291 4343 return CValue.UNKNOWN; 4292 4344 } 4293 return new CValueInteger(v1.intValue() * v2.intValue());4345 return CValueInteger.valueOf(v1.intValue() * v2.intValue()); 4294 4346 } 4295 4347 … … 4307 4359 return CValue.UNKNOWN; 4308 4360 } 4309 return new CValueReal(v1.realValue() / v2.realValue());4361 return CValueReal.valueOf(v1.realValue() / v2.realValue()); 4310 4362 } 4311 4363 … … 4314 4366 return CValue.UNKNOWN; 4315 4367 } 4316 return new CValueReal(v1.realValue() / v2.realValue());4368 return CValueReal.valueOf(v1.realValue() / v2.realValue()); 4317 4369 } 4318 4370 … … 4330 4382 return CValue.UNKNOWN; 4331 4383 } 4332 return new CValueReal(java.lang.StrictMath.pow(v1.realValue(), v2.realValue()));4384 return CValueReal.valueOf(java.lang.StrictMath.pow(v1.realValue(), v2.realValue())); 4333 4385 } 4334 4386 … … 4340 4392 */ 4341 4393 syn CValue FType.neg(CValue v) = CValue.UNKNOWN; 4342 eq FRealType.neg(CValue v) = v.hasRealValue() ? new CValueReal(-v.realValue()) : CValue.UNKNOWN;4343 eq FIntegerType.neg(CValue v) = v.hasIntValue() ? new CValueInteger(-v.intValue()) : CValue.UNKNOWN;4394 eq FRealType.neg(CValue v) = v.hasRealValue() ? CValueReal.valueOf(-v.realValue()) : CValue.UNKNOWN; 4395 eq FIntegerType.neg(CValue v) = v.hasIntValue() ? CValueInteger.valueOf(-v.intValue()) : CValue.UNKNOWN; 4344 4396 4345 4397 /** … … 4350 4402 */ 4351 4403 syn CValue FType.abs(CValue v) = CValue.UNKNOWN; 4352 eq FRealType.abs(CValue v) = v.hasRealValue() ? new CValueReal(StrictMath.abs(v.realValue())) : CValue.UNKNOWN;4404 eq FRealType.abs(CValue v) = v.hasRealValue() ? CValueReal.valueOf(StrictMath.abs(v.realValue())) : CValue.UNKNOWN; 4353 4405 eq FIntegerType.abs(CValue v) = 4354 v.hasIntValue() ? new CValueInteger(StrictMath.abs(v.intValue())) : CValue.UNKNOWN;4406 v.hasIntValue() ? CValueInteger.valueOf(StrictMath.abs(v.intValue())) : CValue.UNKNOWN; 4355 4407 4356 4408 /** … … 4363 4415 4364 4416 eq FIntegerType.sign(CValue v) = 4365 v.hasIntValue() ? new CValueInteger((int) StrictMath.signum(v.realValue())) : CValue.UNKNOWN;4417 v.hasIntValue() ? CValueInteger.valueOf((int) StrictMath.signum(v.realValue())) : CValue.UNKNOWN; 4366 4418 4367 4419 /** … … 4373 4425 syn CValue FType.ceil(CValue v) = CValue.UNKNOWN; 4374 4426 4375 eq FRealType.ceil(CValue v) = v.hasRealValue() ? new CValueReal(StrictMath.ceil(v.realValue())) : CValue.UNKNOWN;4427 eq FRealType.ceil(CValue v) = v.hasRealValue() ? CValueReal.valueOf(StrictMath.ceil(v.realValue())) : CValue.UNKNOWN; 4376 4428 4377 4429 eq FIntegerType.ceil(CValue v) = 4378 v.hasIntValue() ? new CValueInteger((int) StrictMath.ceil(v.realValue())) : CValue.UNKNOWN;4430 v.hasIntValue() ? CValueInteger.valueOf((int) StrictMath.ceil(v.realValue())) : CValue.UNKNOWN; 4379 4431 4380 4432 /** … … 4413 4465 return CValue.UNKNOWN; 4414 4466 } 4415 return new CValueBoolean(v1.booleanValue() && v2.booleanValue());4467 return CValueBoolean.valueOf(v1.booleanValue() && v2.booleanValue()); 4416 4468 } 4417 4469 … … 4429 4481 return CValue.UNKNOWN; 4430 4482 } 4431 return new CValueBoolean(v1.booleanValue() || v2.booleanValue());4483 return CValueBoolean.valueOf(v1.booleanValue() || v2.booleanValue()); 4432 4484 } 4433 4485 … … 4439 4491 */ 4440 4492 syn CValue FType.not(CValue v) = CValue.UNKNOWN; 4441 eq FBooleanType.not(CValue v) = v.isBoolean() ? new CValueBoolean(!v.booleanValue()) : CValue.UNKNOWN;4493 eq FBooleanType.not(CValue v) = v.isBoolean() ? CValueBoolean.valueOf(!v.booleanValue()) : CValue.UNKNOWN; 4442 4494 4443 4495 /* Machine epsilon */ … … 4464 4516 return CValue.UNKNOWN; 4465 4517 } 4466 return new CValueBoolean(v1.intValue() == v2.intValue());4518 return CValueBoolean.valueOf(v1.intValue() == v2.intValue()); 4467 4519 } 4468 4520 … … 4471 4523 return CValue.UNKNOWN; 4472 4524 } 4473 return new CValueBoolean(almostZero(v1.realValue() - v2.realValue()));4525 return CValueBoolean.valueOf(almostZero(v1.realValue() - v2.realValue())); 4474 4526 } 4475 4527 … … 4478 4530 return CValue.UNKNOWN; 4479 4531 } 4480 return new CValueBoolean(v1.stringValue().compareTo(v2.stringValue()) == 0);4532 return CValueBoolean.valueOf(v1.stringValue().compareTo(v2.stringValue()) == 0); 4481 4533 } 4482 4534 … … 4494 4546 return CValue.UNKNOWN; 4495 4547 } 4496 return new CValueBoolean(v1.intValue() != v2.intValue());4548 return CValueBoolean.valueOf(v1.intValue() != v2.intValue()); 4497 4549 } 4498 4550 … … 4501 4553 return CValue.UNKNOWN; 4502 4554 } 4503 return new CValueBoolean(v1.realValue() != v2.realValue());4555 return CValueBoolean.valueOf(v1.realValue() != v2.realValue()); 4504 4556 } 4505 4557 … … 4508 4560 return CValue.UNKNOWN; 4509 4561 } 4510 return new CValueBoolean(v1.stringValue().compareTo(v2.stringValue()) != 0);4562 return CValueBoolean.valueOf(v1.stringValue().compareTo(v2.stringValue()) != 0); 4511 4563 } 4512 4564 … … 4524 4576 return CValue.UNKNOWN; 4525 4577 } 4526 return new CValueBoolean(v1.intValue() >= v2.intValue());4578 return CValueBoolean.valueOf(v1.intValue() >= v2.intValue()); 4527 4579 } 4528 4580 … … 4531 4583 return CValue.UNKNOWN; 4532 4584 } 4533 return new CValueBoolean(almostGtZero(v1.realValue() - v2.realValue()));4585 return CValueBoolean.valueOf(almostGtZero(v1.realValue() - v2.realValue())); 4534 4586 } 4535 4587 … … 4538 4590 return CValue.UNKNOWN; 4539 4591 } 4540 return new CValueBoolean(v1.stringValue().compareTo(v2.stringValue()) >= 0);4592 return CValueBoolean.valueOf(v1.stringValue().compareTo(v2.stringValue()) >= 0); 4541 4593 } 4542 4594 … … 4554 4606 return CValue.UNKNOWN; 4555 4607 } 4556 return new CValueBoolean(v1.intValue() > v2.intValue());4608 return CValueBoolean.valueOf(v1.intValue() > v2.intValue()); 4557 4609 } 4558 4610 … … 4561 4613 return CValue.UNKNOWN; 4562 4614 } 4563 return new CValueBoolean(v1.realValue() > v2.realValue());4615 return CValueBoolean.valueOf(v1.realValue() > v2.realValue()); 4564 4616 } 4565 4617 … … 4568 4620 return CValue.UNKNOWN; 4569 4621 } 4570 return new CValueBoolean(v1.stringValue().compareTo(v2.stringValue()) > 0);4622 return CValueBoolean.valueOf(v1.stringValue().compareTo(v2.stringValue()) > 0); 4571 4623 } 4572 4624 … … 4584 4636 return CValue.UNKNOWN; 4585 4637 } 4586 return new CValueBoolean(v1.intValue() <= v2.intValue());4638 return CValueBoolean.valueOf(v1.intValue() <= v2.intValue()); 4587 4639 } 4588 4640 … … 4591 4643 return CValue.UNKNOWN; 4592 4644 } 4593 return new CValueBoolean(almostLtZero(v1.realValue() - v2.realValue()));4645 return CValueBoolean.valueOf(almostLtZero(v1.realValue() - v2.realValue())); 4594 4646 } 4595 4647 … … 4598 4650 return CValue.UNKNOWN; 4599 4651 } 4600 return new CValueBoolean(v1.stringValue().compareTo(v2.stringValue()) <= 0);4652 return CValueBoolean.valueOf(v1.stringValue().compareTo(v2.stringValue()) <= 0); 4601 4653 } 4602 4654 … … 4614 4666 return CValue.UNKNOWN; 4615 4667 } 4616 return new CValueBoolean(v1.intValue() < v2.intValue());4668 return CValueBoolean.valueOf(v1.intValue() < v2.intValue()); 4617 4669 } 4618 4670 … … 4621 4673 return CValue.UNKNOWN; 4622 4674 } 4623 return new CValueBoolean(v1.realValue() < v2.realValue());4675 return CValueBoolean.valueOf(v1.realValue() < v2.realValue()); 4624 4676 } 4625 4677 … … 4628 4680 return CValue.UNKNOWN; 4629 4681 } 4630 return new CValueBoolean(v1.stringValue().compareTo(v2.stringValue()) < 0);4682 return CValueBoolean.valueOf(v1.stringValue().compareTo(v2.stringValue()) < 0); 4631 4683 } 4632 4684 4633 4685 eq CValueUnknown.lt(CValue v1, CValue v2) = CValue.UNKNOWN; 4634 4686 4687 4688 public CValue CValue.absoluteValue() { 4689 return this; 4690 } 4691 @Override 4692 public CValue CValueReal.absoluteValue() { 4693 return new CValueReal(Math.abs(realValue())); 4694 } 4695 @Override 4696 public CValue CValueInteger.absoluteValue() { 4697 return new CValueInteger(Math.abs(intValue())); 4698 } 4699 4635 4700 } 4636 4701 … … 4891 4956 eq SrcBooleanLitExpTrue.ceval() = CValueBoolean.TRUE; 4892 4957 eq SrcBooleanLitExpFalse.ceval() = CValueBoolean.FALSE; 4893 eq SrcIntegerLitExp.ceval() = new CValueInteger(Integer.parseInt(getUNSIGNED_INTEGER()));4894 eq SrcRealLitExp.ceval() = new CValueReal(Double.parseDouble(getUNSIGNED_NUMBER()));4958 eq SrcIntegerLitExp.ceval() = CValueInteger.valueOf(Integer.parseInt(getUNSIGNED_INTEGER())); 4959 eq SrcRealLitExp.ceval() = CValueReal.valueOf(Double.parseDouble(getUNSIGNED_NUMBER())); 4895 4960 eq SrcArrayConstructor.ceval() = cevalArray(); 4896 4961 eq SrcMatrix.ceval() = cevalArray(); … … 4898 4963 CValue value = getSrcExp().ceval(); 4899 4964 if (value.isInteger()) 4900 return new CValueInteger(-value.intValue());4965 return CValueInteger.valueOf(-value.intValue()); 4901 4966 else if (value.isReal()) 4902 return new CValueReal(-value.realValue());4967 return CValueReal.valueOf(-value.realValue()); 4903 4968 else 4904 4969 return CValue.UNKNOWN; … … 5014 5079 } 5015 5080 5016 public AlgorithmEvaluator createAlgorithmEvaluator( AbstractOptionRegistry options, Map<CommonVariableDecl, CValue> values) {5081 public AlgorithmEvaluator createAlgorithmEvaluator(OptionRegistry options, Map<CommonVariableDecl, CValue> values) { 5017 5082 return new AlgorithmEvaluator(externalEvaluationEnabled, options, values); 5018 5083 } 5019 5084 5020 public AlgorithmEvaluator createEmptyAlgorithmEvaluator( AbstractOptionRegistry options) {5085 public AlgorithmEvaluator createEmptyAlgorithmEvaluator(OptionRegistry options) { 5021 5086 return new AlgorithmEvaluator(true, options, Collections.<CommonVariableDecl, CValue>emptyMap()); 5022 5087 } … … 5084 5149 5085 5150 @Override 5086 public AlgorithmEvaluator createAlgorithmEvaluator( AbstractOptionRegistry options, Map<CommonVariableDecl, CValue> values) {5151 public AlgorithmEvaluator createAlgorithmEvaluator(OptionRegistry options, Map<CommonVariableDecl, CValue> values) { 5087 5152 return new PartialAlgorithmEvaluator(externalEvaluationEnabled(), options, values, this); 5088 5153 } … … 5118 5183 5119 5184 @Override 5120 public AlgorithmEvaluator createAlgorithmEvaluator( AbstractOptionRegistry options, Map<CommonVariableDecl, CValue> values) {5185 public AlgorithmEvaluator createAlgorithmEvaluator(OptionRegistry options, Map<CommonVariableDecl, CValue> values) { 5121 5186 if (this.values == null) { 5122 5187 this.values = values; … … 5212 5277 public class AlgorithmEvaluator extends VariableEvaluator { 5213 5278 5214 protected Map<CommonVariableDecl, CValue> values;5215 private AbstractOptionRegistry options;5216 5217 public AlgorithmEvaluator(boolean evaluateExternalEnabled, AbstractOptionRegistry options, Map<CommonVariableDecl, CValue> values) {5279 protected final Map<CommonVariableDecl, CValue> values; 5280 private final OptionRegistry options; 5281 5282 public AlgorithmEvaluator(boolean evaluateExternalEnabled, OptionRegistry options, Map<CommonVariableDecl, CValue> values) { 5218 5283 super(evaluateExternalEnabled); 5219 5284 this.values = values; … … 5222 5287 5223 5288 public int externalEvaluation() { 5224 return externalEvaluationEnabled() ? options. getIntegerOption("external_constant_evaluation") : 0;5289 return externalEvaluationEnabled() ? options.external_constant_evaluation.getValue() : 0; 5225 5290 } 5226 5291 … … 5286 5351 protected ArrayList<IfEvaluation> ifStack; 5287 5352 5288 public PartialAlgorithmEvaluator(boolean evaluateExternalEnabled, AbstractOptionRegistry options,5353 public PartialAlgorithmEvaluator(boolean evaluateExternalEnabled, OptionRegistry options, 5289 5354 Map<CommonVariableDecl, CValue> values, PartialVariableEvaluator variableEvaluator) { 5290 5355 super(evaluateExternalEnabled, options, values); … … 5303 5368 5304 5369 @Override 5305 public AlgorithmEvaluator createAlgorithmEvaluator( AbstractOptionRegistry options, Map<CommonVariableDecl, CValue> values) {5370 public AlgorithmEvaluator createAlgorithmEvaluator(OptionRegistry options, Map<CommonVariableDecl, CValue> values) { 5306 5371 return variableEvaluator.createAlgorithmEvaluator(options, values); 5307 5372 } -
branches/dev-5819/Compiler/ModelicaFlatTree/src/jastadd/ConstantEvaluation/ExternalConstantEvaluation.jrag
r11541 r13800 26 26 import java.util.TimerTask; 27 27 28 import org.jmodelica.common.evaluation.ExternalFunctionCompiler; 28 29 import org.jmodelica.common.evaluation.ExternalFunction; 29 30 import org.jmodelica.common.evaluation.ExternalProcessCache; 30 31 import org.jmodelica.common.evaluation.ExternalProcessCacheImpl; 31 32 import org.jmodelica.common.evaluation.ExternalProcessMultiCache; 33 import org.jmodelica.common.evaluation.FailedExternalFunction; 32 34 import org.jmodelica.common.evaluation.ProcessCommunicator; 33 35 … … 49 51 class ModelicaCompiler {} 50 52 51 ModelicaCompiler implements External ProcessMultiCache.Compiler<ExternalArgument, FExternalStmt>;53 ModelicaCompiler implements ExternalFunctionCompiler<ExternalArgument, FExternalStmt>; 52 54 FExternalStmt implements ExternalProcessMultiCache.External<ExternalArgument>; 53 55 ExternalArgument extends ExternalProcessMultiCache.Variable<CValue,FType>; … … 89 91 * Check if this external function should be cached as a live process. 90 92 */ 91 syn boolean FExternalStmt.shouldCacheProcess() { 92 return myOptions().getIntegerOption("external_constant_evaluation_max_proc") > 0; 93 } 93 syn int FExternalStmt.processLimit() = 94 myOptions().external_constant_evaluation_max_proc.getValue(); 95 96 syn boolean FExternalStmt.dynamicEvaluatorEnabled() = 97 myOptions().external_constant_evaluation_dynamic.getValue() 98 && !externalObjectsToSerialize().iterator().hasNext(); 94 99 95 100 /** … … 169 174 ExternalFunctionCache efc = root().getUtilInterface().getExternalFunctionCache(); 170 175 if (efc == null) { 171 return new ExternalProcessCacheImpl<>(root().getUtilInterface().getModelicaCompiler()) 172 .failedEval(this, "external function cache unavailable", false); 176 return FailedExternalFunction.<ExternalArgument, CValue, FType, FExternalStmt>failedEval( 177 root().getUtilInterface().getModelicaCompiler(), 178 this, "external function cache unavailable", false); 173 179 } 174 180 return efc.getExternalProcessCache(getLibTopPackagePath()).getExternalFunction(this); … … 205 211 206 212 if (error != null) { 207 throw new ConstantEvaluationException(null, ExternalProcessCacheImpl.failedEvalMsg(getName(), error));213 throw new ConstantEvaluationException(null, FailedExternalFunction.failedEvalMsg(getName(), error)); 208 214 } 209 215 … … 330 336 } 331 337 public CValue FRealType.deserializeScalar(ProcessCommunicator com) throws IOException { 332 return new CValueReal(com.deserializeReal());338 return CValueReal.valueOf(com.deserializeReal()); 333 339 } 334 340 public CValue FIntegerType.deserializeScalar(ProcessCommunicator com) throws IOException { 335 return new CValueInteger((int) com.deserializeReal());341 return CValueInteger.valueOf((int) com.deserializeReal()); 336 342 } 337 343 public CValue FBooleanType.deserializeScalar(ProcessCommunicator com) throws IOException { 338 return new CValueBoolean(com.deserializeReal() != 0);344 return CValueBoolean.valueOf(com.deserializeReal() != 0); 339 345 } 340 346 public CValue FStringType.deserializeScalar(ProcessCommunicator com) throws IOException { -
branches/dev-5819/Compiler/ModelicaFlatTree/src/jastadd/FlatAPI/FlatAPIAttributes.jrag
r11676 r13800 109 109 syn CValue FVariable.attributeCValueBoolean(String name, boolean def) { 110 110 FAttribute a = findAttribute(name); 111 return (attributeSet(a) ? attributeExp(a).ceval() : new CValueBoolean(def)).expandArray(size());111 return (attributeSet(a) ? attributeExp(a).ceval() : CValueBoolean.valueOf(def)).expandArray(size()); 112 112 } 113 113 syn CValue FVariable.attributeCValueReal(String name, double def) { 114 114 FAttribute a = findAttribute(name); 115 return (attributeSet(a) ? attributeExp(a).ceval() : new CValueReal(def)).expandArray(size());115 return (attributeSet(a) ? attributeExp(a).ceval() : CValueReal.valueOf(def)).expandArray(size()); 116 116 } 117 117 syn CValue FVariable.attributeCValueInteger(String name, int def) { 118 118 FAttribute a = findAttribute(name); 119 return (attributeSet(a) ? attributeExp(a).ceval() : new CValueInteger(def)).expandArray(size());119 return (attributeSet(a) ? attributeExp(a).ceval() : CValueInteger.valueOf(def)).expandArray(size()); 120 120 } 121 121 syn CValue FVariable.attributeCValueEnum(String name, FType type, int def) { … … 200 200 syn CValue FVariable.startAttributeCValue() = CValue.UNKNOWN; 201 201 eq FRealVariable.startAttributeCValue() = attributeCValueReal(FAttribute.START, 0.0); 202 eq FDerivativeVariable.startAttributeCValue() = new CValueReal(0.0);202 eq FDerivativeVariable.startAttributeCValue() = CValueReal.valueOf(0.0); 203 203 eq FIntegerVariable.startAttributeCValue() = attributeCValueInteger(FAttribute.START, 0); 204 204 eq FBooleanVariable.startAttributeCValue() = attributeCValueBoolean(FAttribute.START, false); -
branches/dev-5819/Compiler/ModelicaFrontEnd/src/jastadd/flattening/Flattening.jrag
r13651 r13800 2459 2459 int i = 0; 2460 2460 for (CommonForIndex fi : forIndices) { 2461 fi.setEvaluationValue( new CValueInteger(index[i++]));2461 fi.setEvaluationValue(CValueInteger.valueOf(index[i++])); 2462 2462 } 2463 2463 } -
branches/dev-5819/Compiler/ModelicaFrontEnd/src/jastadd/flattening/connections/Connections.jrag
r13600 r13800 1392 1392 int[] ii = indices.translate(i).index(); 1393 1393 for (InstForIndex fi : getInstForIndexs()) { 1394 fi.getInstPrimitive().setLocalCachedEvaluationValue( new CValueInteger(ii[j]));1394 fi.getInstPrimitive().setLocalCachedEvaluationValue(CValueInteger.valueOf(ii[j])); 1395 1395 j++; 1396 1396 } -
branches/dev-5819/Compiler/ModelicaFrontEnd/src/jastadd/flattening/connections/ExpandableConnectors.jrag
r13224 r13800 1059 1059 CValue val = ceval(); 1060 1060 if (ndims() > 0) 1061 val = val.reduce(INT_MAX_OP, new CValueInteger(1));1061 val = val.reduce(INT_MAX_OP, CValueInteger.valueOf(1)); 1062 1062 s.set(i, val.intValue()); 1063 1063 return ndims() == 0 || size().get(0) == len; -
branches/dev-5819/Compiler/ModelicaFrontEnd/src/jastadd/instance/InstLookupClasses.jrag
r13600 r13800 261 261 HashMap<String,SrcLibNode> map = new HashMap<String,SrcLibNode>(prog.getNumSrcLibNode() * 4 / 3 + 1); 262 262 for (SrcLibNode ln : prog.getSrcLibNodes()) { 263 if (!map.containsKey(ln.name())) { 264 map.put(ln.name(), ln); 263 String name = ln.name().toLowerCase(); 264 if (!map.containsKey(name)) { 265 map.put(name, ln); 265 266 } 266 267 } … … 269 270 270 271 syn lazy InstLookupResult<InstClassDecl> InstProgramRoot.lookupLibrary(String name) { 271 SrcLibNode ln = libraryMap().get(name );272 SrcLibNode ln = libraryMap().get(name.toLowerCase()); 272 273 if (ln != null) { 273 274 InstClassDecl icd = createInstClassDecl(ln); -
branches/dev-5819/Compiler/ModelicaFrontEnd/src/jastadd/source/SimpleLookup.jrag
r13600 r13800 87 87 * Lookup the class referenced by the QualifiedName. 88 88 * Lookup is both uncached and only among the class members and imported. 89 * This method is intended as a entry point89 * This method is intended as an entry point 90 90 */ 91 91 public SrcClassDecl SrcClassDecl.LookupMyMembers(QualifiedName qName) { … … 105 105 * Lookup the class referenced by the QualifiedName. The QualifiedName 106 106 * determines if the lookup is in relative or global scope. 107 * This method is intended as a entry point107 * This method is intended as an entry point 108 108 * 109 109 */ … … 161 161 public abstract class ResolvedAccess { 162 162 163 private SrcClassDecl classDecl;164 private SrcComponentDecl componentDecl;165 private String context;166 private boolean isProtected;163 private final SrcClassDecl classDecl; 164 private final SrcComponentDecl componentDecl; 165 private final String context; 166 private final boolean isProtected; 167 167 168 168 public ResolvedAccess(SrcClassDecl classDecl, SrcComponentDecl componentDecl, String context, boolean isProtected) { -
branches/dev-5819/Compiler/ModelicaFrontEnd/src/jastadd/util/Util.jrag
r13600 r13800 1584 1584 1585 1585 syn boolean SrcBaseNode.isLibNode() = false; 1586 eq SrcLibNode.isLibNode() = true; 1586 eq SrcLibNode.isLibNode() = true; 1587 syn SrcLibNode SrcBaseNode.asSrcLibNode() { 1588 throw new UnsupportedOperationException(); 1589 } 1590 syn SrcLibNode SrcLibNode.asSrcLibNode() = this; 1587 1591 } 1588 1592 -
branches/dev-5819/Compiler/ModelicaFrontEnd/src/java/org/jmodelica/common/GUIDManager.java
r13600 r13800 2 2 3 3 import java.io.BufferedReader; 4 import java.io.B ufferedWriter;4 import java.io.ByteArrayInputStream; 5 5 import java.io.ByteArrayOutputStream; 6 6 import java.io.File; 7 import java.io.FileNotFoundException;8 import java.io.FileReader;9 import java.io.FileWriter;10 7 import java.io.IOException; 11 import java.io. OutputStreamWriter;12 import java.io. Reader;13 import java.io. StringReader;14 import java.io. Writer;8 import java.io.InputStream; 9 import java.io.InputStreamReader; 10 import java.io.OutputStream; 11 import java.io.PrintWriter; 15 12 import java.math.BigInteger; 16 13 import java.nio.charset.Charset; 14 import java.nio.file.Files; 15 import java.nio.file.Path; 17 16 import java.security.MessageDigest; 18 17 import java.security.NoSuchAlgorithmException; … … 65 64 66 65 public void setSourceFile(File source) { 66 this.source = new FileOpenable(source.toPath()); 67 } 68 69 public void setSourceFile(Path source) { 67 70 this.source = new FileOpenable(source); 68 71 } … … 73 76 74 77 public void addDependentFile(File dependentFile) { 78 dependentFiles.add(new FileOpenable(dependentFile.toPath())); 79 } 80 81 public void addDependentFile(Path dependentFile) { 75 82 dependentFiles.add(new FileOpenable(dependentFile)); 76 83 } 77 84 78 public void addDependentString(String input, StringBuilderoutput) {85 public void addDependentString(String input, ByteArrayOutputStream output) { 79 86 dependentFiles.add(new StringOpenable(input, output)); 80 87 } … … 85 92 final MessageDigest md5 = MessageDigest.getInstance("MD5"); 86 93 87 try (final BufferedReader reader = new BufferedReader( source.openInput())) {94 try (final BufferedReader reader = new BufferedReader(new InputStreamReader(source.openInput()))) { 88 95 String line = reader.readLine(); 89 96 while (line != null) { … … 118 125 for (final Openable openable : dependentFiles) { 119 126 try { 120 ByteArrayOutputStream os = new ByteArrayOutputStream(); 121 try (final Writer tmp = new OutputStreamWriter(os)) { 122 processFiles(openable.openInput(), tmp); 123 } 124 125 try (BufferedWriter writer = new BufferedWriter(openable.openOutput())) { 126 writer.append(os.toString()); 127 try (ByteArrayOutputStream os = new ByteArrayOutputStream()) { 128 processFiles(openable.openInput(), os); 129 try (PrintWriter writer = new PrintWriter(openable.openOutput())) { 130 writer.append(os.toString()); 131 } 127 132 } 128 133 } catch (IOException e) { … … 132 137 } 133 138 134 private void processFiles( Reader source, Writerdestination) throws IOException {135 try (final BufferedReader reader = new BufferedReader( source);136 final BufferedWriter writer = new BufferedWriter(destination)) {139 private void processFiles(InputStream source, OutputStream destination) throws IOException { 140 try (final BufferedReader reader = new BufferedReader(new InputStreamReader(source)); 141 final PrintWriter writer = new PrintWriter(destination)) { 137 142 138 143 String line = reader.readLine(); … … 200 205 201 206 private static interface Openable { 202 public ReaderopenInput();203 public WriteropenOutput();207 public InputStream openInput(); 208 public OutputStream openOutput(); 204 209 } 205 210 206 private static class FileOpenable implements Openable {207 private File file;208 209 public FileOpenable( Filefile) {210 this. file= file;211 } 212 213 @Override 214 public ReaderopenInput() {211 private static class FileOpenable implements Openable { 212 private Path path; 213 214 public FileOpenable(Path file) { 215 this.path = file; 216 } 217 218 @Override 219 public InputStream openInput() { 215 220 try { 216 return new FileReader(file); 217 } catch (FileNotFoundException e) { 218 throw new RuntimeException(e); 219 } 220 } 221 222 @Override 223 public Writer openOutput() { 224 try { 225 return new FileWriter(file); 221 return Files.newInputStream(path); 226 222 } catch (IOException e) { 227 223 throw new RuntimeException(e); … … 230 226 231 227 @Override 228 public OutputStream openOutput() { 229 try { 230 return Files.newOutputStream(path); 231 } catch (IOException e) { 232 throw new RuntimeException(e); 233 } 234 } 235 236 @Override 232 237 public String toString() { 233 return file.toString();238 return path.toString(); 234 239 } 235 240 } … … 238 243 239 244 private String input; 240 private StringBuilderoutput;241 242 public StringOpenable(String input, StringBuilderoutput) {245 private ByteArrayOutputStream output; 246 247 public StringOpenable(String input, ByteArrayOutputStream output) { 243 248 this.input = input; 244 249 this.output = output; … … 246 251 247 252 @Override 248 public Reader openInput() { 249 return new StringReader(input); 250 } 251 252 @Override 253 public Writer openOutput() { 254 return new Writer() { 255 256 @Override 257 public void write(char[] cbuf, int off, int len) throws IOException { 258 output.append(cbuf, off, len); 259 } 260 261 @Override 262 public void flush() throws IOException { 263 // Do nothing 264 } 265 266 @Override 267 public void close() throws IOException { 268 // Do nothing 269 } 270 }; 253 public InputStream openInput() { 254 return new ByteArrayInputStream(input.getBytes()); 255 } 256 257 @Override 258 public OutputStream openOutput() { 259 return output; 271 260 } 272 261 } -
branches/dev-5819/Compiler/ModelicaFrontEnd/src/java/org/jmodelica/common/evaluation/ExternalProcessCache.java
r10910 r13800 24 24 25 25 protected abstract void tearDown(); 26 27 public abstract ExternalFunction<K, V> failedEval(External<?> ext, String msg, boolean log);28 26 29 27 -
branches/dev-5819/Compiler/ModelicaFrontEnd/src/java/org/jmodelica/common/evaluation/ExternalProcessCacheImpl.java
r12940 r13800 3 3 import java.io.File; 4 4 import java.io.FileNotFoundException; 5 import java.io.IOException;6 5 import java.io.PrintStream; 7 6 import java.util.ArrayList; 7 import java.util.Arrays; 8 import java.util.Collection; 8 9 import java.util.HashMap; 10 import java.util.HashSet; 9 11 import java.util.LinkedHashSet; 10 12 import java.util.Map; 11 12 import org.jmodelica.common.evaluation.ExternalProcessMultiCache.Compiler; 13 import java.util.Set; 14 13 15 import org.jmodelica.common.evaluation.ExternalProcessMultiCache.External; 14 16 import org.jmodelica.common.evaluation.ExternalProcessMultiCache.Type; … … 16 18 import org.jmodelica.common.evaluation.ExternalProcessMultiCache.Variable; 17 19 import org.jmodelica.util.EnvironmentUtils; 20 import org.jmodelica.util.SystemUtil; 18 21 import org.jmodelica.util.ccompiler.CCompilerDelegator; 19 22 import org.jmodelica.util.exceptions.CcodeCompilationException; 20 23 import org.jmodelica.util.logging.ModelicaLogger; 21 import org.jmodelica.util.values.ConstantEvaluationException;22 24 23 25 public class ExternalProcessCacheImpl<K extends Variable<V, T>, V extends Value, T extends Type<V>, E extends External<K>> extends ExternalProcessCache<K, V, T, E> { … … 26 28 * Maps external functions names to compiled executables. 27 29 */ 28 private Map<String, ExternalFunction<K, V>> cachedExternals = new HashMap<String, ExternalFunction<K, V>>();30 private final Map<String, ExternalFunction<K, V>> cachedExternals = new HashMap<String, ExternalFunction<K, V>>(); 29 31 30 32 /** 31 33 * Keeps track of all living processes, least recently used first. 32 34 */ 33 private LinkedHashSet<ExternalFunction<K, V>> livingCachedExternals = new LinkedHashSet<ExternalFunction<K, V>>();34 35 private Compiler<K, E> mc;36 37 public ExternalProcessCacheImpl( Compiler<K, E> mc) {35 private final LinkedHashSet<ExternalFunction<K, V>> livingCachedExternals = new LinkedHashSet<ExternalFunction<K, V>>(); 36 37 private final ExternalFunctionCompiler<K, E> mc; 38 39 public ExternalProcessCacheImpl(ExternalFunctionCompiler<K, E> mc) { 38 40 this.mc = mc; 39 41 } … … 42 44 return mc.log(); 43 45 } 44 46 47 private String getPlatform() { 48 return CCompilerDelegator.reduceBits(EnvironmentUtils.getJavaPlatform(), 49 mc.getCCompiler().getTargetPlatforms()); 50 } 51 52 private String getSharedLibrary(External<K> ext) { 53 String sharedLib = ""; 54 String extLibrary = ""; 55 56 if (ext.library() != null && ext.library().length == 1) { 57 extLibrary = ext.library()[0]; 58 } else { 59 return sharedLib; 60 } 61 62 HashSet<String> externalLibraryDirectories = new HashSet<String>(); 63 externalLibraryDirectories.add(ext.libraryDirectory()); 64 Set<String> expandedLibDirs = mc.getCCompiler().expandCompilerSpecificLibraryPaths(mc.log(), ext.myOptions(), 65 externalLibraryDirectories, getPlatform()); 66 67 for (String dir : expandedLibDirs) { 68 File testlib1 = new File(dir, extLibrary + SystemUtil.sharedLibraryExtension()); 69 File testlib2 = new File(dir, "lib" + extLibrary + SystemUtil.sharedLibraryExtension()); 70 71 if (testlib1.exists() && !testlib1.isDirectory()) { 72 sharedLib = testlib1.toString(); 73 break; 74 } 75 if (testlib2.exists() && !testlib2.isDirectory()) { 76 sharedLib = testlib2.toString(); 77 break; 78 } 79 } 80 81 return sharedLib; 82 } 83 84 private static Collection<String> builtinExternalFunctions = Arrays.asList( 85 "ModelicaStrings_substring", 86 "ModelicaStrings_length", 87 "ModelicaStrings_skipWhiteSpace", 88 "ModelicaStrings_compare" 89 ); 90 91 private static Collection<String> supportedSignatures = Arrays.asList( 92 "d+d,d,", 93 "d+i,", 94 "d+i,d,d,", 95 "s+s,i,i,", 96 "i+s,", 97 "i+s,i,", 98 "i+s,s,i,", 99 "i+i,i,", 100 "void+i,d,d,*R[d,d,d,d,d,d,d,d,d,d,d,],", 101 "void+d,d,*d," 102 ); 103 104 public boolean canUseEvaluator(E ext, ArrayList<String> arguments) { 105 if (!ext.dynamicEvaluatorEnabled()) { 106 return false; 107 } 108 109 String sharedLibrary = getSharedLibrary(ext); 110 String functionName = ext.getName(); 111 String outputArguments = ext.functionReturnArgSerialized(); 112 String inputArguments = ext.functionArgsSerialized(); 113 114 if (sharedLibrary.equals("")) { 115 if (builtinExternalFunctions.contains(functionName)) { 116 sharedLibrary = "NoSharedLibrary"; 117 } else { 118 mc.log().debug("Could not find a shared library containing '" + functionName + "'. Disabling use of the evaluator..."); 119 return false; 120 } 121 } 122 123 if (!supportedSignatures.contains(outputArguments+"+"+inputArguments)) { 124 mc.log().debug("The function signature, outputs '" + outputArguments + "', inputs '" + inputArguments + "', is not supported. Disabling use of the evaluator..."); 125 return false; 126 } 127 128 arguments.add(sharedLibrary); 129 arguments.add(functionName); 130 arguments.add(outputArguments); 131 arguments.add(inputArguments); 132 133 return true; 134 } 135 45 136 @Override 46 137 public ExternalFunction<K, V> getExternalFunction(E ext) { … … 48 139 if (ef == null) { 49 140 if (mc == null) { 50 return failedEval(ext, "Missing ModelicaCompiler", false);141 return FailedExternalFunction.<K,V,T,E>failedEval(mc, ext, "Missing ModelicaCompiler", false); 51 142 } 52 143 try { 53 144 long time = System.currentTimeMillis(); 54 String executable = mc.compileExternal(ext); 55 if (ext.shouldCacheProcess()) { 56 ef = new MappedExternalFunction(ext, executable); 145 String executable = null; 146 ArrayList<String> arguments = new ArrayList<String>(); 147 String debugMsg = ""; 148 ExternalFunctionExecutable extFunctionExecutable; 149 if (canUseEvaluator(ext, arguments)) { 150 String jmHome = System.getenv("JMODELICA_HOME"); 151 String bits = getPlatform().contains("64") && SystemUtil.isWindows() ? "64" : ""; 152 executable = jmHome + File.separator + "bin" + bits + File.separator + "jmi_evaluator" + SystemUtil.executableExtension(); 153 154 arguments.add(0, executable); /* Needs to be first */ 155 156 extFunctionExecutable = new ExternalFunctionExecutableDynamic(arguments); 157 158 debugMsg = "Succesfully connected external function '" + ext.getName() + "' to the evaluator '" 159 + executable + "' with outputs: '" + ext.functionReturnArgSerialized() + "' and inputs: '" + ext.functionArgsSerialized() + "'"; 57 160 } else { 58 ef = new CompiledExternalFunction(ext, executable); 161 executable = mc.compileExternal(ext); 162 163 extFunctionExecutable = new ExternalFunctionExecutableGenerated(executable); 164 165 debugMsg = "Succesfully compiled external function '" + ext.getName() + "' to executable '" 166 + executable + "' code for evaluation"; 167 } 168 169 if (ext.processLimit() > 0) { 170 ef = new MappedExternalFunction<K,V,T,E>(mc, ext, extFunctionExecutable, livingCachedExternals); 171 } else { 172 ef = new ExternalFunctionImpl<K,V,T,E>(mc, ext, extFunctionExecutable); 59 173 } 60 174 time = System.currentTimeMillis() - time; 61 mc.log().debug("Succesfully compiled external function '" + ext.getName() + "' to executable '" 62 + executable + "' code for evaluation, time: " + time + "ms"); 175 mc.log().debug(debugMsg +", time: " + time + "ms"); 63 176 } catch (FileNotFoundException e) { 64 ef = failedEval(ext, "c-code generation failed '" + e.getMessage() + "'", true);177 ef = FailedExternalFunction.<K,V,T,E>failedEval(mc, ext, "c-code generation failed '" + e.getMessage() + "'", true); 65 178 mc.log().debug(ef.getMessage()); 66 179 } catch (CcodeCompilationException e) { 67 ef = failedEval(ext, "c-code compilation failed '" + e.getMessage() + "'", true);180 ef = FailedExternalFunction.<K,V,T,E>failedEval(mc, ext, "c-code compilation failed '" + e.getMessage() + "'", true); 68 181 mc.log().debug(ef.getMessage()); 69 182 e.printStackTrace(new PrintStream(mc.log().debugStream())); … … 95 208 } 96 209 97 @Override98 public ExternalFunction<K, V> failedEval(External<?> ext, String msg, boolean log) {99 return new FailedExternalFunction(failedEvalMsg(ext.getName(), msg), log);100 }101 102 public static String failedEvalMsg(String name, String msg) {103 return "Failed to evaluate external function '" + name + "', " + msg;104 }105 106 private class FailedExternalFunction implements ExternalFunction<K, V> {107 private String msg;108 private boolean log;109 110 public FailedExternalFunction(String msg, boolean log) {111 this.msg = msg;112 this.log = log;113 }114 115 @Override116 public String getMessage() {117 return msg;118 }119 120 @Override121 public int evaluate(External<K> ext, Map<K, V> values, int timeout) throws IOException {122 if (log) {123 log().debug("Evaluating failed external function: " + ext.getName());124 }125 throw new ConstantEvaluationException(null, getMessage());126 }127 128 @Override129 public void destroyProcess() {130 // Do nothing131 }132 133 @Override134 public void remove() {135 // Do nothing136 }137 }138 139 /**140 * Represents an external function that has been compiled successfully.141 */142 private class CompiledExternalFunction implements ExternalFunction<K, V> {143 protected String executable;144 protected ProcessBuilder processBuilder;145 private String msg;146 147 public CompiledExternalFunction(External<K> ext, String executable) {148 this.executable = executable;149 this.processBuilder = createProcessBuilder(ext);150 this.msg = "Succesfully compiled external function '" + ext.getName() + "'";151 }152 153 @Override154 public String getMessage() {155 return msg;156 }157 158 protected ProcessCommunicator<V, T> createProcessCommunicator() throws IOException {159 return new ProcessCommunicator<V, T>(mc, processBuilder.start());160 }161 162 @Override163 public int evaluate(External<K> ext, Map<K, V> values, int timeout) throws IOException {164 log().debug("Evaluating compiled external function: " + ext.getName());165 ProcessCommunicator<V, T> com = null;166 try {167 com = createProcessCommunicator();168 setup(ext, values, timeout, com);169 evaluate(ext, values, timeout, com);170 return teardown(timeout, com);171 } finally {172 if (com != null) {173 com.destroy();174 }175 }176 }177 178 public void setup(External<K> ext, Map<K, V> values, int timeout, ProcessCommunicator<V, T> com)179 throws IOException {180 com.startTimer(timeout);181 com.accept("START");182 for (K eo : ext.externalObjectsToSerialize()) {183 com.put(values.containsKey(eo) ? values.get(eo) : eo.ceval(), eo.type());184 }185 com.accept("READY");186 com.cancelTimer();187 }188 189 public void evaluate(External<K> ext, Map<K, V> values, int timeout, ProcessCommunicator<V, T> com)190 throws IOException {191 com.startTimer(timeout);192 com.check("EVAL");193 194 for (K arg : ext.functionArgsToSerialize()) {195 com.put(values.containsKey(arg) ? values.get(arg) : arg.ceval(), arg.type());196 }197 com.accept("CALC");198 com.accept("DONE");199 for (K cvd : ext.varsToDeserialize())200 values.put(cvd, com.get(cvd.type()));201 com.accept("READY");202 com.cancelTimer();203 }204 205 public int teardown(int timeout, ProcessCommunicator<V, T> com) throws IOException {206 com.startTimer(timeout);207 com.check("EXIT");208 com.accept("END");209 int result = com.end();210 com.cancelTimer();211 // log().debug("SUCCESS TEARDOWN");212 return result;213 }214 215 @Override216 public void destroyProcess() {217 // Do nothing218 }219 220 @Override221 public void remove() {222 new File(executable).delete();223 }224 225 private ProcessBuilder createProcessBuilder(External<K> ext) {226 ProcessBuilder pb = new ProcessBuilder(executable);227 Map<String, String> env = pb.environment();228 if (env.keySet().contains("Path")) {229 env.put("PATH", env.get("Path"));230 env.remove("Path");231 }232 pb.redirectErrorStream(true);233 if (ext.libraryDirectory() != null) {234 // Update environment in case of shared library235 String platform = CCompilerDelegator.reduceBits(EnvironmentUtils.getJavaPlatform(),236 mc.getCCompiler().getTargetPlatforms());237 File f = new File(ext.libraryDirectory(), platform);238 String libLoc = f.isDirectory() ? f.getPath() : ext.libraryDirectory();239 appendPath(env, libLoc, platform);240 }241 return pb;242 }243 244 /**245 * Append a library location <code>libLoc</code> to the path variable in246 * environment <code>env</code>.247 */248 private void appendPath(Map<String, String> env, String libLoc, String platform) {249 String sep = platform.startsWith("win") ? ";" : ":";250 String var = platform.startsWith("win") ? "PATH" : "LD_LIBRARY_PATH";251 String res = env.get(var);252 if (res == null)253 res = libLoc;254 else255 res = res + sep + libLoc;256 env.put(var, res);257 }258 }259 260 /**261 * A CompiledExternalFunction which can cache several processes with external262 * object constructor only called once.263 */264 private class MappedExternalFunction extends CompiledExternalFunction {265 266 private Map<String, ExternalFunction<K, V>> lives = new HashMap<>();267 268 private final int externalConstantEvaluationMaxProc;269 270 public MappedExternalFunction(External<K> ext, String executable) {271 super(ext, executable);272 externalConstantEvaluationMaxProc = ext.myOptions()273 .getIntegerOption("external_constant_evaluation_max_proc");274 }275 276 /**277 * Find a LiveExternalFunction based on the external object of this external278 * function. Start a new process if not up already. Failure to set up (call279 * constructor) will cache and return a Failed external function.280 */281 private ExternalFunction<K, V> getActual(External<K> ext, Map<K, V> values, int timeout) {282 Variable<V, T> cvd = ext.cachedExternalObject();283 String name = cvd == null ? "" : cvd.ceval().getMarkedExternalObject();284 ExternalFunction<K, V> ef = lives.get(name);285 if (ef == null) {286 LiveExternalFunction lef = new LiveExternalFunction();287 try {288 lef.ready(ext, values, timeout);289 ef = lef;290 } catch (IOException e) {291 lef.destroyProcess();292 ef = failedEval(ext, " error starting process '" + e.getMessage() + "'", true);293 } catch (ConstantEvaluationException e) {294 lef.destroyProcess();295 ef = failedEval(ext, " error starting process '" + e.getMessage() + "'", true);296 }297 lives.put(name, ef);298 }299 return ef;300 }301 302 @Override303 public int evaluate(External<K> ext, Map<K, V> values, int timeout) throws IOException {304 return getActual(ext, values, timeout).evaluate(ext, values, timeout);305 }306 307 @Override308 public void destroyProcess() {309 for (ExternalFunction<K, V> ef : lives.values()) {310 ef.destroyProcess();311 }312 lives.clear();313 }314 315 /**316 * Represents a (possible) living external function process.317 */318 private class LiveExternalFunction implements ExternalFunction<K, V> {319 320 protected ProcessCommunicator<V, T> com;321 322 public LiveExternalFunction() {323 super();324 }325 326 @Override327 public String getMessage() {328 return MappedExternalFunction.this.getMessage();329 }330 331 @Override332 public int evaluate(External<K> ext, Map<K, V> values, int timeout) throws IOException {333 log().debug("Evaluating live external function: " + ext.getName());334 try {335 ready(ext, values, timeout);336 long time = System.currentTimeMillis();337 MappedExternalFunction.this.evaluate(ext, values, timeout, com);338 time = System.currentTimeMillis() - time;339 log().debug("Finished evaluating live external function, time: " + time + "ms");340 } catch (ProcessCommunicator.AbortConstantEvaluationException e) {341 342 } catch (ConstantEvaluationException e) {343 destroyProcess();344 throw e;345 } catch (IOException e) {346 destroyProcess();347 throw e;348 }349 return 0;350 }351 352 /**353 * Make sure process is ready for evaluation call.354 */355 protected void ready(External<K> ext, Map<K, V> values, int timeout) throws IOException {356 if (com == null) {357 long time1 = System.currentTimeMillis();358 // Start process if not live.359 com = createProcessCommunicator();360 long time2 = System.currentTimeMillis();361 // Send external object constructor inputs362 MappedExternalFunction.this.setup(ext, values, timeout, com);363 long time3 = System.currentTimeMillis();364 log().debug("Setup live external function: " + ext.getName()365 + ", createProcessCommunicator() time: " + (time2 - time1)366 + "ms, setup time: " + (time3 - time2) + "ms");367 }368 369 // Mark as most recently used370 livingCachedExternals.remove(this);371 livingCachedExternals.add(this);372 373 // If we are over the allowed number of cached processes374 // we kill the least recently used.375 if (livingCachedExternals.size() > externalConstantEvaluationMaxProc) {376 livingCachedExternals.iterator().next().destroyProcess();377 }378 }379 380 @Override381 public void destroyProcess() {382 if (com != null) {383 livingCachedExternals.remove(this);384 com.destroy();385 com = null;386 }387 }388 389 @Override390 public void remove() {391 // Removing this executable is handled by surrounding MappedExternalFunction392 throw new UnsupportedOperationException();393 }394 }395 }396 210 } -
branches/dev-5819/Compiler/ModelicaFrontEnd/src/java/org/jmodelica/common/evaluation/ExternalProcessMultiCache.java
r13252 r13800 2 2 3 3 import java.io.BufferedWriter; 4 import java.io.FileNotFoundException;5 4 import java.io.IOException; 6 5 import java.util.LinkedHashMap; 7 6 import java.util.Map; 8 7 9 import org.jmodelica.common.LogContainer;10 8 import org.jmodelica.common.options.AbstractOptionRegistry; 11 import org.jmodelica.util.ccompiler.CCompilerDelegator;12 import org.jmodelica.util.exceptions.CcodeCompilationException;13 9 14 10 public class ExternalProcessMultiCache<K extends ExternalProcessMultiCache.Variable<V, T>, V extends ExternalProcessMultiCache.Value, T extends ExternalProcessMultiCache.Type<V>, E extends ExternalProcessMultiCache.External<K>> { 15 16 public interface Compiler<K, E extends External<K>> extends LogContainer {17 public String compileExternal(E ext) throws FileNotFoundException, CcodeCompilationException;18 19 public CCompilerDelegator getCCompiler();20 }21 11 22 12 public interface External<K> { 23 13 public String getName(); 24 14 25 public boolean shouldCacheProcess(); 15 public int processLimit(); 16 17 public boolean dynamicEvaluatorEnabled(); 26 18 27 19 public AbstractOptionRegistry myOptions(); … … 35 27 public Iterable<K> functionArgsToSerialize(); 36 28 29 public String functionArgsSerialized(); 30 31 public String functionReturnArgSerialized(); 32 37 33 public Iterable<K> varsToDeserialize(); 34 35 public String[] library(); 38 36 } 39 37 … … 56 54 private Map<String, ExternalProcessCache<K, V, T, E>> map = new LinkedHashMap<>(); 57 55 58 private Compiler<K, E> mc;56 private ExternalFunctionCompiler<K, E> mc; 59 57 60 public ExternalProcessMultiCache( Compiler<K, E> mc) {58 public ExternalProcessMultiCache(ExternalFunctionCompiler<K, E> mc) { 61 59 this.mc = mc; 62 60 } -
branches/dev-5819/Compiler/ModelicaFrontEnd/src/java/org/jmodelica/common/options/AbstractOptionRegistry.java
r13252 r13800 40 40 * to get an option registry populated with all available options. 41 41 */ 42 @SuppressWarnings("javadoc") 42 43 public abstract class AbstractOptionRegistry { 43 44 -
branches/dev-5819/Compiler/ModelicaFrontEnd/src/java/org/jmodelica/separateProcess/CompilerInstance.java
r13600 r13800 274 274 * {@link org.jmodelica.modelica.compiler.ModelicaCompiler ModelicaCompiler}. 275 275 */ 276 @SuppressWarnings("javadoc") 276 277 MODELICA("org.jmodelica.modelica.compiler.ModelicaCompiler"), 277 278 … … 279 280 * {@link org.jmodelica.optimica.compiler.OptimicaCompiler OptimicaCompiler}. 280 281 */ 282 @SuppressWarnings("javadoc") 281 283 OPTIMICA("org.jmodelica.optimica.compiler.OptimicaCompiler"); 282 284 -
branches/dev-5819/Compiler/ModelicaFrontEnd/src/java/org/jmodelica/util/MemorySpider.java
r12940 r13800 145 145 private Field field; 146 146 147 public Object perform(Field f, Object o) { 147 @SuppressWarnings("deprecation") 148 public Object perform(Field f, Object o) { 148 149 field = f; 149 150 if (!f.isAccessible()) -
branches/dev-5819/Compiler/ModelicaFrontEnd/src/java/org/jmodelica/util/SystemUtil.java
r11394 r13800 72 72 return isLinux() ? "" : ".exe"; 73 73 } 74 75 public static String sharedLibraryExtension() { 76 if (isWindows()) { 77 return ".dll"; 78 } else if (isLinux()) { 79 return ".so"; 80 } else { 81 return ".dylib"; 82 } 83 } 74 84 75 85 /** -
branches/dev-5819/Compiler/ModelicaFrontEnd/src/java/org/jmodelica/util/files/FileUtil.java
r11394 r13800 3 3 import java.io.File; 4 4 import java.io.IOException; 5 import java.nio.file.DirectoryStream; 5 6 import java.nio.file.Files; 7 import java.nio.file.Path; 6 8 import java.nio.file.Paths; 7 9 import java.nio.file.StandardCopyOption; … … 155 157 return names; 156 158 } 159 160 /** 161 * @return A collection of all files in {@code dir} matching the {@code glob} 162 * pattern 163 */ 164 public static Collection<Path> getMatching(Path dir, String glob) throws IOException { 165 Collection<Path> res = new ArrayList<>(); 166 try (DirectoryStream<Path> stream = Files.newDirectoryStream(dir, glob)) { 167 for (Path path : stream) { 168 res.add(path); 169 } 170 } 171 return res; 172 } 157 173 158 174 /** … … 234 250 * if there was any error copying the files. 235 251 */ 236 public static void copyRecursive( Collection<File> files, File destination, boolean replace) throws IOException {252 public static void copyRecursive(Iterable<File> files, File destination, boolean replace) throws IOException { 237 253 for (File file : files) { 238 254 copyRecursive(file, destination, replace); 255 } 256 } 257 258 /** 259 * Copies file to a directory. Contents of directories is copied recursively. 260 * 261 * @param sourceFile 262 * The file to copy. 263 * @param destDir 264 * The destination directory. 265 * @throws IOException 266 * if there was any error copying the files. 267 */ 268 public static void copyRecursive(Path sourceFile, Path destDir) throws IOException { 269 Path outFile = destDir.resolve(sourceFile.getFileName()); 270 if (Files.isDirectory(sourceFile)) { 271 if (!Files.exists(outFile)) { 272 Files.createDirectory(outFile); 273 } 274 try (DirectoryStream<Path> stream = Files.newDirectoryStream(sourceFile)) { 275 copyRecursive(stream, outFile); 276 } 277 } else { 278 Files.copy(sourceFile, outFile, StandardCopyOption.REPLACE_EXISTING); 279 } 280 } 281 282 /** 283 * Copies several files to a directory. 284 * 285 * @param sourceFiles 286 * The files to copy. 287 * @param destDir 288 * The destination directory. 289 * @throws IOException 290 * if there was any error copying the files. 291 */ 292 public static void copyRecursive(Iterable<Path> sourceFiles, Path destDir) throws IOException { 293 for (Path file : sourceFiles) { 294 copyRecursive(file, destDir); 239 295 } 240 296 } -
branches/dev-5819/Compiler/ModelicaFrontEnd/src/java/org/jmodelica/util/logging/PipeLogger.java
r12984 r13800 72 72 } 73 73 74 @SuppressWarnings("deprecation") 74 75 @Override 75 76 protected void finalize() throws Throwable { -
branches/dev-5819/Compiler/ModelicaFrontEnd/test/junit/org/jmodelica/test/common/ExternalProcessCacheTest.java
r13274 r13800 9 9 import java.io.IOException; 10 10 11 import org.jmodelica.common.evaluation.ExternalFunctionCompiler; 12 import org.jmodelica.common.evaluation.ExternalFunction; 11 13 import org.jmodelica.common.evaluation.ExternalProcessCache; 12 import org.jmodelica.common.evaluation.ExternalFunction;13 14 import org.jmodelica.common.evaluation.ExternalProcessMultiCache; 15 import org.jmodelica.common.evaluation.ExternalProcessMultiCache.External; 16 import org.jmodelica.common.evaluation.ExternalProcessMultiCache.Type; 17 import org.jmodelica.common.evaluation.ExternalProcessMultiCache.Value; 14 18 import org.jmodelica.common.evaluation.ExternalProcessMultiCache.Variable; 19 import org.jmodelica.common.evaluation.ProcessCommunicator; 15 20 import org.jmodelica.common.options.AbstractOptionRegistry; 16 import org.jmodelica.common.evaluation.ExternalProcessMultiCache.Value;17 import org.jmodelica.common.evaluation.ExternalProcessMultiCache.Type;18 import org.jmodelica.common.evaluation.ExternalProcessMultiCache.External;19 import org.jmodelica.common.evaluation.ProcessCommunicator;20 21 import org.jmodelica.util.ccompiler.CCompilerDelegator; 21 22 import org.jmodelica.util.exceptions.CcodeCompilationException; … … 74 75 class ExternalProcessCacheMock<K extends Variable<V,T>, V extends Value, T extends Type<V>, E extends External<K>> extends ExternalProcessMultiCache<K,V,T,E> { 75 76 76 public ExternalProcessCacheMock( Compiler<K,E> mc) {77 public ExternalProcessCacheMock(ExternalFunctionCompiler<K,E> mc) { 77 78 super(mc); 78 79 } … … 108 109 } 109 110 110 @Override 111 public ExternalFunction<K,V> failedEval(External<?> ext, String msg, boolean log) { 112 // TODO Auto-generated method stub 113 return null; 114 } 115 116 } 117 118 class CompilerMock implements ExternalProcessMultiCache.Compiler<VariableMock, ExternalMock> { 111 } 112 113 class CompilerMock implements ExternalFunctionCompiler<VariableMock, ExternalMock> { 119 114 120 115 @Override … … 189 184 190 185 @Override 191 public boolean shouldCacheProcess() { 192 // TODO Auto-generated method stub 186 public int processLimit() { 187 // TODO Auto-generated method stub 188 return 0; 189 } 190 191 @Override 192 public boolean dynamicEvaluatorEnabled() { 193 193 return false; 194 194 } … … 223 223 return null; 224 224 } 225 226 @Override 227 public String functionArgsSerialized() { 228 // TODO Auto-generated method stub 229 return null; 230 } 231 232 @Override 233 public String functionReturnArgSerialized() { 234 // TODO Auto-generated method stub 235 return null; 236 } 225 237 226 238 @Override … … 229 241 return null; 230 242 } 243 244 @Override 245 public String[] library() { 246 // TODO Auto-generated method stub 247 return null; 248 } 231 249 232 250 } -
branches/dev-5819/Compiler/ModelicaFrontEnd/test/junit/org/jmodelica/test/common/GUIDManagerTest.java
r13600 r13800 4 4 import static org.junit.Assert.assertFalse; 5 5 import static org.junit.Assert.assertTrue; 6 7 import java.io.ByteArrayOutputStream; 6 8 7 9 import org.jmodelica.common.GUIDManager; … … 20 22 private void test(String source, String[] dependent, String[] expected) { 21 23 guidManager.setSourceString(source); 22 StringBuilder[] output = new StringBuilder[dependent.length];24 ByteArrayOutputStream[] output = new ByteArrayOutputStream[dependent.length]; 23 25 for (int i = 0; i < dependent.length; i++) { 24 output[i] = new StringBuilder();26 output[i] = new ByteArrayOutputStream(); 25 27 guidManager.addDependentString(dependent[i], output[i]); 26 28 } … … 47 49 String expected = "guid=277efff8e9f33c422aa6e3fecb8b592"; 48 50 guidManager.setSourceString(input); 49 StringBuilder output = new StringBuilder();51 ByteArrayOutputStream output = new ByteArrayOutputStream(); 50 52 guidManager.addDependentString(input, output); 51 53 guidManager.processDependentFiles(); -
branches/dev-5819/Compiler/ModelicaMiddleEnd/src/jastadd/structural/Symbolic.jrag
r13651 r13800 217 217 private static Boolean FEquation.nominalAllowsDivision(FExp factor, FVariable var, double tol) { 218 218 if (factor.variability().constantVariability()) { 219 FExp nominal = factor.dynamicFExp(var.nominal()); 220 if (nominal.variability().constantVariability() && 221 Math.abs(factor.ceval().realValue()) * 222 nominal.ceval().realValue() < tol) { 223 return false; 219 FExp varNominalExp = factor.dynamicFExp(var.nominal()); 220 if (varNominalExp.variability().constantVariability()) { 221 double factorNominal = Math.abs(factor.ceval().realValue()); 222 double varNominal = varNominalExp.ceval().realValue(); 223 double totalNominal = factorNominal * varNominal; 224 if (totalNominal < tol) { 225 return false; 226 } 224 227 } 225 228 } -
branches/dev-5819/Compiler/ModelicaMiddleEnd/test/modelica/EquationSolvingTests.mo
r13651 r13800 34 34 FClassMethodTestCase( 35 35 name="ParametricNominal1", 36 description=" ",36 description="Test that parametric nominal that cannot be evaluated does not lead to exception during equation solving. Instead we handle it as if there was no nominal set.", 37 37 methodName="printDAEBLT", 38 38 methodResult=" -
branches/dev-5819/Compiler/OptimicaFrontEnd/src/jastadd/OptimicaFlatAPI.jrag
r11676 r13800 71 71 syn CValue FVariable.initialGuessAttributeCValue() = CValue.UNKNOWN; 72 72 eq FRealVariable.initialGuessAttributeCValue() = attributeCValueReal(FAttribute.INITIAL_GUESS, 0.0); 73 eq FDerivativeVariable.initialGuessAttributeCValue() = new CValueReal(0.0);73 eq FDerivativeVariable.initialGuessAttributeCValue() = CValueReal.valueOf(0.0); 74 74 eq FIntegerVariable.initialGuessAttributeCValue() = attributeCValueInteger(FAttribute.INITIAL_GUESS, 0); 75 75 eq FBooleanVariable.initialGuessAttributeCValue() = attributeCValueBoolean(FAttribute.INITIAL_GUESS, false); … … 157 157 syn CValue FOptClass.startTimeAttributeCValue() = 158 158 startTimeAttributeSet()? startTimeAttributeExp().ceval(): 159 new CValueReal(0.0);159 CValueReal.valueOf(0.0); 160 160 161 161 /** … … 211 211 syn CValue FOptClass.startTimeFreeAttributeCValue() = 212 212 startTimeFreeAttributeSet()? startTimeFreeAttributeExp().ceval(): 213 new CValueBoolean(false);213 CValueBoolean.FALSE; 214 214 215 215 /** … … 265 265 syn CValue FOptClass.startTimeInitialGuessAttributeCValue() = 266 266 startTimeInitialGuessAttributeSet()? startTimeInitialGuessAttributeExp().ceval(): 267 new CValueReal(0.0);267 CValueReal.valueOf(0.0); 268 268 269 269 /** … … 311 311 syn CValue FOptClass.finalTimeAttributeCValue() = 312 312 finalTimeAttributeSet()? finalTimeAttributeExp().ceval(): 313 new CValueReal(1.0);313 CValueReal.valueOf(1.0); 314 314 315 315 /** … … 357 357 syn CValue FOptClass.staticAttributeCValue() = 358 358 staticAttributeSet()? staticAttributeExp().ceval(): 359 new CValueBoolean(false);359 CValueBoolean.FALSE; 360 360 361 361 /** … … 411 411 syn CValue FOptClass.finalTimeFreeAttributeCValue() = 412 412 finalTimeFreeAttributeSet()? finalTimeFreeAttributeExp().ceval(): 413 new CValueBoolean(false);413 CValueBoolean.FALSE; 414 414 415 415 /** … … 465 465 syn CValue FOptClass.finalTimeInitialGuessAttributeCValue() = 466 466 finalTimeInitialGuessAttributeSet()? finalTimeInitialGuessAttributeExp().ceval(): 467 new CValueReal(1.0);467 CValueReal.valueOf(1.0); 468 468 469 469 /** -
branches/dev-5819/Compiler/TestFramework/src/jastadd/CodeGenTestCase.jrag
r11966 r13800 44 44 45 45 GUIDManager guidManager = fc.guidManager(); 46 StringBuilder actual = new StringBuilder();46 ByteArrayOutputStream actual = new ByteArrayOutputStream(); 47 47 guidManager.setSourceString(test); 48 48 guidManager.addDependentString(test, actual); -
branches/dev-5819/Makefile.am
-
Property
svn:mergeinfo
set to
(toggle deleted branches)
/branches/1.13.x/Makefile.am merged eligible /branches/1.16.x/Makefile.am merged eligible /branches/1.17.x/Makefile.am merged eligible /branches/2.0.x/Makefile.am merged eligible /branches/2.1.x/Makefile.am merged eligible /branches/2.10.x/Makefile.am merged eligible /branches/2.14.x/Makefile.am merged eligible /branches/2.5.x/Makefile.am merged eligible /branches/2.6.x/Makefile.am merged eligible /branches/2.8.x/Makefile.am merged eligible /branches/20150227.x/Makefile.am merged eligible /branches/20160824.x/Makefile.am merged eligible /branches/ASTDrivenEditor/Makefile.am merged eligible /branches/CasADiInterfaceUpdate/Makefile.am merged eligible /branches/CasADiUpdate/Makefile.am merged eligible /branches/DelayInOptimization/Makefile.am merged eligible /branches/JMILoggingXML/Makefile.am merged eligible /branches/NewCasADiInterface/Makefile.am merged eligible /branches/VariableEliminationInCasADiCollocator/Makefile.am merged eligible /branches/dev-1526/Makefile.am merged eligible /branches/dev-1957/Makefile.am merged eligible /branches/dev-2007/Makefile.am merged eligible /branches/dev-2053/Makefile.am merged eligible /branches/dev-2154/Makefile.am merged eligible /branches/dev-5539/Makefile.am merged eligible /branches/dev-5543/Makefile.am merged eligible /branches/dev-5611/Makefile.am merged eligible /branches/dev-5671/Makefile.am merged eligible /branches/dev-5680/Makefile.am merged eligible /branches/dev-5693/Makefile.am merged eligible /branches/dev-5703-GANExists/Makefile.am merged eligible /branches/dev-5708/Makefile.am merged eligible /branches/dev-5726-orginal-annotation/Makefile.am merged eligible /branches/dev-5728/Makefile.am merged eligible /branches/dev-5787/Makefile.am merged eligible /branches/dev-cw-jcompression/Makefile.am merged eligible /branches/dev-ext-externalEval/Makefile.am merged eligible /branches/dev-jk-2263/Makefile.am merged eligible /branches/dev-jku-1737/Makefile.am merged eligible /branches/dev-jku-2024/Makefile.am merged eligible /branches/dev-jku-2482/Makefile.am merged eligible /branches/dev-jm-evalExternalValues/Makefile.am merged eligible /branches/dev-jo-2330/Makefile.am merged eligible /branches/dev-jo-jastadd/Makefile.am merged eligible /branches/dev-mj-1626/Makefile.am merged eligible /branches/dev-mj-5830/Makefile.am merged eligible /branches/dev-mj-5835/Makefile.am merged eligible /branches/dev-mo-2263-merge/Makefile.am merged eligible /branches/dev-mo-2401/Makefile.am merged eligible /branches/dev-mo-jastadd/Makefile.am merged eligible /branches/dev-mo-merge/Makefile.am merged eligible /branches/dev-python-restructuring-20111129/Makefile.am merged eligible /branches/dev-source-refactoring-2017-10-25/Makefile.am merged eligible /branches/dev-tg-5845/Makefile.am merged eligible /trunk/Makefile.am merged eligible /branches/BlockLabels/Makefile.am 6503-6508 /branches/CasADiRedesign/Makefile.am 3624-3645 /branches/CollocationRestructure/Makefile.am 6153-6382 /branches/DelayInSimulation/Makefile.am 6842-6898 /branches/MSL3.2-switch/Makefile.am 4175-4195 /branches/MSLTables/Makefile.am 4103-4234 /branches/ModelicaStandardTables/Makefile.am 5060-5135 /branches/NewJMILogging/Makefile.am 4601-4754 /branches/PointConstraintsRedesign/Makefile.am 3408-3475,3478-3565,3568-3595 /branches/PreVariablesUpdate/Makefile.am 7472-7473,7482-7483,7487-7488,7503,7507,7527,7529,7531-7532,7538,7545-7546,7549,7551,7559-7560 /branches/PyFMI_build_system_integration/Makefile.am 3946-3966 /branches/RestructuringRun-time-20130828/Makefile.am 5151-5251 /branches/ValuesFileRemoval/Makefile.am 3469-3502 /branches/casadi_build_system_update/Makefile.am 3972-4015 /branches/dev-1360/Makefile.am 11493-11698 /branches/dev-1360_merge/Makefile.am 11699-11751,11756 /branches/dev-1429/Makefile.am 11992-12093 /branches/dev-1435/Makefile.am 11613-11728,11741-11743 /branches/dev-1524/Makefile.am 11727 /branches/dev-1597/Makefile.am 11615-11624 /branches/dev-1637/Makefile.am 11783-11806 /branches/dev-1663/Makefile.am 12546-13016 /branches/dev-1715/Makefile.am 11687-11719 /branches/dev-1726/Makefile.am 11628-11674 /branches/dev-1832/Makefile.am 11772-11965 /branches/dev-1901/Makefile.am 12191-12239 /branches/dev-5523/Makefile.am 10450-10565 /branches/dev-5527/Makefile.am 10472-10517 /branches/dev-5547/Makefile.am 10602-10813 /branches/dev-5570/Makefile.am 10735-10751 /branches/dev-5576/Makefile.am 10775-10901 /branches/dev-5675/Makefile.am 11568-11594,11622-11648 /branches/dev-5686/Makefile.am 11715-11724 /branches/dev-5689-annotation-eval/Makefile.am 11737-11784 /branches/dev-5739/Makefile.am 12420-12531 /branches/dev-5776/Makefile.am 12889-12952 /branches/dev-5789/Makefile.am 12954-12990 /branches/dev-AR-logoutput/Makefile.am 13024 /branches/dev-JM5683/Makefile.am 11701-11703 /branches/dev-Sundials-SuperLU-up/Makefile.am 9816-9820 /branches/dev-TDM-MinGW-gcc4.8.1/Makefile.am 6594-6732,6735 /branches/dev-cs-export-20130307/Makefile.am 4511-4545 /branches/dev-dynamicMemory-20171108/Makefile.am 10358-10384 /branches/dev-fullstringsupport/Makefile.am 10434-10501,10508,10567-10569 /branches/dev-globalscope/Makefile.am 10609-10636 /branches/dev-initialexternalobject/Makefile.am 10922-11035 /branches/dev-jk-1971/Makefile.am 12483-12489 /branches/dev-jk-2130/Makefile.am 12615,12656-12657,12691-12704,12712-12724,12741 /branches/dev-jk-2139/Makefile.am 12799-12891 /branches/dev-jk-2161/Makefile.am 12652 /branches/dev-jk-2169/Makefile.am 12670-12872,12913-12914,12961 /branches/dev-jk-2217-2/Makefile.am 13072-13088 /branches/dev-jk-2217-3/Makefile.am 13081-13098 /branches/dev-jk-2217-4-2/Makefile.am 13127-13145 /branches/dev-jk-2217/Makefile.am 13007 /branches/dev-jk-2233/Makefile.am 12835 /branches/dev-jk-2245/Makefile.am 12853 /branches/dev-jk-2306-2/Makefile.am 13340-13356 /branches/dev-jk-2330/Makefile.am 13218 /branches/dev-jk-2471/Makefile.am 13557-13624 /branches/dev-jk-alias-param/Makefile.am 11834-12003 /branches/dev-jk-alias/Makefile.am 12092,12122 /branches/dev-jk-cdup/Makefile.am 12007 /branches/dev-jk-initial-vp/Makefile.am 11838,11913,11932-11948,12038-12050,12067-12071 /branches/dev-jk-inline/Makefile.am 12402-12411,12478-12491 /branches/dev-jk-iter/Makefile.am 12207 /branches/dev-jk-reinit/Makefile.am 12400 /branches/dev-jk-unroll/Makefile.am 12513,12524-12531,12544 /branches/dev-jku-1603/Makefile.am 12300,12314,12322,12334,12352 /branches/dev-jku-1937/Makefile.am 12540 /branches/dev-jku-2120/Makefile.am 12552 /branches/dev-jo-1907/Makefile.am 13146-13151,13160,13183,13194,13214,13234,13238-13242 /branches/dev-jo-2151-2/Makefile.am 13121-13156 /branches/dev-jo-2326/Makefile.am 13250 /branches/dev-jo-2348/Makefile.am 13207-13236 /branches/dev-mo-1770/Makefile.am 12238-12267 /branches/dev-mo-1877/Makefile.am 12069-12183,12192,12196 /branches/dev-mo-2032/Makefile.am 12406-12457 /branches/dev-mo-2107/Makefile.am 12635-12645,12729-12783 /branches/dev-mo-2164/Makefile.am 12795-12810 /branches/dev-mo-2267/Makefile.am 13369-13454 /branches/dev-mo-2275/Makefile.am 13547-13576 /branches/dev-mo-2276/Makefile.am 13509 /branches/dev-mo-5734/Makefile.am 12336-12375,12445-12457,12462 /branches/dev-oct-1677/Makefile.am 11747-11908 /branches/dev-options/Makefile.am 11309-11318 /branches/dev-performance/Makefile.am 11399-11675 /branches/dev-premerge/Makefile.am 10785-10828 /branches/dev-resolveuri/Makefile.am 10768-10787 /branches/dev-testprinter/Makefile.am 10660-10674 /branches/dev-tg-2069/Makefile.am 12999-13008 /branches/dev-thirdparty-updates-20160215/Makefile.am 8469-8960 /branches/dev/5174/Makefile.am 10350-10545 /branches/dev/directionalderivatives/Makefile.am 10199-10277 /branches/dev/initialvp/Makefile.am 10415-10424 /branches/dev_NLE_bounds_and_norms_2/Makefile.am 4025-4096 /branches/dev_remove_jmu/Makefile.am 9758-9808 /branches/optimizingcompiler/Makefile.am 4343-4707 /branches/thesis/OriginTracking/Makefile.am 9288-9759
r13799 r13800 45 45 bindistdir=JModelica.org-$(VERSION)-bin 46 46 47 casadi: 48 if COMPILE_WITH_IPOPT 49 cd $(abs_builddir)/ThirdParty/CasADi; \ 50 make -f Makefile "SWIGCHECK_BUILD_DIR=$(TMP_SWIGCHECK_BUILD_DIR)" "CASADI_BUILD_DIR=$(TMP_CASADI_BUILD_DIR)" "IPOPT_HOME=$(IPOPT_HOME)" "CASADI_PYTHON_INST_DIR=${TMP_CASADI_PYTHON_INST_DIR}" "CASADI_INST_DIR=${TMP_CASADI_INST_DIR}" "CASADI_PLUGIN_INST_DIR=${TMP_CASADI_PLUGIN_INST_DIR}" "CMAKE_CASADI_ARGS=${TMP_CMAKE_CASADI_ARGS}" "CMAKE_CASADI_COMPILER_ARGS=${TMP_CMAKE_CASADI_COMPILER_ARGS}" "CMAKE_CASADI_CXX_FLAG=${TMP_CMAKE_CASADI_CXX_FLAG}" "CMAKE_PYTHON_LIB=${CMAKE_PYTHON_LIB}" 51 endif 52 if COMPILE_WITH_IPOPT64 53 export PATH=$(PYTHON64_HOME):$(PYTHON64_HOME)/Scripts:$(PYTHON64_HOME)/Lib:"${PATH}"; \ 54 export PYTHONHOME=$(PYTHON64_HOME); \ 55 cd $(abs_builddir)/ThirdParty/CasADi; \ 56 make -f Makefile "SWIGCHECK_BUILD_DIR=$(SWIGCHECK_BUILD_DIR64)" "CASADI_BUILD_DIR=$(CASADI_BUILD_DIR64)" "IPOPT_HOME=$(IPOPT64_HOME)" "CASADI_PYTHON_INST_DIR=${CASADI_PYTHON_INST_DIR64}" "CASADI_INST_DIR=${CASADI_INST_DIR64}" "CASADI_PLUGIN_INST_DIR=${CASADI_PLUGIN_INST_DIR64}" "CMAKE_CASADI_ARGS=${CMAKE_CASADI_ARGS64}" "CMAKE_CASADI_COMPILER_ARGS=${CMAKE_CASADI_COMPILER_ARGS64}" "CMAKE_CASADI_CXX_FLAG=${CMAKE_CASADI_CXX_FLAG64}" "CMAKE_PYTHON_LIB=${CMAKE_PYTHON64_LIB}" "CMAKE_PYTHON_INCLUDE=${CMAKE_PYTHON64_INCLUDE}" 57 export PYTHONHOME=$(ORIG_PYTHON_HOME); \ 58 export PATH="$(ORIG_PATH)"; 59 endif 60 61 install_casadi: casadi 62 if COMPILE_WITH_IPOPT 63 cd $(abs_builddir)/ThirdParty/CasADi; \ 64 make -f Makefile install "SWIGCHECK_BUILD_DIR=$(TMP_SWIGCHECK_BUILD_DIR)" "CASADI_BUILD_DIR=$(TMP_CASADI_BUILD_DIR)" "IPOPT_HOME=$(IPOPT_HOME)" 65 mkdir -p $(DESTDIR)$(prefix)/Python/ 66 cp -r $(TMP_CASADI_PYTHON_INST_DIR)/casadi $(DESTDIR)$(prefix)/Python/ 67 ## temp fix 68 cp $(TMP_CASADI_BUILD_DIR)/swig/casadi_core.py $(DESTDIR)$(prefix)/Python/casadi 69 endif 70 if COMPILE_WITH_IPOPT64 71 export PATH=$(PYTHON64_HOME):$(PYTHON64_HOME)/Scripts:$(PYTHON64_HOME)/Lib:"${PATH}"; \ 72 export PYTHONHOME=$(PYTHON64_HOME); 73 cd $(abs_builddir)/ThirdParty/CasADi; \ 74 make -f Makefile install "SWIGCHECK_BUILD_DIR=$(SWIGCHECK_BUILD_DIR)" "CASADI_BUILD_DIR=$(CASADI_BUILD_DIR64)" "IPOPT_HOME=$(IPOPT64_HOME)" 75 mkdir -p $(DESTDIR)$(prefix)/Python/ 76 cp -r $(CASADI_PYTHON_INST_DIR64)/casadi $(DESTDIR)$(prefix)/Python_64/ 77 ## temp fix 78 cp $(CASADI_BUILD_DIR64)/swig/casadi_core.py $(DESTDIR)$(prefix)/Python_64/casadi 79 export PYTHONHOME=$(ORIG_PYTHON_HOME); \ 80 export PATH="$(ORIG_PATH)"; 81 endif 82 ## Install for CasADiInterface, Variables and targets. 83 ## MC_interface installs the system with Python. 84 ## If C++ compilation/tests are wanted there is the target MC_interface_cplusplus 85 86 MC_INTERFACE=$(abs_top_srcdir)/ModelicaCasADiInterface 87 88 CASADI_HOME=$(abs_top_srcdir)/ThirdParty/CasADi/CasADi 89 MC_SRC=$(JAVA_CASADI_BASE_DIR)/ModelicaCompilerCasADi 90 OC_SRC=$(JAVA_CASADI_BASE_DIR)/OptimicaCompilerCasADi 91 MC_SRC_SWIG=$(abs_top_srcdir)/Compiler/ModelicaCompilerCasADi/src/swig 92 93 MC_CASADI_BUILD=$(abs_builddir)/ModelicaCompilerCasADi 94 OC_CASADI_BUILD=$(abs_builddir)/OptimicaCompilerCasADi 95 96 # The modelica casadi interface is built into a build folder 97 MC_BUILD=$(abs_builddir)/ModelicaCasADiInterfaceBuild 98 MC_BUILD64=$(abs_builddir)/ModelicaCasADiInterfaceBuild64 99 # Jars from the modified modelica and optimica compilers are put into the JModelica folder 100 MC_COMPILERS_DIR=$(MC_BUILD)/JModelica.org 101 MC_LIB=$(DESTDIR)$(prefix)/lib/casadi_interface 102 MC_LIB64=$(DESTDIR)$(prefix)/lib/casadi_interface64 103 104 CASADI_BUILD_DIR=$(abs_builddir)/casadi_build 105 CASADI_BUILD_DIR64=$(abs_builddir)/casadi_build64 106 SWIGCHECK_BUILD_DIR=$(abs_builddir)/swig_check 107 SWIGCHECK_BUILD_DIR64=$(abs_builddir)/swig_check64 108 CASADI_PYTHON_INST_DIR=$(abs_builddir)/casadi_install 109 CASADI_INST_DIR=$(prefix)/ThirdParty/CasADi 110 CASADI_PLUGIN_INST_DIR=$(CASADI_INST_DIR)/lib 111 CASADI_PYTHON_INST_DIR64=$(abs_builddir)/casadi_install64 112 CASADI_INST_DIR64=$(prefix)/ThirdParty/CasADi64 113 CASADI_PLUGIN_INST_DIR64=$(CASADI_INST_DIR64)/lib 114 CMAKE_CASADI_CXX_FLAG=-m32 115 CMAKE_CASADI_COMPILER_ARGS=-m32 -mincoming-stack-boundary=2 116 CMAKE_CASADI_CXX_FLAG64=-m64 117 CMAKE_CASADI_COMPILER_ARGS64=-m64 -fpermissive 118 119 120 if BUILD_WITH_PYTHON32 121 BUILD_WITH_PYTHON32_ARG=--force-32bit="true" --extra-c-flags="-mincoming-stack-boundary=2" 122 DEP_SUFFIX= 123 TMP_CASADI_BUILD_DIR=$(CASADI_BUILD_DIR) 124 TMP_SWIGCHECK_BUILD_DIR=$(SWIGCHECK_BUILD_DIR) 125 TMP_CMAKE_CASADI_CXX_FLAG=$(CMAKE_CASADI_CXX_FLAG) 126 TMP_CMAKE_CASADI_COMPILER_ARGS=$(CMAKE_CASADI_COMPILER_ARGS) 127 128 TMP_CASADI_INST_DIR=$(CASADI_INST_DIR) 129 TMP_CASADI_PLUGIN_INST_DIR=$(CASADI_PLUGIN_INST_DIR) 130 TMP_CASADI_PYTHON_INST_DIR=$(CASADI_PYTHON_INST_DIR) 131 TMP_MC_LIB=$(MC_LIB) 132 TMP_MC_BUILD=$(MC_BUILD) 133 TMP_CMAKE_CASADI_ARGS=$(CMAKE_CASADI_ARGS) 134 else 135 BUILD_WITH_PYTHON32_ARG= 136 DEP_SUFFIX=64 137 TMP_CASADI_BUILD_DIR=$(CASADI_BUILD_DIR64) 138 TMP_SWIGCHECK_BUILD_DIR=$(SWIGCHECK_BUILD_DIR64) 139 TMP_CMAKE_CASADI_CXX_FLAG=$(CMAKE_CASADI_CXX_FLAG64) 140 TMP_CMAKE_CASADI_COMPILER_ARGS=$(CMAKE_CASADI_COMPILER_ARGS64) 141 142 # note we set directories to those without 64bit suffix 143 TMP_CASADI_INST_DIR=$(CASADI_INST_DIR) 144 TMP_CASADI_PLUGIN_INST_DIR=$(CASADI_PLUGIN_INST_DIR) 145 TMP_CASADI_PYTHON_INST_DIR=$(CASADI_PYTHON_INST_DIR) 146 TMP_MC_LIB=$(MC_LIB64) 147 TMP_MC_BUILD=$(MC_BUILD64) 148 149 150 #CMAKE_PYTHON_INCLUDE=$(CMAKE_PYTHON64_INCLUDE) 151 #CMAKE_PYTHON_LIB=$(CMAKE_PYTHON_LIB64) 152 TMP_CMAKE_CASADI_ARGS=$(CMAKE_CASADI_ARGS64) 153 endif 154 155 156 casadi_interface: install_casadi_interface 157 build_casadi_interface: casadi modelicacasadi_wrapper 158 install_casadi_interface: install_casadi $(TMP_MC_LIB) $(DESTDIR)$(prefix)/Python/modelicacasadi_transfer/__init__.py $(DESTDIR)$(prefix)/Python/modelicacasadi_wrapper/__init__.py $(DESTDIR)$(prefix)/Python/modelicacasadi_transfer/modelica_casadi_transfer_wrapper.py 159 if [ "$(INSTALL_EXTRA_CASADI)" ]; then exec "$(INSTALL_EXTRA_CASADI)" "$(abs_top_srcdir)" "$(DESTDIR)$(prefix)"; fi 160 161 ifcasadi: casadi 162 if COMPILE_WITH_IPOPT 163 mkdir -p $(TMP_MC_BUILD)/ifcasadi; \ 164 cd $(TMP_MC_BUILD)/ifcasadi; \ 165 case $(build) in \ 166 *-cygwin*|*-mingw*) \ 167 cmake $(MC_SRC_SWIG) -G "MSYS Makefiles" -DCMAKE_CXX_COMPILER_ARG1="$(TMP_CMAKE_CASADI_CXX_FLAG)" -DCMAKE_CXX_FLAGS="$(TMP_CMAKE_CASADI_CXX_FLAG)" \ 168 -DIFCASADI_OUTDIR="$(MC_CASADI_BUILD)" -DCASADI_HOME="$(CASADI_HOME)" -DCASADI_BUILD_DIR="$(TMP_CASADI_BUILD_DIR)";; \ 169 *) \ 170 cmake $(MC_SRC_SWIG) \ 171 -DIFCASADI_OUTDIR="$(MC_CASADI_BUILD)" -DCASADI_HOME="$(CASADI_HOME)" -DCASADI_BUILD_DIR="$(TMP_CASADI_BUILD_DIR)";; \ 172 esac 173 cd $(TMP_MC_BUILD)/ifcasadi; make 174 endif 175 if COMPILE_WITH_IPOPT64 176 export PATH=$(PYTHON64_HOME):$(PYTHON64_HOME)/Scripts:$(PYTHON64_HOME)/Lib:"${PATH}"; 177 export PYTHONHOME=$(PYTHON64_HOME); 178 mkdir -p $(MC_BUILD64)/ifcasadi; \ 179 cd $(MC_BUILD64)/ifcasadi; \ 180 cmake $(MC_SRC_SWIG) -G "MSYS Makefiles" -DCMAKE_CXX_COMPILER_ARG1="-m64" -DCMAKE_CXX_FLAGS="-m64" \ 181 -DIFCASADI_OUTDIR="$(MC_CASADI_BUILD)" -DCASADI_HOME="$(CASADI_HOME)" -DCASADI_BUILD_DIR="$(CASADI_BUILD_DIR64)"; \ 182 cd $(MC_BUILD64)/ifcasadi; make 183 export PYTHONHOME=$(ORIG_PYTHON_HOME); \ 184 export PATH="$(ORIG_PATH)"; 185 endif 186 187 $(TMP_MC_LIB): $(MC_CASADI_BUILD)/bin/ModelicaCompiler.jar $(OC_CASADI_BUILD)/bin/OptimicaCompiler.jar $(MC_CASADI_BUILD)/bin/util.jar ifcasadi 188 if COMPILE_WITH_IPOPT 189 rm -rf $(TMP_MC_LIB) 190 mkdir -p $(TMP_MC_LIB) 191 cp $(MC_CASADI_BUILD)/bin/ModelicaCompiler.jar $(TMP_MC_LIB) 192 cp $(OC_CASADI_BUILD)/bin/OptimicaCompiler.jar $(TMP_MC_LIB) 193 cp $(MC_CASADI_BUILD)/bin/util.jar $(TMP_MC_LIB) 194 case $(build) in \ 195 *-cygwin*) \ 196 cp $(TMP_MC_BUILD)/ifcasadi/ifcasadi.dll $(TMP_MC_LIB) ;; \ 197 *-mingw*) \ 198 cp $(TMP_MC_BUILD)/ifcasadi/ifcasadi.dll $(TMP_MC_LIB) ;; \ 199 *) \ 200 cp $(TMP_MC_BUILD)/ifcasadi/libifcasadi.so $(TMP_MC_LIB) ;; \ 201 esac 202 endif 203 if COMPILE_WITH_IPOPT64 204 rm -rf $(MC_LIB64) 205 mkdir -p $(MC_LIB64) 206 cp $(MC_CASADI_BUILD)/bin/ModelicaCompiler.jar $(MC_LIB64) 207 cp $(OC_CASADI_BUILD)/bin/OptimicaCompiler.jar $(MC_LIB64) 208 cp $(MC_CASADI_BUILD)/bin/util.jar $(MC_LIB64) 209 cp $(MC_BUILD64)/ifcasadi/ifcasadi.dll $(MC_LIB64) 210 endif 211 212 mc_modelica: ifcasadi 213 cd $(MC_CASADI_BUILD); $(ANT_OPTS) $(ANT) -f "$(JAVA_MC_CASADI_ANT_FILE)" "-Dcompiler=$(COMPILER_DIR)" "-Dtarget=$(MC_CASADI_BUILD)" 214 215 mc_optimica: ifcasadi 216 mkdir -p $(OC_CASADI_BUILD)/src/generated/optimica/java 217 cp -pr $(MC_CASADI_BUILD)/src/generated/modelica/java/ifcasadi $(OC_CASADI_BUILD)/src/generated/optimica/java 218 cd $(OC_CASADI_BUILD); $(ANT_OPTS) $(ANT) -f "$(JAVA_OC_CASADI_ANT_FILE)" "-Dcompiler=$(COMPILER_DIR)" "-Dtarget=$(OC_CASADI_BUILD)" 219 220 $(MC_CASADI_BUILD)/bin/ModelicaCompiler.jar: mc_modelica 221 $(MC_CASADI_BUILD)/bin/util.jar: mc_modelica 222 $(MC_CASADI_BUILD)/bin/separateProcess.jar: mc_modelica 223 224 $(OC_CASADI_BUILD)/bin/OptimicaCompiler.jar: mc_optimica 225 $(OC_CASADI_BUILD)/bin/util.jar: mc_optimica 226 $(OC_CASADI_BUILD)/bin/separateProcess.jar: mc_optimica 227 228 $(TMP_MC_BUILD)/modelicacasadi_wrapper/swig/modelicacasadi_wrapper.py: modelicacasadi_wrapper 229 230 231 modelicacasadi_wrapper: $(MC_CASADI_BUILD)/bin/ModelicaCompiler.jar $(OC_CASADI_BUILD)/bin/OptimicaCompiler.jar $(MC_CASADI_BUILD)/bin/util.jar ifcasadi # $(TMP_MC_LIB) 232 if COMPILE_WITH_IPOPT 233 mkdir -p $(TMP_MC_BUILD)/modelicacasadi_wrapper; \ 234 cd $(TMP_MC_BUILD)/modelicacasadi_wrapper; \ 235 case $(build) in \ 236 *-cygwin*|*-mingw*) \ 237 cmake $(MC_INTERFACE) -G "MSYS Makefiles" -DCMAKE_CXX_COMPILER_ARG1="$(TMP_CMAKE_CASADI_CXX_FLAG)" -DCMAKE_CXX_FLAGS="$(TMP_CMAKE_CASADI_CXX_FLAG)" \ 238 -DMC_BUILD="$(TMP_MC_BUILD)" -DIPOPT_HOME="$(IPOPT_HOME)" -DCASADI_BUILD_DIR="$(TMP_CASADI_BUILD_DIR)" \ 239 -DIFCASADI_JAR_BASE="$(JAVA_CASADI_BUILD_DIR)" -DCASADI_HOME="$(CASADI_HOME)" \ 240 "$(CMAKE_PYTHON_LIB)" "$(CMAKE_PYTHON_INCLUDE)" ;; \ 241 *) \ 242 cmake $(MC_INTERFACE) \ 243 -DMC_BUILD="$(TMP_MC_BUILD)" -DIPOPT_HOME="$(IPOPT_HOME)" -DCASADI_BUILD_DIR="$(TMP_CASADI_BUILD_DIR)" \ 244 -DIFCASADI_JAR_BASE="$(JAVA_CASADI_BUILD_DIR)" -DCASADI_HOME="$(CASADI_HOME)" \ 245 "$(CMAKE_PYTHON_LIB)" "$(CMAKE_PYTHON_INCLUDE)" ;; \ 246 esac 247 cd $(TMP_MC_BUILD)/modelicacasadi_wrapper; make modelicacasadi_wrapper 248 endif 249 if COMPILE_WITH_IPOPT64 250 export PATH=$(PYTHON64_HOME):$(PYTHON64_HOME)/Scripts:$(PYTHON64_HOME)/Lib:"${PATH}"; \ 251 export PYTHONHOME=$(PYTHON64_HOME); \ 252 mkdir -p $(MC_BUILD64)/modelicacasadi_wrapper; \ 253 cd $(MC_BUILD64)/modelicacasadi_wrapper; \ 254 cmake $(MC_INTERFACE) -G "MSYS Makefiles" -DCMAKE_CXX_COMPILER_ARG1="-m64" -DCMAKE_CXX_FLAGS="-m64" \ 255 -DMC_BUILD="$(MC_BUILD64)" -DIPOPT_HOME="$(IPOPT64_HOME)" -DCASADI_BUILD_DIR="$(CASADI_BUILD_DIR64)" \ 256 -DIFCASADI_JAR_BASE="$(JAVA_CASADI_BUILD_DIR)" -DCASADI_HOME="$(CASADI_HOME)" \ 257 "$(CMAKE_PYTHON64_LIB)" "$(CMAKE_PYTHON64_INCLUDE)"; \ 258 cd $(MC_BUILD64)/modelicacasadi_wrapper; make modelicacasadi_wrapper 259 export PYTHONHOME=$(ORIG_PYTHON_HOME); 260 export PATH="$(ORIG_PATH)"; 261 endif 262 263 $(DESTDIR)$(prefix)/Python/modelicacasadi_transfer/__init__.py: install_modelicacasadi_transfer 264 $(DESTDIR)$(prefix)/Python/modelicacasadi_transfer/modelica_casadi_transfer_wrapper.py: install_modelicacasadi_transfer 265 266 $(DESTDIR)$(prefix)/Python/modelicacasadi_wrapper/__init__.py: install_modelicacasadi_wrapper 267 268 install_modelicacasadi_wrapper: $(TMP_MC_BUILD)/modelicacasadi_wrapper/swig/modelicacasadi_wrapper.py 269 if COMPILE_WITH_IPOPT 270 mkdir -p $(DESTDIR)$(prefix)/Python/modelicacasadi_wrapper 271 cp $(TMP_MC_BUILD)/modelicacasadi_wrapper/swig/*modelicacasadi_wrapper* $(DESTDIR)$(prefix)/Python/modelicacasadi_wrapper 272 rm -f $(DESTDIR)$(prefix)/Python/modelicacasadi_wrapper/__init__.py 273 touch $(DESTDIR)$(prefix)/Python/modelicacasadi_wrapper/__init__.py 274 echo "from modelicacasadi_wrapper import *" >> $(DESTDIR)$(prefix)/Python/modelicacasadi_wrapper/__init__.py 275 endif 276 if COMPILE_WITH_IPOPT64 277 export PATH=$(PYTHON64_HOME):$(PYTHON64_HOME)/Scripts:$(PYTHON64_HOME)/Lib:"${PATH}"; \ 278 export PYTHONHOME=$(PYTHON64_HOME); 279 mkdir -p $(DESTDIR)$(prefix)/Python_64/modelicacasadi_wrapper 280 cp $(MC_BUILD64)/modelicacasadi_wrapper/swig/*modelicacasadi_wrapper* $(DESTDIR)$(prefix)/Python_64/modelicacasadi_wrapper 281 rm -f $(DESTDIR)$(prefix)/Python_64/modelicacasadi_wrapper/__init__.py 282 touch $(DESTDIR)$(prefix)/Python_64/modelicacasadi_wrapper/__init__.py 283 echo "from modelicacasadi_wrapper import *" >> $(DESTDIR)$(prefix)/Python_64/modelicacasadi_wrapper/__init__.py 284 export PYTHONHOME=$(ORIG_PYTHON_HOME) 285 export PATH="$(ORIG_PATH)" 286 endif 287 288 install_modelicacasadi_transfer: $(MC_INTERFACE)/python/modelica_casadi_transfer_wrapper.py 289 if COMPILE_WITH_IPOPT 290 mkdir -p $(DESTDIR)$(prefix)/Python/modelicacasadi_transfer 291 rm -f $(DESTDIR)$(prefix)/Python/modelicacasadi_transfer/__init__.py 292 touch $(DESTDIR)$(prefix)/Python/modelicacasadi_transfer/__init__.py 293 echo "from modelica_casadi_transfer_wrapper import *" >> $(DESTDIR)$(prefix)/Python/modelicacasadi_transfer/__init__.py 294 cp $(MC_INTERFACE)/python/modelica_casadi_transfer_wrapper.py $(DESTDIR)$(prefix)/Python/modelicacasadi_transfer 295 endif 296 if COMPILE_WITH_IPOPT64 297 mkdir -p $(DESTDIR)$(prefix)/Python_64/modelicacasadi_transfer 298 rm -f $(DESTDIR)$(prefix)/Python_64/modelicacasadi_transfer/__init__.py 299 touch $(DESTDIR)$(prefix)/Python_64/modelicacasadi_transfer/__init__.py 300 echo "from modelica_casadi_transfer_wrapper import *" >> $(DESTDIR)$(prefix)/Python_64/modelicacasadi_transfer/__init__.py 301 cp $(MC_INTERFACE)/python/modelica_casadi_transfer_wrapper.py $(DESTDIR)$(prefix)/Python_64/modelicacasadi_transfer 302 endif 303 47 include MakefileCasadi.am 48 304 49 if NUMPY_NO_MSVCR 305 50 NUMPY_NO_MSVCR_ARG=--no-msvcr="true" … … 308 53 endif 309 54 55 56 if BUILD_WITH_PYTHON32 57 BUILD_WITH_PYTHON32_ARG=--force-32bit="true" --extra-c-flags="-mincoming-stack-boundary=2" 58 DEP_SUFFIX= 59 else 60 BUILD_WITH_PYTHON32_ARG= 61 DEP_SUFFIX=64 62 endif 310 63 311 64 build-python-packages: … … 691 444 692 445 clean-local: clean-frontends clean-python-packages clean-casadi-interface 693 694 clean-casadi-interface:695 rm -rf $(MC_BUILD)696 rm -rf $(MC_BUILD64)697 # rm -rf $(DESTDIR)$(prefix)/Python/casadi698 # rm -rf $(DESTDIR)$(prefix)/Python/modelicacasadi_transfer699 if HAVE_ANT700 cd $(JAVA_CASADI_BUILD_DIR)/ModelicaCompilerCasADi; \701 $(ANT_OPTS) $(ANT) clean ; rm -rf $(MC_CASADI_BUILD)/src/cpp-generated $(MC_CASADI_BUILD)/src/generated/modelica/java/ifcasadi702 cd $(JAVA_CASADI_BUILD_DIR)/OptimicaCompilerCasADi; \703 $(ANT_OPTS) $(ANT) clean ; rm -rf $(OC_CASADI_BUILD)/src/cpp-generated $(OC_CASADI_BUILD)/src/generated/optimica/java/ifcasadi704 endif705 446 706 447 clean-python-packages: … … 738 479 make -C $(abs_top_srcdir)/doc/PyJMI html 739 480 740 741 .PHONY: modelicacasadi_wrapper ifcasadi install_modelicacasadi_transfer install_modelicacasadi_wrapper -
Property
svn:mergeinfo
set to
(toggle deleted branches)
-
branches/dev-5819/Makefile.in
r13799 r13800 15 15 16 16 @SET_MAKE@ 17 18 # 19 # Copyright (C) 2009 Modelon AB 20 # 21 # This program is free software: you can redistribute it and/or modify 22 # it under the terms of the Common Public License as published by 23 # IBM, version 1.0 of the License. 24 # 25 # This program is distributed in the hope that it will be useful, 26 # but WITHOUT ANY WARRANTY. See the Common Public License for more details. 27 # 28 # You should have received a copy of the Common Public License 29 # along with this program. If not, see 30 # <http://www.ibm.com/developerworks/library/os-cpl.html/>. 17 31 18 32 # … … 49 63 host_triplet = @host@ 50 64 @PYTHON_ENABLED_TRUE@am__append_1 = Python 51 subdir = .52 65 DIST_COMMON = $(am__configure_deps) $(srcdir)/Makefile.am \ 53 $(srcdir)/Makefile.in $(srcdir)/ config.h.in\54 $(srcdir)/ jm_tests.in \66 $(srcdir)/Makefile.in $(srcdir)/MakefileCasadi.am \ 67 $(srcdir)/config.h.in $(srcdir)/jm_tests.in \ 55 68 $(top_srcdir)/Python/src/required_defaults.py.in \ 56 69 $(top_srcdir)/configure INSTALL config.guess config.sub \ 57 70 depcomp install-sh ltmain.sh missing 71 subdir = . 58 72 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 59 73 am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \ … … 400 414 am--refresh: 401 415 @: 402 $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)416 $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(srcdir)/MakefileCasadi.am $(am__configure_deps) 403 417 @for dep in $?; do \ 404 418 case '$(am__configure_deps)' in \ … … 894 908 895 909 910 .PHONY: modelicacasadi_wrapper ifcasadi install_modelicacasadi_transfer install_modelicacasadi_wrapper 911 896 912 casadi: 897 913 @COMPILE_WITH_IPOPT_TRUE@ cd $(abs_builddir)/ThirdParty/CasADi; \ … … 1046 1062 @COMPILE_WITH_IPOPT64_TRUE@ echo "from modelica_casadi_transfer_wrapper import *" >> $(DESTDIR)$(prefix)/Python_64/modelicacasadi_transfer/__init__.py 1047 1063 @COMPILE_WITH_IPOPT64_TRUE@ cp $(MC_INTERFACE)/python/modelica_casadi_transfer_wrapper.py $(DESTDIR)$(prefix)/Python_64/modelicacasadi_transfer 1064 1065 clean-casadi-interface: 1066 rm -rf $(MC_BUILD) 1067 rm -rf $(MC_BUILD64) 1068 # rm -rf $(DESTDIR)$(prefix)/Python/casadi 1069 # rm -rf $(DESTDIR)$(prefix)/Python/modelicacasadi_transfer 1070 @HAVE_ANT_TRUE@ cd $(JAVA_CASADI_BUILD_DIR)/ModelicaCompilerCasADi; \ 1071 @HAVE_ANT_TRUE@ $(ANT_OPTS) $(ANT) clean ; rm -rf $(MC_CASADI_BUILD)/src/cpp-generated $(MC_CASADI_BUILD)/src/generated/modelica/java/ifcasadi 1072 @HAVE_ANT_TRUE@ cd $(JAVA_CASADI_BUILD_DIR)/OptimicaCompilerCasADi; \ 1073 @HAVE_ANT_TRUE@ $(ANT_OPTS) $(ANT) clean ; rm -rf $(OC_CASADI_BUILD)/src/cpp-generated $(OC_CASADI_BUILD)/src/generated/optimica/java/ifcasadi 1048 1074 1049 1075 build-python-packages: … … 1352 1378 clean-local: clean-frontends clean-python-packages clean-casadi-interface 1353 1379 1354 clean-casadi-interface:1355 rm -rf $(MC_BUILD)1356 rm -rf $(MC_BUILD64)1357 # rm -rf $(DESTDIR)$(prefix)/Python/casadi1358 # rm -rf $(DESTDIR)$(prefix)/Python/modelicacasadi_transfer1359 @HAVE_ANT_TRUE@ cd $(JAVA_CASADI_BUILD_DIR)/ModelicaCompilerCasADi; \1360 @HAVE_ANT_TRUE@ $(ANT_OPTS) $(ANT) clean ; rm -rf $(MC_CASADI_BUILD)/src/cpp-generated $(MC_CASADI_BUILD)/src/generated/modelica/java/ifcasadi1361 @HAVE_ANT_TRUE@ cd $(JAVA_CASADI_BUILD_DIR)/OptimicaCompilerCasADi; \1362 @HAVE_ANT_TRUE@ $(ANT_OPTS) $(ANT) clean ; rm -rf $(OC_CASADI_BUILD)/src/cpp-generated $(OC_CASADI_BUILD)/src/generated/optimica/java/ifcasadi1363 1364 1380 clean-python-packages: 1365 1381 @PYTHON_ENABLED_TRUE@ if [ -d $(assimulo_build_dir)/Assimulo ]; then \ … … 1392 1408 make -C $(abs_top_srcdir)/doc/PyJMI html 1393 1409 1394 .PHONY: modelicacasadi_wrapper ifcasadi install_modelicacasadi_transfer install_modelicacasadi_wrapper1395 1396 1410 # Tell versions [3.59,3.63) of GNU make to not export all variables. 1397 1411 # Otherwise a system limit (for SysV at least) may be exceeded. -
branches/dev-5819/MakefileCasadi.am
r13799 r13800 50 50 CMAKE_CASADI_COMPILER_ARGS64=-m64 -fpermissive 51 51 52 if BUILD_WITH_PYTHON32 53 BUILD_WITH_PYTHON32_ARG=--force-32bit="true" --extra-c-flags="-mincoming-stack-boundary=2" 54 DEP_SUFFIX= 55 TMP_CASADI_BUILD_DIR=$(CASADI_BUILD_DIR) 56 TMP_SWIGCHECK_BUILD_DIR=$(SWIGCHECK_BUILD_DIR) 57 TMP_CMAKE_CASADI_CXX_FLAG=$(CMAKE_CASADI_CXX_FLAG) 58 TMP_CMAKE_CASADI_ARGS=$(CMAKE_CASADI_ARGS) 59 TMP_CMAKE_CASADI_COMPILER_ARGS=$(CMAKE_CASADI_COMPILER_ARGS) 60 61 TMP_CASADI_INST_DIR=$(CASADI_INST_DIR) 62 TMP_CASADI_PLUGIN_INST_DIR=$(CASADI_PLUGIN_INST_DIR) 63 TMP_CASADI_PYTHON_INST_DIR=$(CASADI_PYTHON_INST_DIR) 64 TMP_MC_LIB=$(MC_LIB) 65 TMP_MC_BUILD=$(MC_BUILD) 66 67 else 68 BUILD_WITH_PYTHON32_ARG= 69 DEP_SUFFIX=64 70 TMP_CASADI_BUILD_DIR=$(CASADI_BUILD_DIR64) 71 TMP_SWIGCHECK_BUILD_DIR=$(SWIGCHECK_BUILD_DIR64) 72 TMP_CMAKE_CASADI_CXX_FLAG=$(CMAKE_CASADI_CXX_FLAG64) 73 TMP_CMAKE_CASADI_COMPILER_ARGS=$(CMAKE_CASADI_COMPILER_ARGS64) 74 75 # note we set directories to those without 64bit suffix 76 TMP_CASADI_INST_DIR=$(CASADI_INST_DIR) 77 TMP_CASADI_PLUGIN_INST_DIR=$(CASADI_PLUGIN_INST_DIR) 78 TMP_CASADI_PYTHON_INST_DIR=$(CASADI_PYTHON_INST_DIR) 79 TMP_MC_LIB=$(MC_LIB64) 80 TMP_MC_BUILD=$(MC_BUILD64) 81 TMP_CMAKE_CASADI_ARGS=$(CMAKE_CASADI_ARGS64) 82 endif 83 84 52 85 .PHONY: modelicacasadi_wrapper ifcasadi install_modelicacasadi_transfer install_modelicacasadi_wrapper 53 86 … … 55 88 if COMPILE_WITH_IPOPT 56 89 cd $(abs_builddir)/ThirdParty/CasADi; \ 57 make -f Makefile "SWIGCHECK_BUILD_DIR=$( SWIGCHECK_BUILD_DIR)" "CASADI_BUILD_DIR=$(CASADI_BUILD_DIR)" "IPOPT_HOME=$(IPOPT_HOME)" "CASADI_PYTHON_INST_DIR=${CASADI_PYTHON_INST_DIR}" "CASADI_INST_DIR=${CASADI_INST_DIR}" "CASADI_PLUGIN_INST_DIR=${CASADI_PLUGIN_INST_DIR}" "CMAKE_CASADI_ARGS=${CMAKE_CASADI_ARGS}" "CMAKE_CASADI_COMPILER_ARGS=${CMAKE_CASADI_COMPILER_ARGS}" "CMAKE_CASADI_CXX_FLAG=${CMAKE_CASADI_CXX_FLAG}" "CMAKE_PYTHON_LIB=${CMAKE_PYTHON_LIB}"90 make -f Makefile "SWIGCHECK_BUILD_DIR=$(TMP_SWIGCHECK_BUILD_DIR)" "CASADI_BUILD_DIR=$(TMP_CASADI_BUILD_DIR)" "IPOPT_HOME=$(IPOPT_HOME)" "CASADI_PYTHON_INST_DIR=${TMP_CASADI_PYTHON_INST_DIR}" "CASADI_INST_DIR=${TMP_CASADI_INST_DIR}" "CASADI_PLUGIN_INST_DIR=${TMP_CASADI_PLUGIN_INST_DIR}" "CMAKE_CASADI_ARGS=${TMP_CMAKE_CASADI_ARGS}" "CMAKE_CASADI_COMPILER_ARGS=${TMP_CMAKE_CASADI_COMPILER_ARGS}" "CMAKE_CASADI_CXX_FLAG=${TMP_CMAKE_CASADI_CXX_FLAG}" "CMAKE_PYTHON_LIB=${CMAKE_PYTHON_LIB}" 58 91 endif 59 92 if COMPILE_WITH_IPOPT64 … … 69 102 if COMPILE_WITH_IPOPT 70 103 cd $(abs_builddir)/ThirdParty/CasADi; \ 71 make -f Makefile install "SWIGCHECK_BUILD_DIR=$( SWIGCHECK_BUILD_DIR)" "CASADI_BUILD_DIR=$(CASADI_BUILD_DIR)" "IPOPT_HOME=$(IPOPT_HOME)"104 make -f Makefile install "SWIGCHECK_BUILD_DIR=$(TMP_SWIGCHECK_BUILD_DIR)" "CASADI_BUILD_DIR=$(TMP_CASADI_BUILD_DIR)" "IPOPT_HOME=$(IPOPT_HOME)" 72 105 mkdir -p $(DESTDIR)$(prefix)/Python/ 73 cp -r $( CASADI_PYTHON_INST_DIR)/casadi $(DESTDIR)$(prefix)/Python/106 cp -r $(TMP_CASADI_PYTHON_INST_DIR)/casadi $(DESTDIR)$(prefix)/Python/ 74 107 ## temp fix 75 cp $( CASADI_BUILD_DIR)/swig/casadi_core.py $(DESTDIR)$(prefix)/Python/casadi108 cp $(TMP_CASADI_BUILD_DIR)/swig/casadi_core.py $(DESTDIR)$(prefix)/Python/casadi 76 109 endif 77 110 if COMPILE_WITH_IPOPT64 … … 79 112 export PYTHONHOME=$(PYTHON64_HOME); 80 113 cd $(abs_builddir)/ThirdParty/CasADi; \ 81 make -f Makefile install "SWIGCHECK_BUILD_DIR=$(SWIGCHECK_BUILD_DIR )" "CASADI_BUILD_DIR=$(CASADI_BUILD_DIR64)" "IPOPT_HOME=$(IPOPT64_HOME)"114 make -f Makefile install "SWIGCHECK_BUILD_DIR=$(SWIGCHECK_BUILD_DIR64)" "CASADI_BUILD_DIR=$(CASADI_BUILD_DIR64)" "IPOPT_HOME=$(IPOPT64_HOME)" 82 115 mkdir -p $(DESTDIR)$(prefix)/Python/ 83 116 cp -r $(CASADI_PYTHON_INST_DIR64)/casadi $(DESTDIR)$(prefix)/Python_64/ … … 90 123 casadi_interface: install_casadi_interface 91 124 build_casadi_interface: casadi modelicacasadi_wrapper 92 install_casadi_interface: install_casadi $( MC_LIB) $(DESTDIR)$(prefix)/Python/modelicacasadi_transfer/__init__.py $(DESTDIR)$(prefix)/Python/modelicacasadi_wrapper/__init__.py $(DESTDIR)$(prefix)/Python/modelicacasadi_transfer/modelica_casadi_transfer_wrapper.py125 install_casadi_interface: install_casadi $(TMP_MC_LIB) $(DESTDIR)$(prefix)/Python/modelicacasadi_transfer/__init__.py $(DESTDIR)$(prefix)/Python/modelicacasadi_wrapper/__init__.py $(DESTDIR)$(prefix)/Python/modelicacasadi_transfer/modelica_casadi_transfer_wrapper.py 93 126 if [ "$(INSTALL_EXTRA_CASADI)" ]; then exec "$(INSTALL_EXTRA_CASADI)" "$(abs_top_srcdir)" "$(DESTDIR)$(prefix)"; fi 94 127 95 128 ifcasadi: casadi 96 129 if COMPILE_WITH_IPOPT 97 mkdir -p $( MC_BUILD)/ifcasadi; \98 cd $( MC_BUILD)/ifcasadi; \130 mkdir -p $(TMP_MC_BUILD)/ifcasadi; \ 131 cd $(TMP_MC_BUILD)/ifcasadi; \ 99 132 case $(build) in \ 100 133 *-cygwin*|*-mingw*) \ 101 cmake $(MC_SRC_SWIG) -G "MSYS Makefiles" -DCMAKE_CXX_COMPILER_ARG1=" -m32" -DCMAKE_CXX_FLAGS="-m32" \102 -DIFCASADI_OUTDIR="$(MC_CASADI_BUILD)" -DCASADI_HOME="$(CASADI_HOME)" -DCASADI_BUILD_DIR="$( CASADI_BUILD_DIR)";; \134 cmake $(MC_SRC_SWIG) -G "MSYS Makefiles" -DCMAKE_CXX_COMPILER_ARG1="$(TMP_CMAKE_CASADI_CXX_FLAG)" -DCMAKE_CXX_FLAGS="$(TMP_CMAKE_CASADI_CXX_FLAG)" \ 135 -DIFCASADI_OUTDIR="$(MC_CASADI_BUILD)" -DCASADI_HOME="$(CASADI_HOME)" -DCASADI_BUILD_DIR="$(TMP_CASADI_BUILD_DIR)";; \ 103 136 *) \ 104 137 cmake $(MC_SRC_SWIG) \ 105 -DIFCASADI_OUTDIR="$(MC_CASADI_BUILD)" -DCASADI_HOME="$(CASADI_HOME)" -DCASADI_BUILD_DIR="$( CASADI_BUILD_DIR)";; \138 -DIFCASADI_OUTDIR="$(MC_CASADI_BUILD)" -DCASADI_HOME="$(CASADI_HOME)" -DCASADI_BUILD_DIR="$(TMP_CASADI_BUILD_DIR)";; \ 106 139 esac 107 cd $( MC_BUILD)/ifcasadi; make140 cd $(TMP_MC_BUILD)/ifcasadi; make 108 141 endif 109 142 if COMPILE_WITH_IPOPT64 … … 119 152 endif 120 153 121 $( MC_LIB): $(MC_CASADI_BUILD)/bin/ModelicaCompiler.jar $(OC_CASADI_BUILD)/bin/OptimicaCompiler.jar $(MC_CASADI_BUILD)/bin/util.jar ifcasadi122 if COMPILE_WITH_IPOPT 123 rm -rf $( MC_LIB)124 mkdir -p $( MC_LIB)125 cp $(MC_CASADI_BUILD)/bin/ModelicaCompiler.jar $( MC_LIB)126 cp $(OC_CASADI_BUILD)/bin/OptimicaCompiler.jar $( MC_LIB)127 cp $(MC_CASADI_BUILD)/bin/util.jar $( MC_LIB)154 $(TMP_MC_LIB): $(MC_CASADI_BUILD)/bin/ModelicaCompiler.jar $(OC_CASADI_BUILD)/bin/OptimicaCompiler.jar $(MC_CASADI_BUILD)/bin/util.jar ifcasadi 155 if COMPILE_WITH_IPOPT 156 rm -rf $(TMP_MC_LIB) 157 mkdir -p $(TMP_MC_LIB) 158 cp $(MC_CASADI_BUILD)/bin/ModelicaCompiler.jar $(TMP_MC_LIB) 159 cp $(OC_CASADI_BUILD)/bin/OptimicaCompiler.jar $(TMP_MC_LIB) 160 cp $(MC_CASADI_BUILD)/bin/util.jar $(TMP_MC_LIB) 128 161 case $(build) in \ 129 162 *-cygwin*) \ 130 cp $( MC_BUILD)/ifcasadi/ifcasadi.dll $(MC_LIB) ;; \163 cp $(TMP_MC_BUILD)/ifcasadi/ifcasadi.dll $(TMP_MC_LIB) ;; \ 131 164 *-mingw*) \ 132 cp $( MC_BUILD)/ifcasadi/ifcasadi.dll $(MC_LIB) ;; \165 cp $(TMP_MC_BUILD)/ifcasadi/ifcasadi.dll $(TMP_MC_LIB) ;; \ 133 166 *) \ 134 cp $( MC_BUILD)/ifcasadi/libifcasadi.so $(MC_LIB) ;; \167 cp $(TMP_MC_BUILD)/ifcasadi/libifcasadi.so $(TMP_MC_LIB) ;; \ 135 168 esac 136 169 endif … … 160 193 $(OC_CASADI_BUILD)/bin/separateProcess.jar: mc_optimica 161 194 162 $( MC_BUILD)/modelicacasadi_wrapper/swig/modelicacasadi_wrapper.py: modelicacasadi_wrapper163 164 165 modelicacasadi_wrapper: $(MC_CASADI_BUILD)/bin/ModelicaCompiler.jar $(OC_CASADI_BUILD)/bin/OptimicaCompiler.jar $(MC_CASADI_BUILD)/bin/util.jar ifcasadi # $( MC_LIB)166 if COMPILE_WITH_IPOPT 167 mkdir -p $( MC_BUILD)/modelicacasadi_wrapper; \168 cd $( MC_BUILD)/modelicacasadi_wrapper; \195 $(TMP_MC_BUILD)/modelicacasadi_wrapper/swig/modelicacasadi_wrapper.py: modelicacasadi_wrapper 196 197 198 modelicacasadi_wrapper: $(MC_CASADI_BUILD)/bin/ModelicaCompiler.jar $(OC_CASADI_BUILD)/bin/OptimicaCompiler.jar $(MC_CASADI_BUILD)/bin/util.jar ifcasadi # $(TMP_MC_LIB) 199 if COMPILE_WITH_IPOPT 200 mkdir -p $(TMP_MC_BUILD)/modelicacasadi_wrapper; \ 201 cd $(TMP_MC_BUILD)/modelicacasadi_wrapper; \ 169 202 case $(build) in \ 170 203 *-cygwin*|*-mingw*) \ 171 cmake $(MC_INTERFACE) -G "MSYS Makefiles" -DCMAKE_CXX_COMPILER_ARG1=" -m32" -DCMAKE_CXX_FLAGS="-m32" \172 -DMC_BUILD="$( MC_BUILD)" -DIPOPT_HOME="$(IPOPT_HOME)" -DCASADI_BUILD_DIR="$(CASADI_BUILD_DIR)" \204 cmake $(MC_INTERFACE) -G "MSYS Makefiles" -DCMAKE_CXX_COMPILER_ARG1="$(TMP_CMAKE_CASADI_CXX_FLAG)" -DCMAKE_CXX_FLAGS="$(TMP_CMAKE_CASADI_CXX_FLAG)" \ 205 -DMC_BUILD="$(TMP_MC_BUILD)" -DIPOPT_HOME="$(IPOPT_HOME)" -DCASADI_BUILD_DIR="$(TMP_CASADI_BUILD_DIR)" \ 173 206 -DIFCASADI_JAR_BASE="$(JAVA_CASADI_BUILD_DIR)" -DCASADI_HOME="$(CASADI_HOME)" \ 174 207 "$(CMAKE_PYTHON_LIB)" "$(CMAKE_PYTHON_INCLUDE)" ;; \ 175 208 *) \ 176 209 cmake $(MC_INTERFACE) \ 177 -DMC_BUILD="$( MC_BUILD)" -DIPOPT_HOME="$(IPOPT_HOME)" -DCASADI_BUILD_DIR="$(CASADI_BUILD_DIR)" \210 -DMC_BUILD="$(TMP_MC_BUILD)" -DIPOPT_HOME="$(IPOPT_HOME)" -DCASADI_BUILD_DIR="$(TMP_CASADI_BUILD_DIR)" \ 178 211 -DIFCASADI_JAR_BASE="$(JAVA_CASADI_BUILD_DIR)" -DCASADI_HOME="$(CASADI_HOME)" \ 179 212 "$(CMAKE_PYTHON_LIB)" "$(CMAKE_PYTHON_INCLUDE)" ;; \ 180 213 esac 181 cd $( MC_BUILD)/modelicacasadi_wrapper; make modelicacasadi_wrapper214 cd $(TMP_MC_BUILD)/modelicacasadi_wrapper; make modelicacasadi_wrapper 182 215 endif 183 216 if COMPILE_WITH_IPOPT64 … … 200 233 $(DESTDIR)$(prefix)/Python/modelicacasadi_wrapper/__init__.py: install_modelicacasadi_wrapper 201 234 202 install_modelicacasadi_wrapper: $( MC_BUILD)/modelicacasadi_wrapper/swig/modelicacasadi_wrapper.py235 install_modelicacasadi_wrapper: $(TMP_MC_BUILD)/modelicacasadi_wrapper/swig/modelicacasadi_wrapper.py 203 236 if COMPILE_WITH_IPOPT 204 237 mkdir -p $(DESTDIR)$(prefix)/Python/modelicacasadi_wrapper 205 cp $( MC_BUILD)/modelicacasadi_wrapper/swig/*modelicacasadi_wrapper* $(DESTDIR)$(prefix)/Python/modelicacasadi_wrapper238 cp $(TMP_MC_BUILD)/modelicacasadi_wrapper/swig/*modelicacasadi_wrapper* $(DESTDIR)$(prefix)/Python/modelicacasadi_wrapper 206 239 rm -f $(DESTDIR)$(prefix)/Python/modelicacasadi_wrapper/__init__.py 207 240 touch $(DESTDIR)$(prefix)/Python/modelicacasadi_wrapper/__init__.py … … 237 270 238 271 clean-casadi-interface: 239 rm -rf $( MC_BUILD)272 rm -rf $(TMP_MC_BUILD) 240 273 rm -rf $(MC_BUILD64) 241 274 # rm -rf $(DESTDIR)$(prefix)/Python/casadi -
branches/dev-5819/Python/src/pyjmi/examples/cstr_mpc_casadi.py
r13461 r13800 86 86 sim_model.set('_start_T', T_0_A) 87 87 sim_model.set('Tc', 280) 88 init_res = sim_model.simulate(start_time=0., final_time=150) 88 89 opts = sim_model.simulate_options() 90 opts["CVode_options"]["maxh"] = 0.0 91 opts["ncp"] = 0 92 93 init_res = sim_model.simulate(start_time=0., final_time=150, options=opts) 89 94 90 95 ### 2. Define the optimal control problem and solve it using the MPC class … … 159 164 sim_res = sim_model.simulate(start_time=k*sample_period, 160 165 final_time=(k+1)*sample_period, 161 input=u_k )166 input=u_k, options=opts) 162 167 163 168 # Extract state at end of sample_period from sim_res and add Gaussian -
branches/dev-5819/Python/src/pyjmi/examples/if_example_2.py
r4648 r13800 49 49 t = res['time'] 50 50 51 assert N.abs(res.final('x') - 3.5297217) < 1e- 352 assert N.abs(res.final('u') - (-0.2836621)) < 1e- 351 assert N.abs(res.final('x') - 3.5297217) < 1e-2, N.abs(res.final('x') - 3.5297217) 52 assert N.abs(res.final('u') - (-0.2836621)) < 1e-2, N.abs(res.final('u') - (-0.2836621)) 53 53 54 54 if with_plots: -
branches/dev-5819/Python/src/pyjmi/ukf.py
r13461 r13800 368 368 opt['CVode_options']['atol'] = 1e-8 369 369 opt['CVode_options']['rtol'] = 1e-6 370 opt['CVode_options']['maxh'] = 0.0 371 opt['ncp'] = 0 370 372 print('Simulating sigma-point '+str(i+1)+' out of '+str(sigma.shape[1])+' :') 371 373 try: -
branches/dev-5819/Python/src/tests_jmodelica/files/Modelica/ExtFunctionTests.mo
r11759 r13800 1 1 package ExtFunctionTests 2 3 model Evaluator_Double 4 function d_i 5 input Integer a; 6 output Real b; 7 8 external "C" b=f_d_i(a) annotation(Library="evaluatorTestsShared", 9 Include="#include \"evaluatorTests.h\""); 10 end d_i; 11 12 function d_idd 13 input Integer a; 14 input Real b; 15 input Real c; 16 output Real d; 17 18 external "C" d=f_d_idd(a,b,c) annotation(Library="evaluatorTestsShared", 19 Include="#include \"evaluatorTests.h\""); 20 end d_idd; 21 22 23 Real c = d_i(1); 24 Real d = d_idd(1, 2.0, 3.0); 25 end Evaluator_Double; 26 27 model Evaluator_Integer 28 function i_ii 29 input Integer a; 30 input Integer b; 31 output Integer c; 32 33 external "C" c=f_i_ii(a,b) annotation(Library="evaluatorTestsShared", 34 Include="#include \"evaluatorTests.h\""); 35 end i_ii; 36 37 constant Integer c = i_ii(1,2); 38 end Evaluator_Integer; 39 40 model Evaluator_Record 41 record R 42 Real x0; 43 Real x1; 44 Real x2; 45 Real x3; 46 Real x4; 47 Real x5; 48 Real x6; 49 Real x7; 50 Real x8; 51 Real x9; 52 Real x10; 53 end R; 54 function iddpR_ddddddddddd_ 55 input Integer a; 56 input Real b; 57 input Real c; 58 output R d; 59 60 external "C" f___iddpR_ddddddddddd_(a,b,c,d) annotation(Library="evaluatorTestsShared", 61 Include="#include \"evaluatorTests.h\""); 62 end iddpR_ddddddddddd_; 63 64 constant R c = iddpR_ddddddddddd_(1,2.0,3.0); 65 end Evaluator_Record; 66 67 68 model Evaluator_Substring 69 constant String full="Yy00"; 70 constant String sub=Modelica.Utilities.Strings.substring(full,1,1); 71 constant String string1 = "This is line 111"; 72 constant String string2 = Modelica.Utilities.Strings.substring(string1,9,12); // string2 = \"line\" 73 constant Integer len = Modelica.Utilities.Strings.length(string1); 74 constant Integer start = Modelica.Utilities.Strings.Advanced.skipWhiteSpace(" Hello", 1); 75 constant Boolean not_equal = Modelica.Utilities.Strings.isEqual("Temp", "test", true); 76 constant Boolean equal = Modelica.Utilities.Strings.isEqual("Temp", "Temp", true); 77 end Evaluator_Substring; 78 79 model Evaluator_Add 80 function add1 81 input Real a; 82 input Real b; 83 output Real c; 84 85 external "C" c=add(a,b) annotation(Library="addNumbersShared", 86 Include="#include \"addNumbers.h\""); 87 end add1; 88 89 function add2 90 input Real a; 91 input Real b; 92 output Real c; 93 94 external "C" add_output(a,b,c) annotation(Library="addNumbersShared", 95 Include="#include \"addNumbers.h\""); 96 end add2; 97 98 constant Real a = 1; 99 constant Real b = 2; 100 Real c = add1(a,b); 101 Real d = add2(a,b); 102 end Evaluator_Add; 103 104 model Evaluator_Multiple_Add 105 function add 106 input Real a; 107 input Real b; 108 input Real c; 109 input Real d; 110 input Real e; 111 input Real f; 112 input Real g; 113 input Real h; 114 input Real i; 115 output Real o; 116 117 external "C" o=multiple_add(a,b,c,d,e,f,g,h,i) annotation(Library="addNumbersShared", 118 Include="#include \"addNumbers.h\""); 119 end add; 120 121 constant Real a = 1; 122 constant Real b = 2; 123 Real c = add(a,b,a,b,a,b,a,b,a); 124 end Evaluator_Multiple_Add; 125 126 model Evaluator_Unknown_Shared 127 function unknown_function 128 input Real a; 129 output Real b; 130 external "C" b = unknown(a) annotation(Library="unknown"); 131 end unknown_function; 132 133 constant Real a = unknown_function(1.0); 134 end Evaluator_Unknown_Shared; 2 135 3 136 model ExtFunctionTest1 -
branches/dev-5819/Python/src/tests_jmodelica/files/Modelica/Resources/CMakeLists.txt
r13792 r13800 40 40 include_directories(${TOP_SRC}/RuntimeLibrary/src/jmi) 41 41 42 set(EVALUATORTESTS_Sources 43 src/evaluatorTests.c 44 Include/evaluatorTests.h 45 ) 46 42 47 set(ADDNUMBERS_Sources 43 48 src/addNumbers.c … … 72 77 endif() 73 78 79 #Build evaluatorTests library 80 add_library(evaluatorTestsShared SHARED ${EVALUATORTESTS_Sources}) 81 if(NOT MSVC) 82 set_target_properties(evaluatorTestsShared PROPERTIES COMPILE_FLAGS "-Wall -g -std=c89 -pedantic -Werror -O2") 83 endif() 84 74 85 #Build addNumbers library 75 86 add_library(addNumbers STATIC ${ADDNUMBERS_Sources}) 87 add_library(addNumbersShared SHARED ${ADDNUMBERS_Sources}) 76 88 if(NOT MSVC) 77 89 set_target_properties(addNumbers PROPERTIES COMPILE_FLAGS "-Wall -g -std=c89 -pedantic -Werror -O2") 90 set_target_properties(addNumbersShared PROPERTIES COMPILE_FLAGS "-Wall -g -std=c89 -pedantic -Werror -O2") 78 91 endif() 79 92 … … 108 121 109 122 #Install the libraries 123 install(TARGETS evaluatorTestsShared DESTINATION "${TEST_LIBRARY_INSTALL_DIR}") 110 124 install(TARGETS addNumbers DESTINATION "${TEST_LIBRARY_INSTALL_DIR}") 125 install(TARGETS addNumbersShared DESTINATION "${TEST_LIBRARY_INSTALL_DIR}") 111 126 install(TARGETS arrayFunctions DESTINATION "${TEST_LIBRARY_INSTALL_DIR}") 112 127 install(TARGETS externalFunctionsC DESTINATION "${TEST_LIBRARY_INSTALL_DIR}") -
branches/dev-5819/Python/src/tests_jmodelica/files/Modelica/Resources/Include/addNumbers.h
r3965 r13800 2 2 #define ADDNUMBERS_H 3 3 4 double add(double a, double b); 4 #if defined _WIN32 5 #define DllExport __declspec(dllexport) 6 #else 7 #define DllExport 8 #endif 9 10 DllExport double add(double a, double b); 11 DllExport void add_output(double a, double b, double *c); 12 DllExport double multiple_add(double a, double b, double c, double d, double e, double f, double g, double h, double i); 5 13 void multiplyAnArray(int* inputs, int* outputs, int size, int m); 6 14 -
branches/dev-5819/Python/src/tests_jmodelica/files/Modelica/Resources/src/addNumbers.c
r6459 r13800 1 1 #include "addNumbers.h" 2 2 3 double add(double a, double b)3 DllExport double add(double a, double b) 4 4 { 5 return a+b; 5 return a + b; 6 } 7 8 DllExport void add_output(double a, double b, double *c) 9 { 10 *c = a + b; 11 } 12 13 DllExport double multiple_add(double a, double b, double c, double d, double e, double f, double g, double h, double i) 14 { 15 return a+b+c+d+e+f+g+h+i; 6 16 } 7 17 -
branches/dev-5819/Python/src/tests_jmodelica/general/base_simul.py
r13461 r13800 286 286 287 287 if not cvode_options: 288 cvode_options = {'atol':self.abs_tol,'rtol':self.rel_tol} 288 cvode_options = {'atol':self.abs_tol,'rtol':self.rel_tol, 'maxh':0.0} 289 else: 290 if not 'maxh' in cvode_options: 291 cvode_options['maxh'] = 0.0 289 292 290 293 if isinstance(self.model, FMUModelME1) or isinstance(self.model, FMUModelME2): -
branches/dev-5819/Python/src/tests_jmodelica/general/test_extfunctions.py
r13461 r13800 22 22 23 23 import nose 24 import fnmatch 24 25 25 26 from pymodelica import compile_fmu 26 27 from pymodelica.common.core import get_platform_dir, create_temp_dir 27 from pyfmi import load_fmu 28 from pyfmi import load_fmu, FMUModelME2 28 29 from pyfmi.fmi import FMUException 29 30 from tests_jmodelica import testattr, get_files_path … … 33 34 path_to_mofiles = os.path.join(get_files_path(), 'Modelica') 34 35 36 class TestEvaluator: 37 @classmethod 38 def setUpClass(cls): 39 """ 40 Sets up the test class. 41 """ 42 cls.fpath = path(path_to_mofiles, "ExtFunctionTests.mo") 43 44 @testattr(stddist_base = True) 45 def test_builtin_substring(self): 46 cpath = "ExtFunctionTests.Evaluator_Substring" 47 fmu_name = compile_fmu(cpath, self.fpath, compiler_options={"external_constant_evaluation_dynamic":True}, compiler_log_level="d:log.txt") 48 49 nbr_of_evaluator_calls = 0 50 with open("log.txt") as f: 51 res = fnmatch.filter(f, "Succesfully connected external function '*' to the evaluator*") 52 nbr_of_evaluator_calls = len(res) 53 54 assert nbr_of_evaluator_calls == 4, "Wrong number of external function calls, check log." 55 56 model = load_fmu(fmu_name) 57 58 assert model.get("sub")[0] == "Y", model.get("sub") 59 assert model.get("string2")[0] == "line", model.get("string2") 60 assert model.get("len") == 16, model.get("len") 61 assert model.get("start") == 4, model.get("start") 62 assert not model.get("not_equal"), model.get("not_equal") 63 assert model.get("equal"), model.get("equal") 64 65 @testattr(stddist_base = True) 66 def test_add(self): 67 cpath = "ExtFunctionTests.Evaluator_Add" 68 fmu_name = compile_fmu(cpath, self.fpath, compiler_options={"external_constant_evaluation_dynamic":True}, version=2.0, compiler_log_level="d:log.txt") 69 70 nbr_of_evaluator_calls = 0 71 with open("log.txt") as f: 72 res = fnmatch.filter(f, "Succesfully connected external function '*' to the evaluator*") 73 nbr_of_evaluator_calls = len(res) 74 75 assert nbr_of_evaluator_calls == 2, "Wrong number of external function calls, check log." 76 77 model = FMUModelME2(fmu_name, _connect_dll=False) 78 79 assert model.get_variable_start("c") == 3, model.get_variable_start("c") 80 assert model.get_variable_start("d") == 3, model.get_variable_start("d") 81 82 @testattr(stddist_base = True) 83 def test_unsupported_signature(self): 84 cpath = "ExtFunctionTests.Evaluator_Multiple_Add" 85 fmu_name = compile_fmu(cpath, self.fpath, compiler_options={"external_constant_evaluation_dynamic":True}, compiler_log_level="d:log.txt") 86 87 matches = 0 88 with open("log.txt") as f: 89 res = fnmatch.filter(f, "*is not supported. Disabling use of the evaluator*") 90 matches = len(res) 91 92 assert matches == 1, "Does not seem to disabling the evaluator" 93 94 @testattr(stddist_base = True) 95 def test_unknown_shared_library(self): 96 cpath = "ExtFunctionTests.Evaluator_Unknown_Shared" 97 try: 98 fmu_name = compile_fmu(cpath, self.fpath, compiler_options={"external_constant_evaluation_dynamic":True}, compiler_log_level="d:log_unknown_shared.txt") 99 except: #The compilation will fail, the interesting parts will though still be contained in the log file 100 pass 101 102 matches = 0 103 with open("log_unknown_shared.txt") as f: 104 res = fnmatch.filter(f, "Could not find a shared library containing*") 105 matches = len(res) 106 107 assert matches == 1, "Seems to have found an unknown shared library" 108 109 @testattr(stddist_base = True) 110 def test_double_return(self): 111 cpath = "ExtFunctionTests.Evaluator_Double" 112 fmu_name = compile_fmu(cpath, self.fpath, compiler_options={"external_constant_evaluation_dynamic":True}, version=2.0, compiler_log_level="d:log.txt") 113 114 nbr_of_evaluator_calls = 0 115 with open("log.txt") as f: 116 res = fnmatch.filter(f, "Succesfully connected external function '*' to the evaluator*") 117 nbr_of_evaluator_calls = len(res) 118 119 assert nbr_of_evaluator_calls == 2, "Wrong number of external function calls, check log." 120 121 model = FMUModelME2(fmu_name, _connect_dll=False) 122 123 assert model.get_variable_start("c") == 3.0, model.get_variable_start("c") 124 assert model.get_variable_start("d") == 9.0, model.get_variable_start("d") 125 126 @testattr(stddist_base = True) 127 def test_integer_return(self): 128 cpath = "ExtFunctionTests.Evaluator_Integer" 129 fmu_name = compile_fmu(cpath, self.fpath, compiler_options={"external_constant_evaluation_dynamic":True}, version=2.0, compiler_log_level="d:log.txt") 130 131 nbr_of_evaluator_calls = 0 132 with open("log.txt") as f: 133 res = fnmatch.filter(f, "Succesfully connected external function '*' to the evaluator*") 134 nbr_of_evaluator_calls = len(res) 135 136 assert nbr_of_evaluator_calls == 1, "Wrong number of external function calls, check log." 137 138 model = FMUModelME2(fmu_name, _connect_dll=False) 139 140 assert model.get_variable_start("c") == 3.0, model.get_variable_start("c") 141 142 @testattr(stddist_base = True) 143 def test_record(self): 144 cpath = "ExtFunctionTests.Evaluator_Record" 145 fmu_name = compile_fmu(cpath, self.fpath, compiler_options={"external_constant_evaluation_dynamic":True}, version=2.0, compiler_log_level="d:log.txt") 146 147 nbr_of_evaluator_calls = 0 148 with open("log.txt") as f: 149 res = fnmatch.filter(f, "Succesfully connected external function '*' to the evaluator*") 150 nbr_of_evaluator_calls = len(res) 151 152 assert nbr_of_evaluator_calls == 1, "Wrong number of external function calls, check log." 153 154 model = FMUModelME2(fmu_name, _connect_dll=False) 155 156 assert model.get_variable_start("c.x0") == 1.0, model.get_variable_start("c.x0") 157 assert model.get_variable_start("c.x1") == 2.0, model.get_variable_start("c.x1") 158 assert model.get_variable_start("c.x2") == 3.0, model.get_variable_start("c.x2") 159 assert model.get_variable_start("c.x3") == 3.0, model.get_variable_start("c.x3") 160 assert model.get_variable_start("c.x4") == 4.0, model.get_variable_start("c.x4") 161 assert model.get_variable_start("c.x5") == 5.0, model.get_variable_start("c.x5") 162 assert model.get_variable_start("c.x6") == 6.0, model.get_variable_start("c.x6") 163 assert model.get_variable_start("c.x7") == 7.0, model.get_variable_start("c.x7") 164 assert model.get_variable_start("c.x8") == 8.0, model.get_variable_start("c.x8") 165 assert model.get_variable_start("c.x9") == 9.0, model.get_variable_start("c.x9") 166 assert model.get_variable_start("c.x10") == 10.0, model.get_variable_start("c.x10") 167 35 168 class TestExternalStatic: 36 169 -
branches/dev-5819/Python/src/tests_jmodelica/optimization/test_casadi_collocation.py
r13600 r13800 366 366 opts["CVode_options"]["rtol"] = 1e-6 367 367 opts["CVode_options"]["atol"] = 1e-8 * model.nominal_continuous_states 368 opts["CVode_options"]["maxh"] = 0.0 369 opts["ncp"] = 0 368 370 init_res = model.simulate(final_time=300, input=('Tc', u_traj), 369 371 options=opts) … … 2125 2127 opts["CVode_options"]["rtol"] = 1e-6 2126 2128 opts["CVode_options"]["atol"] = 1e-8 * model.nominal_continuous_states 2129 opts["CVode_options"]["maxh"] = 0.0 2130 opts["ncp"] = 0 2127 2131 res = model.simulate(start_time=0., final_time=150., input=opt_input, 2128 2132 options=opts) -
branches/dev-5819/Python/src/tests_jmodelica/optimization/test_realtime_mpc.py
r13600 r13800 35 35 def check_result(results, ref): 36 36 for key in ref: 37 assert abs(ref[key] - results[key][-1]) < 1e- 3, abs(ref[key] - results[key][-1])37 assert abs(ref[key] - results[key][-1]) < 1e-2, abs(ref[key] - results[key][-1]) 38 38 39 39 -
branches/dev-5819/Python/src/tests_jmodelica/simulation/test_assimulo_interface_fmi.py
r13795 r13800 2014 2014 opts["CVode_options"]["rtol"] = 1e-4 2015 2015 opts["CVode_options"]["atol"] = 1e-6 2016 opts["CVode_options"]["maxh"] = 0.0 2017 opts["ncp"] = 0 2016 2018 res = bounce.simulate(start_time=2.,final_time=5.,options=opts) 2017 2019 … … 2032 2034 opts["CVode_options"]["rtol"] = 1e-4 2033 2035 opts["CVode_options"]["atol"] = 1e-6 2036 opts["CVode_options"]["maxh"] = 0.0 2037 opts["ncp"] = 0 2034 2038 res = bounce.simulate(final_time=3., options=opts) 2035 2039 … … 2045 2049 opt["CVode_options"]["rtol"] = 1e-4 2046 2050 opt["CVode_options"]["atol"] = 1e-6 2051 opt["CVode_options"]["maxh"] = 0.0 2052 opt["ncp"] = 0 2047 2053 res = bounce.simulate(final_time=3., options=opt) 2048 2054 … … 2071 2077 opts["CVode_options"]["rtol"] = 1e-4 2072 2078 opts["CVode_options"]["atol"] = 1e-6 2079 opts["CVode_options"]["maxh"] = 0.0 2080 opts["ncp"] = 0 2073 2081 res = bounce.simulate(final_time=3., options=opts) 2074 2082 … … 2082 2090 #Writing continuous 2083 2091 bounce = load_fmu('bouncingBall.fmu', path_to_fmus_me1) 2084 #bounce.initialize(options={'initialize':False})2085 2092 res = bounce.simulate(final_time=3., 2086 options={'initialize':True,' CVode_options':{'iter':'FixedPoint','rtol':1e-6,'atol':1e-6}})2093 options={'initialize':True,'ncp':0, 'CVode_options':{'maxh':0.0, 'iter':'FixedPoint','rtol':1e-6,'atol':1e-6}}) 2087 2094 2088 2095 N.testing.assert_almost_equal(res.solver.rtol, 0.00000100, 7) … … 2104 2111 opts["CVode_options"]["rtol"] = 1e-4 2105 2112 opts["CVode_options"]["atol"] = 1e-6 2106 #bounce.initialize() 2113 opts["CVode_options"]["maxh"] = 0.0 2114 opts["ncp"] = 0 2107 2115 res = bounce.simulate(final_time=3., options=opts) 2108 2116 … … 2111 2119 2112 2120 bounce.reset() 2113 #bounce.initialize() 2114 2121 2115 2122 N.testing.assert_almost_equal(bounce.get('h'), 1.00000,5) 2116 2123 -
branches/dev-5819/Python/src/tests_jmodelica/test_delay.py
r13461 r13800 38 38 def simulate(fmu, final_time, maxh = None): 39 39 opts = fmu.simulate_options() 40 opts['solver'] = 'CVode' 40 opts['solver'] = 'CVode' 41 opts['ncp'] = 0 42 opts['CVode_options']['maxh'] = 0.0 41 43 if maxh is not None: 42 44 opts['CVode_options']['maxh'] = maxh -
branches/dev-5819/Python/src/tests_jmodelica/test_fmi_2.py
r13600 r13800 988 988 assert opts['initialize'] 989 989 assert opts['with_jacobian'] == "Default" 990 assert opts['ncp'] == 0991 990 992 991 #Test the result file -
branches/dev-5819/Python/src/tests_jmodelica/test_fmi_coupled.py
r13600 r13800 82 82 nose.tools.assert_almost_equal(res.final("time"),1.5) 83 83 nose.tools.assert_almost_equal(res.final("First.J1.w"),res.final("Second.J1.w")) 84 nose.tools.assert_almost_equal(res.final("First.J1.w"), 3.2501079, places= 3)84 nose.tools.assert_almost_equal(res.final("First.J1.w"), 3.2501079, places=2) 85 85 86 86 coupled.reset() … … 90 90 nose.tools.assert_almost_equal(res.final("time"),1.5) 91 91 nose.tools.assert_almost_equal(res.final("First.J1.w"),res.final("Second.J1.w")) 92 nose.tools.assert_almost_equal(res.final("First.J1.w"), 3.2501079, places= 3)92 nose.tools.assert_almost_equal(res.final("First.J1.w"), 3.2501079, places=2) 93 93 94 94 @testattr(stddist_full = True) -
branches/dev-5819/RuntimeLibrary/CMakeLists.txt
r9663 r13800 55 55 if(" ${CMAKE_C_FLAGS} " MATCHES " -m64 ") 56 56 set(RTLIB_LIB_DIR ${JMODELICA_INSTALL_DIR}/lib/RuntimeLibrary64) 57 set(RTLIB_BIN_DIR ${JMODELICA_INSTALL_DIR}/bin64) 57 58 else() 58 59 set(RTLIB_LIB_DIR ${JMODELICA_INSTALL_DIR}/lib/RuntimeLibrary) 60 set(RTLIB_BIN_DIR ${JMODELICA_INSTALL_DIR}/bin) 59 61 endif() 60 62 install(CODE "file(MAKE_DIRECTORY $ENV{DESTDIR}${RTLIB_LIB_DIR})") … … 91 93 add_subdirectory(src/modules) 92 94 95 #Add evaluator 96 include_directories(src/evaluator) 97 add_subdirectory(src/evaluator) 93 98 94 99 if(EXTRA_RUNTIME_MODULES) -
branches/dev-5819/RuntimeLibrary/Makefiles/Makefile.linux
r10938 r13800 126 126 LIBS_FMUCS10 = -lfmi1_cs -lfmi1_me $(LIBS_FMU_STD) $(LIB_COMMON) -l:libsundials_cvode.a 127 127 LIBS_FMU20 = -lfmi2 $(LIBS_FMU_STD) $(LIB_COMMON) -l:libsundials_cvode.a 128 LIBS_CEVAL = $(LIBS_FMU_STD)128 LIBS_CEVAL = -ljmi_evaluator_util $(LIBS_FMU_STD) 129 129 130 130 # Include paths for compilation -
branches/dev-5819/RuntimeLibrary/Makefiles/Makefile.macosx
r10938 r13800 125 125 LIBS_FMUCS10 = -lfmi1_cs -lfmi1_me $(LIBS_FMU_STD) $(LIB_COMMON) $(SUNDIALS_HOME)/lib/libsundials_cvode.a 126 126 LIBS_FMU20 = -lfmi2 $(LIBS_FMU_STD) $(LIB_COMMON) $(SUNDIALS_HOME)/lib/libsundials_cvode.a 127 LIBS_CEVAL = $(LIBS_FMU_STD)127 LIBS_CEVAL = -ljmi_evaluator_util $(LIBS_FMU_STD) 128 128 129 129 # Include paths for compilation -
branches/dev-5819/RuntimeLibrary/Makefiles/Makefile.windows
r11565 r13800 160 160 LIBS_FMUCS10 = -lfmi1_cs -lfmi1_me $(LIBS_FMU_ALL) 161 161 LIBS_FMU20 = -lfmi2 $(LIBS_FMU_ALL) 162 LIBS_CEVAL = $(LIBS_FMU_STD)162 LIBS_CEVAL = -ljmi_evaluator_util $(LIBS_FMU_STD) 163 163 164 164 # Include paths for compilation -
branches/dev-5819/RuntimeLibrary/src
- Property svn:mergeinfo changed
/branches/dev-cw-evaluator/RuntimeLibrary/src (added) merged: 13436,13440,13465,13534,13548,13553,13562,13570,13572-13573,13602,13712 /trunk/RuntimeLibrary/src merged: 13700,13703,13719
- Property svn:mergeinfo changed
-
branches/dev-5819/RuntimeLibrary/src/fmi1_cs/CMakeLists.txt
r6737 r13800 37 37 38 38 #Install the libraries 39 install(TARGETS fmi1_cs DESTINATION "${RTLIB_LIB_DIR}") 39 if (NOT MSVC) 40 install(TARGETS fmi1_cs DESTINATION "${RTLIB_LIB_DIR}") 41 endif() 40 42 41 43 #Install header files -
branches/dev-5819/RuntimeLibrary/src/fmi1_me/CMakeLists.txt
r6737 r13800 39 39 40 40 #Install the libraries 41 install(TARGETS fmi1_me DESTINATION "${RTLIB_LIB_DIR}") 41 if (NOT MSVC) 42 install(TARGETS fmi1_me DESTINATION "${RTLIB_LIB_DIR}") 43 endif() 42 44 43 45 #Install header files -
branches/dev-5819/RuntimeLibrary/src/fmi2/CMakeLists.txt
r6737 r13800 49 49 50 50 #Install the libraries 51 install(TARGETS fmi2 DESTINATION "${RTLIB_LIB_DIR}") 51 if (NOT MSVC) 52 install(TARGETS fmi2 DESTINATION "${RTLIB_LIB_DIR}") 53 endif() 52 54 53 55 #Install header files -
branches/dev-5819/RuntimeLibrary/src/jmi/CMakeLists.txt
r12148 r13800 202 202 203 203 #Install the libraries 204 install(TARGETS jmi 205 DESTINATION "${RTLIB_LIB_DIR}") 204 if (NOT MSVC) 205 install(TARGETS jmi 206 DESTINATION "${RTLIB_LIB_DIR}") 207 endif() 206 208 207 209 #Install header files … … 247 249 248 250 #Install the libraries 249 install(TARGETS ModelicaExternalC ModelicaStandardTables ModelicaIO ModelicaMatIO zlib 250 DESTINATION "${RTLIB_LIB_DIR}") 251 if (NOT MSVC) 252 install(TARGETS ModelicaExternalC ModelicaStandardTables ModelicaIO ModelicaMatIO zlib 253 DESTINATION "${RTLIB_LIB_DIR}") 254 endif() 251 255 252 256 install(DIRECTORY "${MSLCSOURCES}/"
Note: See TracChangeset
for help on using the changeset viewer.