2021-07-24 02:37:17 +00:00
|
|
|
package androidx.constraintlayout.solver;
|
|
|
|
|
|
|
|
import androidx.constraintlayout.solver.SolverVariable;
|
|
|
|
import androidx.constraintlayout.solver.widgets.ConstraintAnchor;
|
|
|
|
import androidx.constraintlayout.solver.widgets.ConstraintWidget;
|
2021-12-17 21:59:34 +00:00
|
|
|
import b.d.b.a.a;
|
2021-08-09 22:51:56 +00:00
|
|
|
import com.discord.widgets.chat.input.autocomplete.AutocompleteViewModel;
|
2021-07-24 02:37:17 +00:00
|
|
|
import java.io.PrintStream;
|
|
|
|
import java.util.Arrays;
|
|
|
|
import java.util.HashMap;
|
2022-03-07 09:34:54 +00:00
|
|
|
/* loaded from: classes.dex */
|
2021-07-24 02:37:17 +00:00
|
|
|
public class LinearSystem {
|
|
|
|
public static long ARRAY_ROW_CREATION = 0;
|
|
|
|
public static final boolean DEBUG = false;
|
|
|
|
private static final boolean DEBUG_CONSTRAINTS = false;
|
|
|
|
public static final boolean FULL_DEBUG = false;
|
|
|
|
public static final boolean MEASURE = false;
|
|
|
|
public static long OPTIMIZED_ARRAY_ROW_CREATION = 0;
|
|
|
|
public static boolean OPTIMIZED_ENGINE = false;
|
|
|
|
private static int POOL_SIZE = 1000;
|
|
|
|
public static boolean SIMPLIFY_SYNONYMS = true;
|
|
|
|
public static boolean SKIP_COLUMNS = true;
|
|
|
|
public static boolean USE_BASIC_SYNONYMS = true;
|
|
|
|
public static boolean USE_DEPENDENCY_ORDERING = false;
|
|
|
|
public static boolean USE_SYNONYMS = true;
|
|
|
|
public static Metrics sMetrics;
|
|
|
|
public final Cache mCache;
|
|
|
|
private Row mGoal;
|
|
|
|
public ArrayRow[] mRows;
|
|
|
|
private Row mTempGoal;
|
2022-03-07 09:34:54 +00:00
|
|
|
public boolean hasSimpleDefinition = false;
|
|
|
|
public int mVariablesID = 0;
|
|
|
|
private HashMap<String, SolverVariable> mVariables = null;
|
|
|
|
private int TABLE_SIZE = 32;
|
|
|
|
private int mMaxColumns = 32;
|
|
|
|
public boolean graphOptimizer = false;
|
|
|
|
public boolean newgraphOptimizer = false;
|
|
|
|
private boolean[] mAlreadyTestedCandidates = new boolean[32];
|
|
|
|
public int mNumColumns = 1;
|
|
|
|
public int mNumRows = 0;
|
|
|
|
private int mMaxRows = 32;
|
|
|
|
private SolverVariable[] mPoolVariables = new SolverVariable[POOL_SIZE];
|
|
|
|
private int mPoolVariablesCount = 0;
|
|
|
|
|
|
|
|
/* loaded from: classes.dex */
|
2021-07-24 02:37:17 +00:00
|
|
|
public interface Row {
|
|
|
|
void addError(SolverVariable solverVariable);
|
|
|
|
|
|
|
|
void clear();
|
|
|
|
|
|
|
|
SolverVariable getKey();
|
|
|
|
|
|
|
|
SolverVariable getPivotCandidate(LinearSystem linearSystem, boolean[] zArr);
|
|
|
|
|
|
|
|
void initFromRow(Row row);
|
|
|
|
|
|
|
|
boolean isEmpty();
|
|
|
|
|
|
|
|
void updateFromFinalVariable(LinearSystem linearSystem, SolverVariable solverVariable, boolean z2);
|
|
|
|
|
|
|
|
void updateFromRow(LinearSystem linearSystem, ArrayRow arrayRow, boolean z2);
|
|
|
|
|
|
|
|
void updateFromSystem(LinearSystem linearSystem);
|
|
|
|
}
|
|
|
|
|
2022-03-07 09:34:54 +00:00
|
|
|
/* loaded from: classes.dex */
|
2021-07-24 02:37:17 +00:00
|
|
|
public class ValuesRow extends ArrayRow {
|
|
|
|
public ValuesRow(Cache cache) {
|
|
|
|
this.variables = new SolverVariableValues(this, cache);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public LinearSystem() {
|
|
|
|
this.mRows = null;
|
|
|
|
this.mRows = new ArrayRow[32];
|
|
|
|
releaseRows();
|
|
|
|
Cache cache = new Cache();
|
|
|
|
this.mCache = cache;
|
|
|
|
this.mGoal = new PriorityGoalRow(cache);
|
|
|
|
if (OPTIMIZED_ENGINE) {
|
|
|
|
this.mTempGoal = new ValuesRow(cache);
|
|
|
|
} else {
|
|
|
|
this.mTempGoal = new ArrayRow(cache);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private SolverVariable acquireSolverVariable(SolverVariable.Type type, String str) {
|
|
|
|
SolverVariable acquire = this.mCache.solverVariablePool.acquire();
|
|
|
|
if (acquire == null) {
|
|
|
|
acquire = new SolverVariable(type, str);
|
|
|
|
acquire.setType(type, str);
|
|
|
|
} else {
|
|
|
|
acquire.reset();
|
|
|
|
acquire.setType(type, str);
|
|
|
|
}
|
|
|
|
int i = this.mPoolVariablesCount;
|
|
|
|
int i2 = POOL_SIZE;
|
|
|
|
if (i >= i2) {
|
|
|
|
int i3 = i2 * 2;
|
|
|
|
POOL_SIZE = i3;
|
|
|
|
this.mPoolVariables = (SolverVariable[]) Arrays.copyOf(this.mPoolVariables, i3);
|
|
|
|
}
|
|
|
|
SolverVariable[] solverVariableArr = this.mPoolVariables;
|
|
|
|
int i4 = this.mPoolVariablesCount;
|
|
|
|
this.mPoolVariablesCount = i4 + 1;
|
|
|
|
solverVariableArr[i4] = acquire;
|
|
|
|
return acquire;
|
|
|
|
}
|
|
|
|
|
|
|
|
private void addError(ArrayRow arrayRow) {
|
|
|
|
arrayRow.addError(this, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
private final void addRow(ArrayRow arrayRow) {
|
|
|
|
int i;
|
|
|
|
if (!SIMPLIFY_SYNONYMS || !arrayRow.isSimpleDefinition) {
|
|
|
|
ArrayRow[] arrayRowArr = this.mRows;
|
|
|
|
int i2 = this.mNumRows;
|
|
|
|
arrayRowArr[i2] = arrayRow;
|
|
|
|
SolverVariable solverVariable = arrayRow.variable;
|
|
|
|
solverVariable.definitionId = i2;
|
|
|
|
this.mNumRows = i2 + 1;
|
|
|
|
solverVariable.updateReferencesWithNewDefinition(this, arrayRow);
|
|
|
|
} else {
|
|
|
|
arrayRow.variable.setFinalValue(this, arrayRow.constantValue);
|
|
|
|
}
|
|
|
|
if (SIMPLIFY_SYNONYMS && this.hasSimpleDefinition) {
|
|
|
|
int i3 = 0;
|
|
|
|
while (i3 < this.mNumRows) {
|
|
|
|
if (this.mRows[i3] == null) {
|
|
|
|
System.out.println("WTF");
|
|
|
|
}
|
|
|
|
ArrayRow[] arrayRowArr2 = this.mRows;
|
|
|
|
if (arrayRowArr2[i3] != null && arrayRowArr2[i3].isSimpleDefinition) {
|
|
|
|
ArrayRow arrayRow2 = arrayRowArr2[i3];
|
|
|
|
arrayRow2.variable.setFinalValue(this, arrayRow2.constantValue);
|
|
|
|
if (OPTIMIZED_ENGINE) {
|
|
|
|
this.mCache.optimizedArrayRowPool.release(arrayRow2);
|
|
|
|
} else {
|
|
|
|
this.mCache.arrayRowPool.release(arrayRow2);
|
|
|
|
}
|
|
|
|
this.mRows[i3] = null;
|
|
|
|
int i4 = i3 + 1;
|
|
|
|
int i5 = i4;
|
|
|
|
while (true) {
|
|
|
|
i = this.mNumRows;
|
|
|
|
if (i4 >= i) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
ArrayRow[] arrayRowArr3 = this.mRows;
|
|
|
|
int i6 = i4 - 1;
|
|
|
|
arrayRowArr3[i6] = arrayRowArr3[i4];
|
|
|
|
if (arrayRowArr3[i6].variable.definitionId == i4) {
|
|
|
|
arrayRowArr3[i6].variable.definitionId = i6;
|
|
|
|
}
|
|
|
|
i4++;
|
2022-03-07 09:34:54 +00:00
|
|
|
i5 = i4;
|
2021-07-24 02:37:17 +00:00
|
|
|
}
|
|
|
|
if (i5 < i) {
|
|
|
|
this.mRows[i5] = null;
|
|
|
|
}
|
|
|
|
this.mNumRows = i - 1;
|
|
|
|
i3--;
|
|
|
|
}
|
|
|
|
i3++;
|
|
|
|
}
|
|
|
|
this.hasSimpleDefinition = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private void addSingleError(ArrayRow arrayRow, int i) {
|
|
|
|
addSingleError(arrayRow, i, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
private void computeValues() {
|
|
|
|
for (int i = 0; i < this.mNumRows; i++) {
|
|
|
|
ArrayRow arrayRow = this.mRows[i];
|
|
|
|
arrayRow.variable.computedValue = arrayRow.constantValue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public static ArrayRow createRowDimensionPercent(LinearSystem linearSystem, SolverVariable solverVariable, SolverVariable solverVariable2, float f) {
|
|
|
|
return linearSystem.createRow().createRowDimensionPercent(solverVariable, solverVariable2, f);
|
|
|
|
}
|
|
|
|
|
|
|
|
private SolverVariable createVariable(String str, SolverVariable.Type type) {
|
|
|
|
Metrics metrics = sMetrics;
|
|
|
|
if (metrics != null) {
|
|
|
|
metrics.variables++;
|
|
|
|
}
|
|
|
|
if (this.mNumColumns + 1 >= this.mMaxColumns) {
|
|
|
|
increaseTableSize();
|
|
|
|
}
|
|
|
|
SolverVariable acquireSolverVariable = acquireSolverVariable(type, null);
|
|
|
|
acquireSolverVariable.setName(str);
|
|
|
|
int i = this.mVariablesID + 1;
|
|
|
|
this.mVariablesID = i;
|
|
|
|
this.mNumColumns++;
|
2021-12-17 21:59:34 +00:00
|
|
|
acquireSolverVariable.f30id = i;
|
2021-07-24 02:37:17 +00:00
|
|
|
if (this.mVariables == null) {
|
|
|
|
this.mVariables = new HashMap<>();
|
|
|
|
}
|
|
|
|
this.mVariables.put(str, acquireSolverVariable);
|
|
|
|
this.mCache.mIndexedVariables[this.mVariablesID] = acquireSolverVariable;
|
|
|
|
return acquireSolverVariable;
|
|
|
|
}
|
|
|
|
|
|
|
|
private void displayRows() {
|
|
|
|
displaySolverVariables();
|
|
|
|
String str = "";
|
|
|
|
for (int i = 0; i < this.mNumRows; i++) {
|
2022-03-14 07:58:47 +00:00
|
|
|
StringBuilder S = a.S(str);
|
|
|
|
S.append(this.mRows[i]);
|
|
|
|
str = a.v(S.toString(), "\n");
|
2021-07-24 02:37:17 +00:00
|
|
|
}
|
2022-03-14 07:58:47 +00:00
|
|
|
StringBuilder S2 = a.S(str);
|
|
|
|
S2.append(this.mGoal);
|
|
|
|
S2.append("\n");
|
|
|
|
System.out.println(S2.toString());
|
2021-07-24 02:37:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private void displaySolverVariables() {
|
2022-03-14 07:58:47 +00:00
|
|
|
StringBuilder S = a.S("Display Rows (");
|
|
|
|
S.append(this.mNumRows);
|
|
|
|
S.append("x");
|
|
|
|
System.out.println(a.A(S, this.mNumColumns, ")\n"));
|
2021-07-24 02:37:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private int enforceBFS(Row row) throws Exception {
|
|
|
|
boolean z2;
|
|
|
|
int i = 0;
|
|
|
|
while (true) {
|
|
|
|
if (i >= this.mNumRows) {
|
|
|
|
z2 = false;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
ArrayRow[] arrayRowArr = this.mRows;
|
|
|
|
if (arrayRowArr[i].variable.mType != SolverVariable.Type.UNRESTRICTED && arrayRowArr[i].constantValue < 0.0f) {
|
|
|
|
z2 = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
if (!z2) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
boolean z3 = false;
|
|
|
|
int i2 = 0;
|
|
|
|
while (!z3) {
|
|
|
|
Metrics metrics = sMetrics;
|
|
|
|
if (metrics != null) {
|
|
|
|
metrics.bfs++;
|
|
|
|
}
|
|
|
|
i2++;
|
|
|
|
float f = Float.MAX_VALUE;
|
|
|
|
int i3 = -1;
|
|
|
|
int i4 = -1;
|
|
|
|
int i5 = 0;
|
|
|
|
for (int i6 = 0; i6 < this.mNumRows; i6++) {
|
|
|
|
ArrayRow arrayRow = this.mRows[i6];
|
|
|
|
if (arrayRow.variable.mType != SolverVariable.Type.UNRESTRICTED && !arrayRow.isSimpleDefinition && arrayRow.constantValue < 0.0f) {
|
|
|
|
int i7 = 9;
|
|
|
|
if (SKIP_COLUMNS) {
|
|
|
|
int currentSize = arrayRow.variables.getCurrentSize();
|
|
|
|
int i8 = 0;
|
|
|
|
while (i8 < currentSize) {
|
|
|
|
SolverVariable variable = arrayRow.variables.getVariable(i8);
|
|
|
|
float f2 = arrayRow.variables.get(variable);
|
|
|
|
if (f2 > 0.0f) {
|
|
|
|
int i9 = 0;
|
|
|
|
while (i9 < i7) {
|
|
|
|
float f3 = variable.strengthVector[i9] / f2;
|
|
|
|
if ((f3 < f && i9 == i5) || i9 > i5) {
|
2021-12-17 21:59:34 +00:00
|
|
|
i4 = variable.f30id;
|
2021-07-24 02:37:17 +00:00
|
|
|
i5 = i9;
|
|
|
|
i3 = i6;
|
|
|
|
f = f3;
|
|
|
|
}
|
|
|
|
i9++;
|
|
|
|
i7 = 9;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
i8++;
|
|
|
|
i7 = 9;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
for (int i10 = 1; i10 < this.mNumColumns; i10++) {
|
|
|
|
SolverVariable solverVariable = this.mCache.mIndexedVariables[i10];
|
|
|
|
float f4 = arrayRow.variables.get(solverVariable);
|
|
|
|
if (f4 > 0.0f) {
|
|
|
|
for (int i11 = 0; i11 < 9; i11++) {
|
|
|
|
float f5 = solverVariable.strengthVector[i11] / f4;
|
|
|
|
if ((f5 < f && i11 == i5) || i11 > i5) {
|
|
|
|
i4 = i10;
|
|
|
|
i5 = i11;
|
|
|
|
i3 = i6;
|
|
|
|
f = f5;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (i3 != -1) {
|
|
|
|
ArrayRow arrayRow2 = this.mRows[i3];
|
|
|
|
arrayRow2.variable.definitionId = -1;
|
|
|
|
Metrics metrics2 = sMetrics;
|
|
|
|
if (metrics2 != null) {
|
|
|
|
metrics2.pivots++;
|
|
|
|
}
|
|
|
|
arrayRow2.pivot(this.mCache.mIndexedVariables[i4]);
|
|
|
|
SolverVariable solverVariable2 = arrayRow2.variable;
|
|
|
|
solverVariable2.definitionId = i3;
|
|
|
|
solverVariable2.updateReferencesWithNewDefinition(this, arrayRow2);
|
|
|
|
} else {
|
|
|
|
z3 = true;
|
|
|
|
}
|
|
|
|
if (i2 > this.mNumColumns / 2) {
|
|
|
|
z3 = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return i2;
|
|
|
|
}
|
|
|
|
|
|
|
|
private String getDisplaySize(int i) {
|
|
|
|
int i2 = i * 4;
|
|
|
|
int i3 = i2 / 1024;
|
|
|
|
int i4 = i3 / 1024;
|
2021-11-05 06:48:17 +00:00
|
|
|
return i4 > 0 ? a.q("", i4, " Mb") : i3 > 0 ? a.q("", i3, " Kb") : a.q("", i2, " bytes");
|
2021-07-24 02:37:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private String getDisplayStrength(int i) {
|
|
|
|
return i == 1 ? "LOW" : i == 2 ? "MEDIUM" : i == 3 ? "HIGH" : i == 4 ? "HIGHEST" : i == 5 ? "EQUALITY" : i == 8 ? "FIXED" : i == 6 ? "BARRIER" : "NONE";
|
|
|
|
}
|
|
|
|
|
|
|
|
public static Metrics getMetrics() {
|
|
|
|
return sMetrics;
|
|
|
|
}
|
|
|
|
|
|
|
|
private void increaseTableSize() {
|
|
|
|
int i = this.TABLE_SIZE * 2;
|
|
|
|
this.TABLE_SIZE = i;
|
|
|
|
this.mRows = (ArrayRow[]) Arrays.copyOf(this.mRows, i);
|
|
|
|
Cache cache = this.mCache;
|
|
|
|
cache.mIndexedVariables = (SolverVariable[]) Arrays.copyOf(cache.mIndexedVariables, this.TABLE_SIZE);
|
|
|
|
int i2 = this.TABLE_SIZE;
|
|
|
|
this.mAlreadyTestedCandidates = new boolean[i2];
|
|
|
|
this.mMaxColumns = i2;
|
|
|
|
this.mMaxRows = i2;
|
|
|
|
Metrics metrics = sMetrics;
|
|
|
|
if (metrics != null) {
|
|
|
|
metrics.tableSizeIncrease++;
|
2022-03-07 09:34:54 +00:00
|
|
|
metrics.maxTableSize = Math.max(metrics.maxTableSize, i2);
|
2021-07-24 02:37:17 +00:00
|
|
|
Metrics metrics2 = sMetrics;
|
|
|
|
metrics2.lastTableSize = metrics2.maxTableSize;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private final int optimize(Row row, boolean z2) {
|
|
|
|
Metrics metrics = sMetrics;
|
|
|
|
if (metrics != null) {
|
|
|
|
metrics.optimize++;
|
|
|
|
}
|
|
|
|
for (int i = 0; i < this.mNumColumns; i++) {
|
|
|
|
this.mAlreadyTestedCandidates[i] = false;
|
|
|
|
}
|
|
|
|
boolean z3 = false;
|
|
|
|
int i2 = 0;
|
|
|
|
while (!z3) {
|
|
|
|
Metrics metrics2 = sMetrics;
|
|
|
|
if (metrics2 != null) {
|
|
|
|
metrics2.iterations++;
|
|
|
|
}
|
|
|
|
i2++;
|
|
|
|
if (i2 >= this.mNumColumns * 2) {
|
|
|
|
return i2;
|
|
|
|
}
|
|
|
|
if (row.getKey() != null) {
|
2021-12-17 21:59:34 +00:00
|
|
|
this.mAlreadyTestedCandidates[row.getKey().f30id] = true;
|
2021-07-24 02:37:17 +00:00
|
|
|
}
|
|
|
|
SolverVariable pivotCandidate = row.getPivotCandidate(this, this.mAlreadyTestedCandidates);
|
|
|
|
if (pivotCandidate != null) {
|
|
|
|
boolean[] zArr = this.mAlreadyTestedCandidates;
|
2021-12-17 21:59:34 +00:00
|
|
|
int i3 = pivotCandidate.f30id;
|
2021-07-24 02:37:17 +00:00
|
|
|
if (zArr[i3]) {
|
|
|
|
return i2;
|
|
|
|
}
|
|
|
|
zArr[i3] = true;
|
|
|
|
}
|
|
|
|
if (pivotCandidate != null) {
|
|
|
|
float f = Float.MAX_VALUE;
|
|
|
|
int i4 = -1;
|
|
|
|
for (int i5 = 0; i5 < this.mNumRows; i5++) {
|
|
|
|
ArrayRow arrayRow = this.mRows[i5];
|
|
|
|
if (arrayRow.variable.mType != SolverVariable.Type.UNRESTRICTED && !arrayRow.isSimpleDefinition && arrayRow.hasVariable(pivotCandidate)) {
|
|
|
|
float f2 = arrayRow.variables.get(pivotCandidate);
|
|
|
|
if (f2 < 0.0f) {
|
|
|
|
float f3 = (-arrayRow.constantValue) / f2;
|
|
|
|
if (f3 < f) {
|
|
|
|
i4 = i5;
|
|
|
|
f = f3;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (i4 > -1) {
|
|
|
|
ArrayRow arrayRow2 = this.mRows[i4];
|
|
|
|
arrayRow2.variable.definitionId = -1;
|
|
|
|
Metrics metrics3 = sMetrics;
|
|
|
|
if (metrics3 != null) {
|
|
|
|
metrics3.pivots++;
|
|
|
|
}
|
|
|
|
arrayRow2.pivot(pivotCandidate);
|
|
|
|
SolverVariable solverVariable = arrayRow2.variable;
|
|
|
|
solverVariable.definitionId = i4;
|
|
|
|
solverVariable.updateReferencesWithNewDefinition(this, arrayRow2);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
z3 = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return i2;
|
|
|
|
}
|
|
|
|
|
|
|
|
private void releaseRows() {
|
|
|
|
int i = 0;
|
|
|
|
if (OPTIMIZED_ENGINE) {
|
|
|
|
while (i < this.mNumRows) {
|
|
|
|
ArrayRow arrayRow = this.mRows[i];
|
|
|
|
if (arrayRow != null) {
|
|
|
|
this.mCache.optimizedArrayRowPool.release(arrayRow);
|
|
|
|
}
|
|
|
|
this.mRows[i] = null;
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
while (i < this.mNumRows) {
|
|
|
|
ArrayRow arrayRow2 = this.mRows[i];
|
|
|
|
if (arrayRow2 != null) {
|
|
|
|
this.mCache.arrayRowPool.release(arrayRow2);
|
|
|
|
}
|
|
|
|
this.mRows[i] = null;
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void addCenterPoint(ConstraintWidget constraintWidget, ConstraintWidget constraintWidget2, float f, int i) {
|
|
|
|
ConstraintAnchor.Type type = ConstraintAnchor.Type.LEFT;
|
|
|
|
SolverVariable createObjectVariable = createObjectVariable(constraintWidget.getAnchor(type));
|
|
|
|
ConstraintAnchor.Type type2 = ConstraintAnchor.Type.TOP;
|
|
|
|
SolverVariable createObjectVariable2 = createObjectVariable(constraintWidget.getAnchor(type2));
|
|
|
|
ConstraintAnchor.Type type3 = ConstraintAnchor.Type.RIGHT;
|
|
|
|
SolverVariable createObjectVariable3 = createObjectVariable(constraintWidget.getAnchor(type3));
|
|
|
|
ConstraintAnchor.Type type4 = ConstraintAnchor.Type.BOTTOM;
|
|
|
|
SolverVariable createObjectVariable4 = createObjectVariable(constraintWidget.getAnchor(type4));
|
|
|
|
SolverVariable createObjectVariable5 = createObjectVariable(constraintWidget2.getAnchor(type));
|
|
|
|
SolverVariable createObjectVariable6 = createObjectVariable(constraintWidget2.getAnchor(type2));
|
|
|
|
SolverVariable createObjectVariable7 = createObjectVariable(constraintWidget2.getAnchor(type3));
|
|
|
|
SolverVariable createObjectVariable8 = createObjectVariable(constraintWidget2.getAnchor(type4));
|
|
|
|
ArrayRow createRow = createRow();
|
2022-03-07 09:34:54 +00:00
|
|
|
double d = f;
|
|
|
|
double d2 = i;
|
2021-07-24 02:37:17 +00:00
|
|
|
createRow.createRowWithAngle(createObjectVariable2, createObjectVariable4, createObjectVariable6, createObjectVariable8, (float) (Math.sin(d) * d2));
|
|
|
|
addConstraint(createRow);
|
|
|
|
ArrayRow createRow2 = createRow();
|
|
|
|
createRow2.createRowWithAngle(createObjectVariable, createObjectVariable3, createObjectVariable5, createObjectVariable7, (float) (Math.cos(d) * d2));
|
|
|
|
addConstraint(createRow2);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void addCentering(SolverVariable solverVariable, SolverVariable solverVariable2, int i, float f, SolverVariable solverVariable3, SolverVariable solverVariable4, int i2, int i3) {
|
|
|
|
ArrayRow createRow = createRow();
|
|
|
|
createRow.createRowCentering(solverVariable, solverVariable2, i, f, solverVariable3, solverVariable4, i2);
|
|
|
|
if (i3 != 8) {
|
|
|
|
createRow.addError(this, i3);
|
|
|
|
}
|
|
|
|
addConstraint(createRow);
|
|
|
|
}
|
|
|
|
|
2022-03-07 09:34:54 +00:00
|
|
|
/* JADX WARN: Removed duplicated region for block: B:44:0x009f A[RETURN] */
|
|
|
|
/* JADX WARN: Removed duplicated region for block: B:45:0x00a0 */
|
|
|
|
/*
|
|
|
|
Code decompiled incorrectly, please refer to instructions dump.
|
|
|
|
*/
|
2021-07-24 02:37:17 +00:00
|
|
|
public void addConstraint(ArrayRow arrayRow) {
|
|
|
|
SolverVariable pickPivot;
|
|
|
|
if (arrayRow != null) {
|
|
|
|
Metrics metrics = sMetrics;
|
|
|
|
if (metrics != null) {
|
|
|
|
metrics.constraints++;
|
|
|
|
if (arrayRow.isSimpleDefinition) {
|
|
|
|
metrics.simpleconstraints++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
boolean z2 = true;
|
|
|
|
if (this.mNumRows + 1 >= this.mMaxRows || this.mNumColumns + 1 >= this.mMaxColumns) {
|
|
|
|
increaseTableSize();
|
|
|
|
}
|
2022-03-07 09:34:54 +00:00
|
|
|
z2 = false;
|
2021-07-24 02:37:17 +00:00
|
|
|
if (!arrayRow.isSimpleDefinition) {
|
|
|
|
arrayRow.updateFromSystem(this);
|
|
|
|
if (!arrayRow.isEmpty()) {
|
|
|
|
arrayRow.ensurePositiveConstant();
|
|
|
|
if (arrayRow.chooseSubject(this)) {
|
|
|
|
SolverVariable createExtraVariable = createExtraVariable();
|
|
|
|
arrayRow.variable = createExtraVariable;
|
|
|
|
int i = this.mNumRows;
|
|
|
|
addRow(arrayRow);
|
|
|
|
if (this.mNumRows == i + 1) {
|
|
|
|
this.mTempGoal.initFromRow(arrayRow);
|
|
|
|
optimize(this.mTempGoal, true);
|
|
|
|
if (createExtraVariable.definitionId == -1) {
|
|
|
|
if (arrayRow.variable == createExtraVariable && (pickPivot = arrayRow.pickPivot(createExtraVariable)) != null) {
|
|
|
|
Metrics metrics2 = sMetrics;
|
|
|
|
if (metrics2 != null) {
|
|
|
|
metrics2.pivots++;
|
|
|
|
}
|
|
|
|
arrayRow.pivot(pickPivot);
|
|
|
|
}
|
|
|
|
if (!arrayRow.isSimpleDefinition) {
|
|
|
|
arrayRow.variable.updateReferencesWithNewDefinition(this, arrayRow);
|
|
|
|
}
|
|
|
|
if (OPTIMIZED_ENGINE) {
|
|
|
|
this.mCache.optimizedArrayRowPool.release(arrayRow);
|
|
|
|
} else {
|
|
|
|
this.mCache.arrayRowPool.release(arrayRow);
|
|
|
|
}
|
|
|
|
this.mNumRows--;
|
|
|
|
}
|
2022-03-07 09:34:54 +00:00
|
|
|
if (arrayRow.hasKeyVariable()) {
|
2021-07-24 02:37:17 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
z2 = false;
|
2022-03-07 09:34:54 +00:00
|
|
|
if (arrayRow.hasKeyVariable()) {
|
2021-07-24 02:37:17 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2022-03-07 09:34:54 +00:00
|
|
|
if (!z2) {
|
2021-07-24 02:37:17 +00:00
|
|
|
addRow(arrayRow);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public ArrayRow addEquality(SolverVariable solverVariable, SolverVariable solverVariable2, int i, int i2) {
|
|
|
|
if (!USE_BASIC_SYNONYMS || i2 != 8 || !solverVariable2.isFinalValue || solverVariable.definitionId != -1) {
|
|
|
|
ArrayRow createRow = createRow();
|
|
|
|
createRow.createRowEquals(solverVariable, solverVariable2, i);
|
|
|
|
if (i2 != 8) {
|
|
|
|
createRow.addError(this, i2);
|
|
|
|
}
|
|
|
|
addConstraint(createRow);
|
|
|
|
return createRow;
|
|
|
|
}
|
2022-03-07 09:34:54 +00:00
|
|
|
solverVariable.setFinalValue(this, solverVariable2.computedValue + i);
|
2021-07-24 02:37:17 +00:00
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void addEquality(SolverVariable solverVariable, int i) {
|
|
|
|
if (!USE_BASIC_SYNONYMS || solverVariable.definitionId != -1) {
|
|
|
|
int i2 = solverVariable.definitionId;
|
|
|
|
if (i2 != -1) {
|
|
|
|
ArrayRow arrayRow = this.mRows[i2];
|
|
|
|
if (arrayRow.isSimpleDefinition) {
|
2022-03-07 09:34:54 +00:00
|
|
|
arrayRow.constantValue = i;
|
2021-07-24 02:37:17 +00:00
|
|
|
} else if (arrayRow.variables.getCurrentSize() == 0) {
|
|
|
|
arrayRow.isSimpleDefinition = true;
|
2022-03-07 09:34:54 +00:00
|
|
|
arrayRow.constantValue = i;
|
2021-07-24 02:37:17 +00:00
|
|
|
} else {
|
|
|
|
ArrayRow createRow = createRow();
|
|
|
|
createRow.createRowEquals(solverVariable, i);
|
|
|
|
addConstraint(createRow);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
ArrayRow createRow2 = createRow();
|
|
|
|
createRow2.createRowDefinition(solverVariable, i);
|
|
|
|
addConstraint(createRow2);
|
|
|
|
}
|
|
|
|
} else {
|
2022-03-07 09:34:54 +00:00
|
|
|
float f = i;
|
2021-07-24 02:37:17 +00:00
|
|
|
solverVariable.setFinalValue(this, f);
|
|
|
|
for (int i3 = 0; i3 < this.mVariablesID + 1; i3++) {
|
|
|
|
SolverVariable solverVariable2 = this.mCache.mIndexedVariables[i3];
|
2021-12-17 21:59:34 +00:00
|
|
|
if (solverVariable2 != null && solverVariable2.isSynonym && solverVariable2.synonym == solverVariable.f30id) {
|
2021-07-24 02:37:17 +00:00
|
|
|
solverVariable2.setFinalValue(this, solverVariable2.synonymDelta + f);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void addGreaterBarrier(SolverVariable solverVariable, SolverVariable solverVariable2, int i, boolean z2) {
|
|
|
|
ArrayRow createRow = createRow();
|
|
|
|
SolverVariable createSlackVariable = createSlackVariable();
|
|
|
|
createSlackVariable.strength = 0;
|
|
|
|
createRow.createRowGreaterThan(solverVariable, solverVariable2, createSlackVariable, i);
|
|
|
|
addConstraint(createRow);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void addGreaterThan(SolverVariable solverVariable, SolverVariable solverVariable2, int i, int i2) {
|
|
|
|
ArrayRow createRow = createRow();
|
|
|
|
SolverVariable createSlackVariable = createSlackVariable();
|
|
|
|
createSlackVariable.strength = 0;
|
|
|
|
createRow.createRowGreaterThan(solverVariable, solverVariable2, createSlackVariable, i);
|
|
|
|
if (i2 != 8) {
|
2022-03-07 09:34:54 +00:00
|
|
|
addSingleError(createRow, (int) (createRow.variables.get(createSlackVariable) * (-1.0f)), i2);
|
2021-07-24 02:37:17 +00:00
|
|
|
}
|
|
|
|
addConstraint(createRow);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void addLowerBarrier(SolverVariable solverVariable, SolverVariable solverVariable2, int i, boolean z2) {
|
|
|
|
ArrayRow createRow = createRow();
|
|
|
|
SolverVariable createSlackVariable = createSlackVariable();
|
|
|
|
createSlackVariable.strength = 0;
|
|
|
|
createRow.createRowLowerThan(solverVariable, solverVariable2, createSlackVariable, i);
|
|
|
|
addConstraint(createRow);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void addLowerThan(SolverVariable solverVariable, SolverVariable solverVariable2, int i, int i2) {
|
|
|
|
ArrayRow createRow = createRow();
|
|
|
|
SolverVariable createSlackVariable = createSlackVariable();
|
|
|
|
createSlackVariable.strength = 0;
|
|
|
|
createRow.createRowLowerThan(solverVariable, solverVariable2, createSlackVariable, i);
|
|
|
|
if (i2 != 8) {
|
2022-03-07 09:34:54 +00:00
|
|
|
addSingleError(createRow, (int) (createRow.variables.get(createSlackVariable) * (-1.0f)), i2);
|
2021-07-24 02:37:17 +00:00
|
|
|
}
|
|
|
|
addConstraint(createRow);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void addRatio(SolverVariable solverVariable, SolverVariable solverVariable2, SolverVariable solverVariable3, SolverVariable solverVariable4, float f, int i) {
|
|
|
|
ArrayRow createRow = createRow();
|
|
|
|
createRow.createRowDimensionRatio(solverVariable, solverVariable2, solverVariable3, solverVariable4, f);
|
|
|
|
if (i != 8) {
|
|
|
|
createRow.addError(this, i);
|
|
|
|
}
|
|
|
|
addConstraint(createRow);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void addSingleError(ArrayRow arrayRow, int i, int i2) {
|
|
|
|
arrayRow.addSingleError(createErrorVariable(i2, null), i);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void addSynonym(SolverVariable solverVariable, SolverVariable solverVariable2, int i) {
|
|
|
|
if (solverVariable.definitionId == -1 && i == 0) {
|
|
|
|
if (solverVariable2.isSynonym) {
|
|
|
|
solverVariable2 = this.mCache.mIndexedVariables[solverVariable2.synonym];
|
|
|
|
}
|
|
|
|
if (solverVariable.isSynonym) {
|
|
|
|
SolverVariable solverVariable3 = this.mCache.mIndexedVariables[solverVariable.synonym];
|
|
|
|
} else {
|
|
|
|
solverVariable.setSynonym(this, solverVariable2, 0.0f);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
addEquality(solverVariable, solverVariable2, i, 8);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public final void cleanupRows() {
|
|
|
|
int i;
|
|
|
|
int i2 = 0;
|
|
|
|
while (i2 < this.mNumRows) {
|
|
|
|
ArrayRow arrayRow = this.mRows[i2];
|
|
|
|
if (arrayRow.variables.getCurrentSize() == 0) {
|
|
|
|
arrayRow.isSimpleDefinition = true;
|
|
|
|
}
|
|
|
|
if (arrayRow.isSimpleDefinition) {
|
|
|
|
SolverVariable solverVariable = arrayRow.variable;
|
|
|
|
solverVariable.computedValue = arrayRow.constantValue;
|
|
|
|
solverVariable.removeFromRow(arrayRow);
|
|
|
|
int i3 = i2;
|
|
|
|
while (true) {
|
|
|
|
i = this.mNumRows;
|
|
|
|
if (i3 >= i - 1) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
ArrayRow[] arrayRowArr = this.mRows;
|
|
|
|
int i4 = i3 + 1;
|
|
|
|
arrayRowArr[i3] = arrayRowArr[i4];
|
|
|
|
i3 = i4;
|
|
|
|
}
|
|
|
|
this.mRows[i - 1] = null;
|
|
|
|
this.mNumRows = i - 1;
|
|
|
|
i2--;
|
|
|
|
if (OPTIMIZED_ENGINE) {
|
|
|
|
this.mCache.optimizedArrayRowPool.release(arrayRow);
|
|
|
|
} else {
|
|
|
|
this.mCache.arrayRowPool.release(arrayRow);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
i2++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public SolverVariable createErrorVariable(int i, String str) {
|
|
|
|
Metrics metrics = sMetrics;
|
|
|
|
if (metrics != null) {
|
|
|
|
metrics.errors++;
|
|
|
|
}
|
|
|
|
if (this.mNumColumns + 1 >= this.mMaxColumns) {
|
|
|
|
increaseTableSize();
|
|
|
|
}
|
|
|
|
SolverVariable acquireSolverVariable = acquireSolverVariable(SolverVariable.Type.ERROR, str);
|
|
|
|
int i2 = this.mVariablesID + 1;
|
|
|
|
this.mVariablesID = i2;
|
|
|
|
this.mNumColumns++;
|
2021-12-17 21:59:34 +00:00
|
|
|
acquireSolverVariable.f30id = i2;
|
2021-07-24 02:37:17 +00:00
|
|
|
acquireSolverVariable.strength = i;
|
|
|
|
this.mCache.mIndexedVariables[i2] = acquireSolverVariable;
|
|
|
|
this.mGoal.addError(acquireSolverVariable);
|
|
|
|
return acquireSolverVariable;
|
|
|
|
}
|
|
|
|
|
|
|
|
public SolverVariable createExtraVariable() {
|
|
|
|
Metrics metrics = sMetrics;
|
|
|
|
if (metrics != null) {
|
|
|
|
metrics.extravariables++;
|
|
|
|
}
|
|
|
|
if (this.mNumColumns + 1 >= this.mMaxColumns) {
|
|
|
|
increaseTableSize();
|
|
|
|
}
|
|
|
|
SolverVariable acquireSolverVariable = acquireSolverVariable(SolverVariable.Type.SLACK, null);
|
|
|
|
int i = this.mVariablesID + 1;
|
|
|
|
this.mVariablesID = i;
|
|
|
|
this.mNumColumns++;
|
2021-12-17 21:59:34 +00:00
|
|
|
acquireSolverVariable.f30id = i;
|
2021-07-24 02:37:17 +00:00
|
|
|
this.mCache.mIndexedVariables[i] = acquireSolverVariable;
|
|
|
|
return acquireSolverVariable;
|
|
|
|
}
|
|
|
|
|
|
|
|
public SolverVariable createObjectVariable(Object obj) {
|
|
|
|
SolverVariable solverVariable = null;
|
|
|
|
if (obj == null) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
if (this.mNumColumns + 1 >= this.mMaxColumns) {
|
|
|
|
increaseTableSize();
|
|
|
|
}
|
|
|
|
if (obj instanceof ConstraintAnchor) {
|
|
|
|
ConstraintAnchor constraintAnchor = (ConstraintAnchor) obj;
|
|
|
|
solverVariable = constraintAnchor.getSolverVariable();
|
|
|
|
if (solverVariable == null) {
|
|
|
|
constraintAnchor.resetSolverVariable(this.mCache);
|
|
|
|
solverVariable = constraintAnchor.getSolverVariable();
|
|
|
|
}
|
2021-12-17 21:59:34 +00:00
|
|
|
int i = solverVariable.f30id;
|
2021-07-24 02:37:17 +00:00
|
|
|
if (i == -1 || i > this.mVariablesID || this.mCache.mIndexedVariables[i] == null) {
|
|
|
|
if (i != -1) {
|
|
|
|
solverVariable.reset();
|
|
|
|
}
|
|
|
|
int i2 = this.mVariablesID + 1;
|
|
|
|
this.mVariablesID = i2;
|
|
|
|
this.mNumColumns++;
|
2021-12-17 21:59:34 +00:00
|
|
|
solverVariable.f30id = i2;
|
2021-07-24 02:37:17 +00:00
|
|
|
solverVariable.mType = SolverVariable.Type.UNRESTRICTED;
|
|
|
|
this.mCache.mIndexedVariables[i2] = solverVariable;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return solverVariable;
|
|
|
|
}
|
|
|
|
|
|
|
|
public ArrayRow createRow() {
|
|
|
|
ArrayRow arrayRow;
|
|
|
|
if (OPTIMIZED_ENGINE) {
|
|
|
|
arrayRow = this.mCache.optimizedArrayRowPool.acquire();
|
|
|
|
if (arrayRow == null) {
|
|
|
|
arrayRow = new ValuesRow(this.mCache);
|
|
|
|
OPTIMIZED_ARRAY_ROW_CREATION++;
|
|
|
|
} else {
|
|
|
|
arrayRow.reset();
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
arrayRow = this.mCache.arrayRowPool.acquire();
|
|
|
|
if (arrayRow == null) {
|
|
|
|
arrayRow = new ArrayRow(this.mCache);
|
|
|
|
ARRAY_ROW_CREATION++;
|
|
|
|
} else {
|
|
|
|
arrayRow.reset();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
SolverVariable.increaseErrorId();
|
|
|
|
return arrayRow;
|
|
|
|
}
|
|
|
|
|
|
|
|
public SolverVariable createSlackVariable() {
|
|
|
|
Metrics metrics = sMetrics;
|
|
|
|
if (metrics != null) {
|
|
|
|
metrics.slackvariables++;
|
|
|
|
}
|
|
|
|
if (this.mNumColumns + 1 >= this.mMaxColumns) {
|
|
|
|
increaseTableSize();
|
|
|
|
}
|
|
|
|
SolverVariable acquireSolverVariable = acquireSolverVariable(SolverVariable.Type.SLACK, null);
|
|
|
|
int i = this.mVariablesID + 1;
|
|
|
|
this.mVariablesID = i;
|
|
|
|
this.mNumColumns++;
|
2021-12-17 21:59:34 +00:00
|
|
|
acquireSolverVariable.f30id = i;
|
2021-07-24 02:37:17 +00:00
|
|
|
this.mCache.mIndexedVariables[i] = acquireSolverVariable;
|
|
|
|
return acquireSolverVariable;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void displayReadableRows() {
|
|
|
|
displaySolverVariables();
|
2022-03-14 07:58:47 +00:00
|
|
|
String A = a.A(a.S(" num vars "), this.mVariablesID, "\n");
|
2021-07-24 02:37:17 +00:00
|
|
|
for (int i = 0; i < this.mVariablesID + 1; i++) {
|
|
|
|
SolverVariable solverVariable = this.mCache.mIndexedVariables[i];
|
|
|
|
if (solverVariable != null && solverVariable.isFinalValue) {
|
2021-11-05 06:48:17 +00:00
|
|
|
A = A + " $[" + i + "] => " + solverVariable + " = " + solverVariable.computedValue + "\n";
|
2021-07-24 02:37:17 +00:00
|
|
|
}
|
|
|
|
}
|
2021-11-05 06:48:17 +00:00
|
|
|
String v = a.v(A, "\n");
|
2021-07-24 02:37:17 +00:00
|
|
|
for (int i2 = 0; i2 < this.mVariablesID + 1; i2++) {
|
|
|
|
SolverVariable[] solverVariableArr = this.mCache.mIndexedVariables;
|
|
|
|
SolverVariable solverVariable2 = solverVariableArr[i2];
|
|
|
|
if (solverVariable2 != null && solverVariable2.isSynonym) {
|
2021-11-05 06:48:17 +00:00
|
|
|
v = v + " ~[" + i2 + "] => " + solverVariable2 + " = " + solverVariableArr[solverVariable2.synonym] + " + " + solverVariable2.synonymDelta + "\n";
|
2021-07-24 02:37:17 +00:00
|
|
|
}
|
|
|
|
}
|
2021-11-05 06:48:17 +00:00
|
|
|
String v2 = a.v(v, "\n\n # ");
|
2021-07-24 02:37:17 +00:00
|
|
|
for (int i3 = 0; i3 < this.mNumRows; i3++) {
|
2022-03-14 07:58:47 +00:00
|
|
|
StringBuilder S = a.S(v2);
|
|
|
|
S.append(this.mRows[i3].toReadableString());
|
|
|
|
v2 = a.v(S.toString(), "\n # ");
|
2021-07-24 02:37:17 +00:00
|
|
|
}
|
|
|
|
if (this.mGoal != null) {
|
2022-03-14 07:58:47 +00:00
|
|
|
StringBuilder W = a.W(v2, "Goal: ");
|
|
|
|
W.append(this.mGoal);
|
|
|
|
W.append("\n");
|
|
|
|
v2 = W.toString();
|
2021-07-24 02:37:17 +00:00
|
|
|
}
|
2021-11-05 06:48:17 +00:00
|
|
|
System.out.println(v2);
|
2021-07-24 02:37:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public void displaySystemInformations() {
|
|
|
|
int i = 0;
|
|
|
|
for (int i2 = 0; i2 < this.TABLE_SIZE; i2++) {
|
|
|
|
ArrayRow[] arrayRowArr = this.mRows;
|
|
|
|
if (arrayRowArr[i2] != null) {
|
|
|
|
i = arrayRowArr[i2].sizeInBytes() + i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
int i3 = 0;
|
|
|
|
for (int i4 = 0; i4 < this.mNumRows; i4++) {
|
|
|
|
ArrayRow[] arrayRowArr2 = this.mRows;
|
|
|
|
if (arrayRowArr2[i4] != null) {
|
|
|
|
i3 = arrayRowArr2[i4].sizeInBytes() + i3;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
PrintStream printStream = System.out;
|
2022-03-14 07:58:47 +00:00
|
|
|
StringBuilder S = a.S("Linear System -> Table size: ");
|
|
|
|
S.append(this.TABLE_SIZE);
|
|
|
|
S.append(" (");
|
2021-07-24 02:37:17 +00:00
|
|
|
int i5 = this.TABLE_SIZE;
|
2022-03-14 07:58:47 +00:00
|
|
|
S.append(getDisplaySize(i5 * i5));
|
|
|
|
S.append(") -- row sizes: ");
|
|
|
|
S.append(getDisplaySize(i));
|
|
|
|
S.append(", actual size: ");
|
|
|
|
S.append(getDisplaySize(i3));
|
|
|
|
S.append(" rows: ");
|
|
|
|
S.append(this.mNumRows);
|
|
|
|
S.append(AutocompleteViewModel.COMMAND_DISCOVER_TOKEN);
|
|
|
|
S.append(this.mMaxRows);
|
|
|
|
S.append(" cols: ");
|
|
|
|
S.append(this.mNumColumns);
|
|
|
|
S.append(AutocompleteViewModel.COMMAND_DISCOVER_TOKEN);
|
|
|
|
S.append(this.mMaxColumns);
|
|
|
|
S.append(" ");
|
|
|
|
S.append(0);
|
|
|
|
S.append(" occupied cells, ");
|
|
|
|
S.append(getDisplaySize(0));
|
|
|
|
printStream.println(S.toString());
|
2021-07-24 02:37:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public void displayVariablesReadableRows() {
|
|
|
|
displaySolverVariables();
|
|
|
|
String str = "";
|
|
|
|
for (int i = 0; i < this.mNumRows; i++) {
|
|
|
|
if (this.mRows[i].variable.mType == SolverVariable.Type.UNRESTRICTED) {
|
2022-03-14 07:58:47 +00:00
|
|
|
StringBuilder S = a.S(str);
|
|
|
|
S.append(this.mRows[i].toReadableString());
|
|
|
|
str = a.v(S.toString(), "\n");
|
2021-07-24 02:37:17 +00:00
|
|
|
}
|
|
|
|
}
|
2022-03-14 07:58:47 +00:00
|
|
|
StringBuilder S2 = a.S(str);
|
|
|
|
S2.append(this.mGoal);
|
|
|
|
S2.append("\n");
|
|
|
|
System.out.println(S2.toString());
|
2021-07-24 02:37:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public void fillMetrics(Metrics metrics) {
|
|
|
|
sMetrics = metrics;
|
|
|
|
}
|
|
|
|
|
|
|
|
public Cache getCache() {
|
|
|
|
return this.mCache;
|
|
|
|
}
|
|
|
|
|
|
|
|
public Row getGoal() {
|
|
|
|
return this.mGoal;
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getMemoryUsed() {
|
|
|
|
int i = 0;
|
|
|
|
for (int i2 = 0; i2 < this.mNumRows; i2++) {
|
|
|
|
ArrayRow[] arrayRowArr = this.mRows;
|
|
|
|
if (arrayRowArr[i2] != null) {
|
|
|
|
i = arrayRowArr[i2].sizeInBytes() + i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getNumEquations() {
|
|
|
|
return this.mNumRows;
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getNumVariables() {
|
|
|
|
return this.mVariablesID;
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getObjectVariableValue(Object obj) {
|
|
|
|
SolverVariable solverVariable = ((ConstraintAnchor) obj).getSolverVariable();
|
|
|
|
if (solverVariable != null) {
|
|
|
|
return (int) (solverVariable.computedValue + 0.5f);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
public ArrayRow getRow(int i) {
|
|
|
|
return this.mRows[i];
|
|
|
|
}
|
|
|
|
|
|
|
|
public float getValueFor(String str) {
|
|
|
|
SolverVariable variable = getVariable(str, SolverVariable.Type.UNRESTRICTED);
|
|
|
|
if (variable == null) {
|
|
|
|
return 0.0f;
|
|
|
|
}
|
|
|
|
return variable.computedValue;
|
|
|
|
}
|
|
|
|
|
|
|
|
public SolverVariable getVariable(String str, SolverVariable.Type type) {
|
|
|
|
if (this.mVariables == null) {
|
|
|
|
this.mVariables = new HashMap<>();
|
|
|
|
}
|
|
|
|
SolverVariable solverVariable = this.mVariables.get(str);
|
|
|
|
return solverVariable == null ? createVariable(str, type) : solverVariable;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void minimize() throws Exception {
|
|
|
|
Metrics metrics = sMetrics;
|
|
|
|
if (metrics != null) {
|
|
|
|
metrics.minimize++;
|
|
|
|
}
|
|
|
|
if (this.mGoal.isEmpty()) {
|
|
|
|
computeValues();
|
|
|
|
} else if (this.graphOptimizer || this.newgraphOptimizer) {
|
|
|
|
Metrics metrics2 = sMetrics;
|
|
|
|
if (metrics2 != null) {
|
|
|
|
metrics2.graphOptimizer++;
|
|
|
|
}
|
|
|
|
boolean z2 = false;
|
|
|
|
int i = 0;
|
|
|
|
while (true) {
|
|
|
|
if (i >= this.mNumRows) {
|
|
|
|
z2 = true;
|
|
|
|
break;
|
|
|
|
} else if (!this.mRows[i].isSimpleDefinition) {
|
|
|
|
break;
|
|
|
|
} else {
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!z2) {
|
|
|
|
minimizeGoal(this.mGoal);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
Metrics metrics3 = sMetrics;
|
|
|
|
if (metrics3 != null) {
|
|
|
|
metrics3.fullySolved++;
|
|
|
|
}
|
|
|
|
computeValues();
|
|
|
|
} else {
|
|
|
|
minimizeGoal(this.mGoal);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void minimizeGoal(Row row) throws Exception {
|
|
|
|
Metrics metrics = sMetrics;
|
|
|
|
if (metrics != null) {
|
|
|
|
metrics.minimizeGoal++;
|
2022-03-07 09:34:54 +00:00
|
|
|
metrics.maxVariables = Math.max(metrics.maxVariables, this.mNumColumns);
|
2021-07-24 02:37:17 +00:00
|
|
|
Metrics metrics2 = sMetrics;
|
2022-03-07 09:34:54 +00:00
|
|
|
metrics2.maxRows = Math.max(metrics2.maxRows, this.mNumRows);
|
2021-07-24 02:37:17 +00:00
|
|
|
}
|
|
|
|
enforceBFS(row);
|
|
|
|
optimize(row, false);
|
|
|
|
computeValues();
|
|
|
|
}
|
|
|
|
|
|
|
|
public void removeRow(ArrayRow arrayRow) {
|
|
|
|
SolverVariable solverVariable;
|
|
|
|
int i;
|
|
|
|
if (arrayRow.isSimpleDefinition && (solverVariable = arrayRow.variable) != null) {
|
|
|
|
int i2 = solverVariable.definitionId;
|
|
|
|
if (i2 != -1) {
|
|
|
|
while (true) {
|
|
|
|
i = this.mNumRows;
|
|
|
|
if (i2 >= i - 1) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
ArrayRow[] arrayRowArr = this.mRows;
|
|
|
|
int i3 = i2 + 1;
|
|
|
|
SolverVariable solverVariable2 = arrayRowArr[i3].variable;
|
|
|
|
if (solverVariable2.definitionId == i3) {
|
|
|
|
solverVariable2.definitionId = i2;
|
|
|
|
}
|
|
|
|
arrayRowArr[i2] = arrayRowArr[i3];
|
|
|
|
i2 = i3;
|
|
|
|
}
|
|
|
|
this.mNumRows = i - 1;
|
|
|
|
}
|
|
|
|
SolverVariable solverVariable3 = arrayRow.variable;
|
|
|
|
if (!solverVariable3.isFinalValue) {
|
|
|
|
solverVariable3.setFinalValue(this, arrayRow.constantValue);
|
|
|
|
}
|
|
|
|
if (OPTIMIZED_ENGINE) {
|
|
|
|
this.mCache.optimizedArrayRowPool.release(arrayRow);
|
|
|
|
} else {
|
|
|
|
this.mCache.arrayRowPool.release(arrayRow);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void reset() {
|
|
|
|
Cache cache;
|
|
|
|
int i = 0;
|
|
|
|
while (true) {
|
|
|
|
cache = this.mCache;
|
|
|
|
SolverVariable[] solverVariableArr = cache.mIndexedVariables;
|
|
|
|
if (i >= solverVariableArr.length) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
SolverVariable solverVariable = solverVariableArr[i];
|
|
|
|
if (solverVariable != null) {
|
|
|
|
solverVariable.reset();
|
|
|
|
}
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
cache.solverVariablePool.releaseAll(this.mPoolVariables, this.mPoolVariablesCount);
|
|
|
|
this.mPoolVariablesCount = 0;
|
|
|
|
Arrays.fill(this.mCache.mIndexedVariables, (Object) null);
|
|
|
|
HashMap<String, SolverVariable> hashMap = this.mVariables;
|
|
|
|
if (hashMap != null) {
|
|
|
|
hashMap.clear();
|
|
|
|
}
|
|
|
|
this.mVariablesID = 0;
|
|
|
|
this.mGoal.clear();
|
|
|
|
this.mNumColumns = 1;
|
|
|
|
for (int i2 = 0; i2 < this.mNumRows; i2++) {
|
|
|
|
ArrayRow[] arrayRowArr = this.mRows;
|
|
|
|
if (arrayRowArr[i2] != null) {
|
|
|
|
arrayRowArr[i2].used = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
releaseRows();
|
|
|
|
this.mNumRows = 0;
|
|
|
|
if (OPTIMIZED_ENGINE) {
|
|
|
|
this.mTempGoal = new ValuesRow(this.mCache);
|
|
|
|
} else {
|
|
|
|
this.mTempGoal = new ArrayRow(this.mCache);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|