Skip to content
Snippets Groups Projects
Commit 36764f48 authored by MASSAT Jean luc's avatar MASSAT Jean luc
Browse files

Update

parent 7728fd27
No related branches found
No related tags found
No related merge requests found
......@@ -8,6 +8,9 @@ build/
.idea/modules.xml
.idea/jarRepositories.xml
.idea/compiler.xml
.idea/gradle.xml
.idea/vcs.xml
.idea/workspace.xml
.idea/libraries/
*.iws
*.iml
......
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="GradleMigrationSettings" migrationVersion="1" />
<component name="GradleSettings">
<option name="linkedExternalProjectsSettings">
<GradleProjectSettings>
......
......@@ -5,7 +5,10 @@
</component>
<component name="ChangeListManager">
<list default="true" id="a17b64ea-8b68-4cd2-aba6-1780c674b35e" name="Changes" comment="Clean">
<change beforePath="$PROJECT_DIR$/.gitignore" beforeDir="false" afterPath="$PROJECT_DIR$/.gitignore" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/gradle.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/gradle.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/fr/univamu/solver/Solver.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/fr/univamu/solver/Solver.java" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
......@@ -20,31 +23,31 @@
<component name="Git.Settings">
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
</component>
<component name="ProjectColorInfo"><![CDATA[{
"associatedIndex": 2
}]]></component>
<component name="ProjectColorInfo">{
&quot;associatedIndex&quot;: 2
}</component>
<component name="ProjectId" id="2mvqVujSHxI14AYjE6lvdsJNkMj" />
<component name="ProjectLevelVcsManager" settingsEditedManually="true" />
<component name="ProjectViewState">
<option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" />
</component>
<component name="PropertiesComponent"><![CDATA[{
"keyToString": {
"Gradle.GL-Solver [:fr.univamu.solver.Main.main()].executor": "Run",
"Gradle.Tests in 'GL-Solver'.executor": "Run",
"Gradle.Tests in 'fr.univamu.solver'.executor": "Run",
"RunOnceActivity.ShowReadmeOnStart": "true",
"git-widget-placeholder": "master",
"kotlin-language-version-configured": "true",
"node.js.detected.package.eslint": "true",
"node.js.detected.package.tslint": "true",
"node.js.selected.package.eslint": "(autodetect)",
"node.js.selected.package.tslint": "(autodetect)",
"nodejs_package_manager_path": "npm",
"vue.rearranger.settings.migration": "true"
<component name="PropertiesComponent">{
&quot;keyToString&quot;: {
&quot;Gradle.GL-Solver [:fr.univamu.solver.Main.main()].executor&quot;: &quot;Run&quot;,
&quot;Gradle.Tests in 'GL-Solver'.executor&quot;: &quot;Run&quot;,
&quot;Gradle.Tests in 'fr.univamu.solver'.executor&quot;: &quot;Run&quot;,
&quot;RunOnceActivity.ShowReadmeOnStart&quot;: &quot;true&quot;,
&quot;git-widget-placeholder&quot;: &quot;master&quot;,
&quot;kotlin-language-version-configured&quot;: &quot;true&quot;,
&quot;node.js.detected.package.eslint&quot;: &quot;true&quot;,
&quot;node.js.detected.package.tslint&quot;: &quot;true&quot;,
&quot;node.js.selected.package.eslint&quot;: &quot;(autodetect)&quot;,
&quot;node.js.selected.package.tslint&quot;: &quot;(autodetect)&quot;,
&quot;nodejs_package_manager_path&quot;: &quot;npm&quot;,
&quot;vue.rearranger.settings.migration&quot;: &quot;true&quot;
}
}]]></component>
}</component>
<component name="RunManager" selected="Gradle.Tests in 'GL-Solver'">
<configuration name="Main" type="Application" factoryName="Application" temporary="true" nameIsGenerated="true">
<option name="MAIN_CLASS_NAME" value="fr.univamu.solver.Main" />
......@@ -129,7 +132,8 @@
<option name="number" value="Default" />
<option name="presentableId" value="Default" />
<updated>1727967430355</updated>
<workItem from="1727967431394" duration="6814000" />
<workItem from="1727967431394" duration="6834000" />
<workItem from="1728024944251" duration="2652000" />
</task>
<task id="LOCAL-00001" summary="Create">
<option name="closed" value="true" />
......@@ -163,7 +167,15 @@
<option name="project" value="LOCAL" />
<updated>1727971953919</updated>
</task>
<option name="localTasksCounter" value="5" />
<task id="LOCAL-00005" summary="Clean">
<option name="closed" value="true" />
<created>1727988463386</created>
<option name="number" value="00005" />
<option name="presentableId" value="LOCAL-00005" />
<option name="project" value="LOCAL" />
<updated>1727988463386</updated>
</task>
<option name="localTasksCounter" value="6" />
<servers />
</component>
<component name="TypeScriptGeneratedFilesManager">
......
......@@ -50,6 +50,7 @@ public class Solver {
private long nodesCounter = 0;
private long maxNodes = 1000_000_000L;
private boolean verbose = true;
private boolean modified = false;
public void reduceAndCheckIntervalsStrategy() {
strategy = REDUCE_AND_CHECK_INTERVALS_STRATEGY;
......@@ -73,23 +74,6 @@ public class Solver {
return (!ko);
}
private boolean reduceAddConstraint(Constraint c) {
var change = c.getResult().reduce(c.getVar1().add(c.getVar2()));
change = c.getVar1().reduce(c.getResult().sub(c.getVar2())) || change;
change = c.getVar2().reduce(c.getResult().sub(c.getVar1())) || change;
return change;
}
private boolean reduceMulConstraint(Constraint c) {
var change = false;
for (int i = 0; i < 3; i++) {
change = c.getResult().reduce(c.getVar1().mul(c.getVar2())) || change;
change = c.getVar2().reduce(c.getResult().inverseMul(c.getVar1())) || change;
change = c.getVar1().reduce(c.getResult().inverseMul(c.getVar2())) || change;
}
return change;
}
private boolean checkConstraintIntervalsStrategy(Constraint c) {
return switch (c.getType()) {
case '+' -> checkAddConstraintIntervalsStrategy(c);
......@@ -100,12 +84,46 @@ public class Solver {
};
}
private boolean reduce(Constraint c) {
return switch (c.getType()) {
case '+' -> reduceAddConstraint(c);
case '*' -> reduceMulConstraint(c);
default -> false;
};
private void reduceAddConstraint(Constraint c) {
modified = c.getResult().reduce(c.getVar1().add(c.getVar2())) || modified;
modified = c.getVar1().reduce(c.getResult().sub(c.getVar2())) || modified;
modified = c.getVar2().reduce(c.getResult().sub(c.getVar1())) || modified;
}
private void reduceMulConstraint(Constraint c) {
for (int i = 0; i < 3; i++) {
modified = c.getResult().reduce(c.getVar1().mul(c.getVar2())) || modified;
modified = c.getVar2().reduce(c.getResult().inverseMul(c.getVar1())) || modified;
modified = c.getVar1().reduce(c.getResult().inverseMul(c.getVar2())) || modified;
}
}
private void reduce(Constraint c) {
switch (c.getType()) {
case '+':
reduceAddConstraint(c);
break;
case '*':
reduceMulConstraint(c);
break;
}
}
private void reduce() {
if (verbose) {
System.out.println("Variables before reduction:");
variables.forEach(System.out::println);
}
do {
modified = false;
constraints.forEach(this::reduce);
} while (modified);
if (verbose) {
System.out.println("Variables after reduction:");
variables.forEach(System.out::println);
}
}
private boolean checkConstraint(Constraint c) {
......@@ -342,27 +360,6 @@ public class Solver {
return result;
}
private void reduce() {
if (verbose) {
System.out.println("Variables before reduction:");
variables.forEach(System.out::println);
}
for (boolean change = true; change; ) {
change = false;
for (Constraint c : constraints) {
if (reduce(c)) {
change = true;
}
}
}
if (verbose) {
System.out.println("Variables after reduction:");
variables.forEach(System.out::println);
}
}
public long solve() {
this.solutionsCounter = 0;
this.nodesCounter = 0;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment