Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Jun 24 18:22

    axkr on master

    clean up Fix #525 - Series of rational f… (compare)

  • Jun 24 18:10
    axkr edited #545
  • Jun 24 18:10
    axkr opened #545
  • Jun 24 05:34

    dependabot[bot] on maven

    (compare)

  • Jun 24 05:34

    axkr on master

    Bump RoaringBitmap from 0.9.28 … (compare)

  • Jun 24 05:34
    axkr closed #544
  • Jun 24 04:19
    gitpod-io[bot] commented #544
  • Jun 24 04:19
    dependabot[bot] labeled #544
  • Jun 24 04:19
    dependabot[bot] labeled #544
  • Jun 24 04:19
    dependabot[bot] opened #544
  • Jun 24 04:19

    dependabot[bot] on maven

    Bump RoaringBitmap from 0.9.28 … (compare)

  • Jun 21 16:24

    axkr on master

    clean up Define INumber#isZero(double to… WIP #538 Implement solving meth… (compare)

  • Jun 20 16:52
    axkr closed #543
  • Jun 20 16:52

    axkr on master

    Fix #543 don't cast ClassLoader… (compare)

  • Jun 20 16:13
    axkr opened #543
  • Jun 20 15:59

    dependabot[bot] on maven

    (compare)

  • Jun 20 15:59
    axkr closed #541
  • Jun 20 15:59

    axkr on master

    Bump lucene-analyzers-common fr… (compare)

  • Jun 20 04:19
    gitpod-io[bot] commented #541
  • Jun 20 04:19
    dependabot[bot] labeled #541
TiMauzi
@TiMauzi
@axkr Different question... does Symja have a method to get all literals within an IExpr object? E.g. if I have "a || b && c || c", is there a function that returns "[a, b, c, c]"?
TiMauzi
@TiMauzi
@axkr Awesome, thank you!
TiMauzi
@TiMauzi
@axkr And is there a method to invert a logical expression with De Morgan's Laws? Something like "a || b" => "!(!a && !b)"?
TiMauzi
@TiMauzi
Something like "use only '&&' and '!' but no '||'"
TiMauzi
@TiMauzi

Nice, I think I managed already:

deMorgan1 = {x_ || y_ :> !(!x && !y)}
deMorgan2 = {x_ && y_ :> !(!x || !y)}
ReplaceRepeated(fox || rabbit || chicken, deMorgan1)

... leads to: ¬(¬fox∧¬rabbit∧¬chicken), perfect :)

Axel Kramer
@axkr
@TiMauzi I'm not sure what you want to get exactly, but BooleanConvert may also be an option?
TiMauzi
@TiMauzi
No, this is not what I want, since "a || b || c" would always stay the same with BooleanConvert, while I want it to become "!(!a && !b && !c)".
I want to write a formula with only "&&"s or only "||"s, and I think that's what my deMorgan1/deMorgan2 replacements are doing
TiMauzi
@TiMauzi

The BooleanVariables() function use this internally https://github.com/axkr/symja_android_library/blob/master/symja_android_library/doc/functions/BooleanVariables.md

@axkr Is there a way of outputting the list/set created by BooleanVariables() or Variables() to a Java list or Java array?

Without doing some usual pattern matching, of course :)
Axel Kramer
@axkr
@TiMauzi something like this?
private static List<IExpr> booleanVariables(final IExpr expr) {
      VariablesSet eVar = new VariablesSet();
      eVar.addBooleanVarList(expr);
      return eVar.getArrayList(); 
}
TiMauzi
@TiMauzi
I did it the following way now:
private static String[] getVariablesArray(IExpr variables) throws MathException, StackOverflowError, OutOfMemoryError {
    return variables.toString()
            .replaceAll("\\{", "")
            .replaceAll("}", "")
            .replaceAll(" ", "")
            .split(",");
}
With IExpr calcExpr = evaluator.eval("Variables(" + calc + ")"); and calc being my formula
And then getVariablesArray(calcExpr);
Since I need the string representation anyway, I think the effort is similar, no?
Axel Kramer
@axkr
If you use regex it might be slower:
TiMauzi
@TiMauzi
Good to know, thanks for the hint!
I'll try your approach later, then :)
TiMauzi
@TiMauzi

@axkr In https://github.com/axkr/symja_android_library/blob/d1e78f694be9b7b0bea4abbacbd924c8512adc38/symja_android_library/matheclipse-core/src/main/java/org/matheclipse/core/expression/F.java#L3907 there is the following part of the code:

        String autoload = ".\\Autoload";
        if (FEConfig.PARSER_USE_LOWERCASE_SYMBOLS) {
          autoload = ".\\AutoloadSymja";
        }
        File sourceLocation = new File(autoload);

Symja creates a file here. Since I'm writing an Elasticsearch plugin, creating files doesn't seem to be allowed. Is there a way of using Symja without addtional files being implicitly created by ExprEvaluator?

Axel Kramer
@axkr
@TiMauzi can you please try something like this for automatically loading init scripts:
Axel Kramer
@axkr
try {
          String autoload = ".\\Autoload";
          if (FEConfig.PARSER_USE_LOWERCASE_SYMBOLS) {
            autoload = ".\\AutoloadSymja";
          }
          File sourceLocation = new File(autoload);
          final String[] files = sourceLocation.list();
          if (files != null) {
            for (int i = 0; i < files.length; i++) {
              if (files[i].endsWith(".m")) {
                File sourceFile = new File(sourceLocation, files[i]);
                FileFunctions.Get.loadPackage(EvalEngine.get(), sourceFile);
              }
            }
          }
        } catch (java.security.AccessControlException acex) {
          // no read access for current user
          acex.printStackTrace();
        } catch (RuntimeException ex) {
          ex.printStackTrace();
        }
TiMauzi
@TiMauzi

@axkr Following output if I place this test right in front of the part of my plugin that crashes when executed:

[2021-05-14T00:21:32,244][WARN ][stderr                   ] [TIM] java.security.AccessControlException: access denied ("java.io.FilePermission" ".\AutoloadSymja" "read")
[2021-05-14T00:21:32,245][WARN ][stderr                   ] [TIM]       at java.base/java.security.AccessControlContext.checkPermission(AccessControlContext.java:472)
[2021-05-14T00:21:32,246][WARN ][stderr                   ] [TIM]       at java.base/java.security.AccessController.checkPermission(AccessController.java:1036)
[2021-05-14T00:21:32,246][WARN ][stderr                   ] [TIM]       at java.base/java.lang.SecurityManager.checkPermission(SecurityManager.java:408)
[2021-05-14T00:21:32,246][WARN ][stderr                   ] [TIM]       at java.base/java.lang.SecurityManager.checkRead(SecurityManager.java:747)
[2021-05-14T00:21:32,247][WARN ][stderr                   ] [TIM]       at java.base/java.io.File.list(File.java:1131)
[2021-05-14T00:21:32,247][WARN ][stderr                   ] [TIM]       at org.elasticsearch.index.search.CommutingQuantumScorer.score(CommutingQuantumScorer.java:96)
...

(The last method before I skipped the rest is the method I placed the test in.)

TiMauzi
@TiMauzi
I found out that Elasticsearch doesn't want people to have any FilePermission. That's why I asked if there is any way to not letting Symja create some file
Axel Kramer
@axkr
@TiMauzi If you don't need any scripts, do you need an option to simply skip the autoload part?
TiMauzi
@TiMauzi
What kind of "scripts" do you mean?
formulaEvaluator.eval("deMorganDisCon = {x_ || y_ :> !(!x && !y)}");
formulaEvaluator.eval("deMorganConDis = {x_ && y_ :> !(!x || !y)}");
Something like this? ^-^' @axkr
If you mean this, then it might hurt a bit but I might be able to solve it in another way.
Axel Kramer
@axkr
I meant "script" packages which could be automatically loaded on startup like this one: https://github.com/axkr/symja_android_library/wiki/context
TiMauzi
@TiMauzi
Oh you mean that >>I<< want to use external files? Then no
In this case I don't need any scripts
I just need the basic symja functionalities @axkr
TiMauzi
@TiMauzi
@axkr So you mentioned an option to skip the autoload part, is there any I'm not aware of? :O
Axel Kramer
@axkr
no I have to introduce it.
I think I will simply skip the part and do some logging like this:
private static final Logger logger = LogManager.getLogger(F.class);

...

...
      try {  
...

...
        } catch (java.security.AccessControlException acex) {
          // no read access for current user
          logger.warn("Cannot read packages in autoload folder:", acex); 
        } catch (RuntimeException ex) {
          logger.error(ex); 
        }
TiMauzi
@TiMauzi
That looks reasonable :)
TiMauzi
@TiMauzi

@axkr Also, part of Symja seems to need the RuntimePermission "shutdownHooks":

[2021-05-14T17:52:09,382][WARN ][stderr                   ] [TIM] java.lang.ExceptionInInitializerError
[2021-05-14T17:52:09,382][WARN ][stderr                   ] [TIM]       at org.matheclipse.core.expression.F.<clinit>(F.java:599)
[2021-05-14T17:52:09,383][WARN ][stderr                   ] [TIM]       at org.matheclipse.core.eval.ExprEvaluator.<clinit>(ExprEvaluator.java:133)
...
[2021-05-14T17:52:09,391][WARN ][stderr                   ] [TIM] Caused by: org.apfloat.ApfloatConfigurationException: Error setting property "cleanupAtExit" to value "true"
[2021-05-14T17:52:09,392][WARN ][stderr                   ] [TIM]       at org.apfloat.ApfloatContext.setProperty(ApfloatContext.java:1025)
[2021-05-14T17:52:09,392][WARN ][stderr                   ] [TIM]       at org.apfloat.ApfloatContext.setProperties(ApfloatContext.java:1270)
[2021-05-14T17:52:09,392][WARN ][stderr                   ] [TIM]       at org.apfloat.ApfloatContext.<init>(ApfloatContext.java:331)
[2021-05-14T17:52:09,392][WARN ][stderr                   ] [TIM]       at org.apfloat.ApfloatContext.<clinit>(ApfloatContext.java:1388)
[2021-05-14T17:52:09,393][WARN ][stderr                   ] [TIM]       ... 28 more
[2021-05-14T17:52:09,393][WARN ][stderr                   ] [TIM] Caused by: java.security.AccessControlException: access denied ("java.lang.RuntimePermission" "shutdownHooks")
[2021-05-14T17:52:09,393][WARN ][stderr                   ] [TIM]       at java.base/java.security.AccessControlContext.checkPermission(AccessControlContext.java:472)
...

I assume it is caused by the property cleanupAtExit. Is it possible to not let it being set to true?

Axel Kramer
@axkr
@TiMauzi my environment is different from yours. Can you test, if the ApfloatContextcan be changed here:
by adding a line
ctx.setCleanupAtExit(false);
TiMauzi
@TiMauzi
Okay, give me a second
Just a question, you mean in my own code, right?
Because I don't have any ApfloatContext object there
Since it's implicitly created by ExprEvaluator
Axel Kramer
@axkr
Oh, I'd thought you already used a modified Symja version?
TiMauzi
@TiMauzi
No, not at all
Axel Kramer
@axkr
Ok then lets add in your code this test: