use of org.matheclipse.core.convert.CreamConvert in project symja_android_library by axkr.
the class Solve method solveIntegers.
public static IExpr solveIntegers(final IAST ast, IAST equationVariables, IAST userDefinedVariables, int maximumNumberOfResults, EvalEngine engine) {
if (!userDefinedVariables.isEmpty()) {
IAST equationsAndInequations = Validate.checkEquationsAndInequations(ast, 1);
if (equationsAndInequations.isEmpty()) {
return F.NIL;
}
try {
// if (ToggleFeature.CHOCO_SOLVER) {
// // try calling choco solver
// if (equationsAndInequations.isFreeAST(x -> x.equals(S.Power))) {
// try {
// IAST resultList =
// ChocoConvert.integerSolve(
// equationsAndInequations,
// equationVariables,
// userDefinedVariables,
// engine);
// if (resultList.isPresent()) {
// EvalAttributes.sort((IASTMutable) resultList);
// return resultList;
// }
// } catch (RuntimeException rex) {
// // try 2nd solver
// }
// }
// }
// call cream solver
CreamConvert converter = new CreamConvert();
IAST resultList = converter.integerSolve(equationsAndInequations, equationVariables, userDefinedVariables, maximumNumberOfResults, engine);
if (resultList.isPresent()) {
EvalAttributes.sort((IASTMutable) resultList);
return resultList;
}
} catch (LimitException le) {
LOGGER.debug("Solve.of() failed", le);
throw le;
} catch (RuntimeException rex) {
LOGGER.log(engine.getLogLevel(), "Integers solution not found", rex);
return F.NIL;
}
}
return F.NIL;
}
Aggregations