Skip to content

Optimization/weights #129

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 130 commits into from
May 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
130 commits
Select commit Hold shift + click to select a range
d64f2b7
refactor: extracted RepresentativeWeight from InferenceWeight
swissiety Mar 3, 2025
0a1d4d8
added generics to RepresentativeWeight
swissiety Mar 3, 2025
8e5a8f2
simplifications
swissiety Mar 3, 2025
7e97a42
added TransitionRepresentationFunction.java
Akshayaquinnox Mar 3, 2025
fc9fc93
added TransitionRepresentationFunction.java
Akshayaquinnox Mar 3, 2025
7026a1e
added TransitionRepresentationFunction.java
Akshayaquinnox Mar 3, 2025
30fb631
added TransitionRepresentationFunction.java
Akshayaquinnox Mar 3, 2025
431426d
added TransitionRepresentationFunction.java
Akshayaquinnox Mar 3, 2025
3a5764a
added TransitionRepresentationFunction.java
Akshayaquinnox Mar 3, 2025
45d4e30
added TransitionRepresentationFunction.java
Akshayaquinnox Mar 3, 2025
dd7809a
added TransitionRepresentationFunction.java
Akshayaquinnox Mar 4, 2025
cc86a03
added TransitionRepresentationFunction.java
Akshayaquinnox Mar 4, 2025
d6fcf53
added TransitionRepresentationFunction.java
Akshayaquinnox Mar 4, 2025
5af9659
added TransitionRepresentationFunction.java
Akshayaquinnox Mar 4, 2025
e05d4ee
added TransitionRepresentationFunction.java
Akshayaquinnox Mar 4, 2025
109718b
added TransitionRepresentationFunction.java
Akshayaquinnox Mar 4, 2025
283a850
added TransitionRepresentationFunction.java
Akshayaquinnox Mar 4, 2025
b728df8
added TransitionRepresentationFunction.java
Akshayaquinnox Mar 4, 2025
6e949cf
added TransitionRepresentationFunction.java
Akshayaquinnox Mar 4, 2025
be8020e
added TransitionRepresentationFunction.java
Akshayaquinnox Mar 4, 2025
0af6538
added TransitionRepresentationFunction.java
Akshayaquinnox Mar 4, 2025
d14e1a5
added TransitionRepresentationFunction.java
Akshayaquinnox Mar 4, 2025
40b4b3b
added TransitionRepresentationFunction.java
Akshayaquinnox Mar 4, 2025
135d1a2
added TransitionRepresentationFunction.java
Akshayaquinnox Mar 4, 2025
38fd6d5
added TransitionRepresentationFunction.java
Akshayaquinnox Mar 4, 2025
5d7db2a
added TransitionRepresentationFunction.java
Akshayaquinnox Mar 4, 2025
35a9116
added TransitionRepresentationFunction.java
Akshayaquinnox Mar 4, 2025
bfaf9ff
added TransitionRepresentationFunction.java
Akshayaquinnox Mar 4, 2025
3b4fe9c
Merge remote-tracking branch 'origin/refactor/transitionfunction' int…
Akshayaquinnox Mar 4, 2025
d89f660
added TransitionRepresentationFunction.java
Akshayaquinnox Mar 4, 2025
a14c744
added TransitionRepresentationFunction.java
Akshayaquinnox Mar 4, 2025
b9d03ba
added TransitionRepresentationFunction.java
Akshayaquinnox Mar 4, 2025
5470b76
added TransitionRepresentationFunction.java
Akshayaquinnox Mar 4, 2025
21fecaf
added TransitionRepresentationFunction.java
Akshayaquinnox Mar 4, 2025
84f71ff
added TransitionRepresentationFunction.java
Akshayaquinnox Mar 4, 2025
f3765f6
added TransitionRepresentationFunction.java
Akshayaquinnox Mar 4, 2025
b736385
remove possible subclassing deadlock
swissiety Mar 5, 2025
867ae50
added PathTrackingRepresentativeWeight.java
Akshayaquinnox Mar 5, 2025
e641d98
added PathTrackingRepresentativeWeight.java
Akshayaquinnox Mar 5, 2025
5aa52f9
added PathTrackingRepresentativeWeight.java
Akshayaquinnox Mar 5, 2025
56147b4
refactor up TransitionFunction into an interface
swissiety Mar 5, 2025
e78f77c
Merge remote-tracking branch 'origin/refactor/weights' into refactor/…
swissiety Mar 5, 2025
92ca4ac
merge leftovers
swissiety Mar 5, 2025
a20eef1
fix merge+ compile errors
swissiety Mar 5, 2025
7b2d171
simplify & remove unnecessary copying
swissiety Mar 5, 2025
0efd70e
refactor & simplify TransitionFunction
swissiety Mar 6, 2025
d7d5978
simplified TransitionFunction(One|Zero) combineWith
swissiety Mar 6, 2025
bdd5a8f
refactor & reduce unnecessary Collection copying in TransitionFunctio…
swissiety Mar 6, 2025
6466e21
refactor & simplify Transition
swissiety Mar 6, 2025
4bb6391
refactor & simplify InferenceWeight
swissiety Mar 6, 2025
18cc59c
simpify zero/one names
swissiety Mar 6, 2025
052ff34
fix leftovrs
swissiety Mar 6, 2025
a060558
drastically simplify .zero()'s extendsWith logic
swissiety Mar 6, 2025
e6a1ba7
fix import
swissiety Mar 6, 2025
f2977f5
unify class+method naming
swissiety Mar 7, 2025
b0f9949
Merge branch 'develop' into refactor/weights
swissiety Mar 7, 2025
b7115ad
improve debug info
swissiety Mar 7, 2025
e2d0f9f
Created SetDomainInterface and the implmentation classes
Akshayaquinnox Mar 7, 2025
0d32b1d
compile regex Pattern and reuse it
swissiety Mar 7, 2025
9d30d87
Created MinDistanceWeightInterface and the implmentation classes
Akshayaquinnox Mar 7, 2025
96bfcf9
updated SetDomainImpl class
Akshayaquinnox Mar 7, 2025
d801033
more detailed debug msg
swissiety Mar 10, 2025
b812410
Merge remote-tracking branch 'origin/refactor/weights' into refactor/…
swissiety Mar 10, 2025
5a37764
DataFlowInterface implementation
Akshayaquinnox Mar 10, 2025
1615e47
Merge remote-tracking branch 'origin/refactor/weights' into refactor/…
swissiety Mar 11, 2025
ff9e307
fix typehierarchy / return types / generics
swissiety Mar 11, 2025
2f8818b
fixup semantics - don't return just empty collections etc to silence …
swissiety Mar 11, 2025
aaff2bb
Merge branch 'develop' into refactor/weights
swissiety Mar 11, 2025
8017f0f
unify naming
swissiety Mar 11, 2025
28e5173
apply spotless
swissiety Mar 11, 2025
f0b611c
reverted combineWith and ExtendWith of InferenceWeightImpl.java and S…
Akshayaquinnox Mar 11, 2025
94b2599
reverted combineWith and ExtendWith of InferenceWeightImpl.java and S…
Akshayaquinnox Mar 11, 2025
c1e1d46
Reverted combineWith and ExtendWith of InferenceWeightImpl.java,Trans…
Akshayaquinnox Mar 11, 2025
181e7cf
unify class & interface naming
swissiety Mar 12, 2025
85abc98
Merge branch 'develop' into refactor/weights
swissiety Mar 12, 2025
76d686e
REVERTING COMBINEWITRH AND EXTENDWITH
Akshayaquinnox Mar 13, 2025
e4ebb23
Checks on CombineWith and ExtendWith
Akshayaquinnox Mar 14, 2025
11cb237
Removing Throwable in NumWeightOne
Akshayaquinnox Mar 17, 2025
f388a63
Adding Default Values
Akshayaquinnox Mar 17, 2025
3151db8
Adding Default Values
Akshayaquinnox Mar 17, 2025
1aedb07
Adding Default Values
Akshayaquinnox Mar 17, 2025
09078ec
fix combineWith; style
swissiety Mar 17, 2025
aa011bc
keeping the original behaviour
swissiety Mar 17, 2025
6e4541e
Merge branch 'develop' into refactor/weights
swissiety Mar 17, 2025
ee4688d
adapt to using the interface
swissiety Mar 17, 2025
0191c8c
Changes in WPDS
Akshayaquinnox Mar 18, 2025
feca811
Changes in WPDS
Akshayaquinnox Mar 18, 2025
5383122
Changes in WPDS
Akshayaquinnox Mar 18, 2025
4ce7c5e
changes in WPDS
Akshayaquinnox Mar 18, 2025
6a483de
improve exception notification
swissiety Mar 19, 2025
0a8ffc9
fix class cast error
swissiety Mar 19, 2025
c5c94c4
Merge branch 'develop' into refactor/weights
swissiety Mar 19, 2025
8a6cab8
Revert "changes in WPDS"
Akshayaquinnox Mar 19, 2025
6509c13
Revert "Changes in WPDS"
Akshayaquinnox Mar 19, 2025
fd8e12d
Revert "Changes in WPDS"
Akshayaquinnox Mar 19, 2025
26e33d0
Revert "Changes in WPDS"
Akshayaquinnox Mar 19, 2025
630485f
optimization Changes in the new Branch
Akshayaquinnox Mar 24, 2025
82dd277
Spotless check on SetDomainZero.java
Akshayaquinnox Mar 24, 2025
c2cb133
Styling SetDomainZero.java
Akshayaquinnox Mar 24, 2025
ed60b7b
Spotless:apply on files
Akshayaquinnox Mar 24, 2025
27454ac
Solving Maven build error
Akshayaquinnox Mar 25, 2025
bc71e56
Optimizing CombinWith and ExtendWith
Akshayaquinnox Mar 22, 2025
e740f62
Revert "Optimizing CombinWith and ExtendWith"
Akshayaquinnox Mar 24, 2025
8ba9461
Nonnull to NonNull
Akshayaquinnox Mar 26, 2025
5dd26a7
Merge branch 'develop' into optimization/weights
Akshayaquinnox Mar 26, 2025
4b13dd3
Maven Build
Akshayaquinnox Mar 24, 2025
945a10d
Spotless:apply
Akshayaquinnox Mar 26, 2025
7b7527a
Removing obvious true/false cases
Akshayaquinnox Mar 28, 2025
d7a53c1
Merge branch 'develop' into optimization/weights
swissiety Mar 31, 2025
9c22edf
Spotless:apply
Akshayaquinnox Mar 31, 2025
1f6c27e
Merge remote-tracking branch 'origin/optimization/weights' into optim…
Akshayaquinnox Mar 31, 2025
8d764af
NumWeight and spotless:appply
Akshayaquinnox Mar 31, 2025
acda553
fix TransitionFunctionOne
swissiety Mar 31, 2025
0d21a80
Removing Unnecessary Parenthesis and checking other==one==this,other=…
Akshayaquinnox Mar 31, 2025
f7845ae
spotless:apply
Akshayaquinnox Mar 31, 2025
518caea
reverting TransitionFunctionOne.java
Akshayaquinnox Apr 1, 2025
054222f
Fixing ExtendWith of TransitionFunctionOne.java
Akshayaquinnox Apr 1, 2025
980274c
Fixing CombineWith of TransitionFunctionOne.java
Akshayaquinnox Apr 1, 2025
b8e4b16
remove unused Imports
Akshayaquinnox Apr 1, 2025
63e78ae
reverting extendWith TransitionFunctionOne.java
Akshayaquinnox Apr 1, 2025
fde00af
reverting TransitionFunctionOne
Akshayaquinnox Apr 1, 2025
e0937eb
Fixing TransitionFunctionOne.java
Akshayaquinnox Apr 1, 2025
c04495f
Merge remote-tracking branch 'origin/optimization/weights' into optim…
Akshayaquinnox Apr 1, 2025
3e05f67
spotless:apply to TransitionFunctionalOne
Akshayaquinnox Apr 1, 2025
b977324
Merge branch 'develop' into optimization/weights
schlichtig Apr 23, 2025
7937255
optimize extendswith/combinewith
swissiety May 15, 2025
3ca5f19
Merge branch 'develop' into optweight
swissiety May 16, 2025
14b5652
Merge branch 'optweight' into optimization/weights
swissiety May 16, 2025
7a02a20
fix merge leftovers
swissiety May 16, 2025
b318490
reintroduce lost field
swissiety May 16, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 11 additions & 15 deletions SynchronizedPDS/src/main/java/sync/pds/weights/SetDomainImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,30 +35,26 @@ public SetDomainImpl(Collection<Node<Stmt, Fact>> nodes) {

@NonNull
@Override
public Weight extendWith(Weight other) {
if (other.equals(one())) {
public Weight extendWith(@NonNull Weight other) {
Weight one = one();
if (other == one) {
return this;
}
if (this.equals(one())) {
return other;
}

return zero();
}

@NonNull
@Override
public Weight combineWith(@NonNull Weight other) {

if (other.equals(zero())) return this;
if (this.equals(zero())) return other;
if (this.equals(one()) || other.equals(one())) return one();

if (other instanceof SetDomainImpl) {
Set<Node<Stmt, Fact>> merged = Sets.newHashSet(nodes);
merged.addAll(((SetDomainImpl) other).nodes);
return new SetDomainImpl<N, Stmt, Fact>(merged);
}
return zero();
SetDomainZero zero = zero();
SetDomain one = one();
if (other == zero) return this;
if (other == one) return one;
Set<Node<Stmt, Fact>> merged = Sets.newHashSet(nodes);
merged.addAll(((SetDomainImpl) other).nodes);
return new SetDomainImpl<N, Stmt, Fact>(merged);
}

@NonNull
Expand Down
29 changes: 6 additions & 23 deletions SynchronizedPDS/src/main/java/sync/pds/weights/SetDomainOne.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
*/
package sync.pds.weights;

import static sync.pds.weights.SetDomainZero.zero;

import java.util.Collection;
import org.jspecify.annotations.NonNull;
import sync.pds.solver.nodes.Node;
Expand All @@ -24,39 +22,24 @@
public class SetDomainOne implements SetDomain {
@NonNull private static final SetDomainOne one = new SetDomainOne();

private SetDomainOne() {}
private SetDomainOne() {
/* Singleton*/
}

public static Weight one() {
public static SetDomainOne one() {
return one;
}

@NonNull
@Override
public Weight extendWith(@NonNull Weight other) {
if (other.equals(one())) {
return this;
}
if (this.equals(one())) {
return other;
}
return zero();
return other;
}

@NonNull
@Override
public Weight combineWith(@NonNull Weight other) {

if (other.equals(zero())) return this;
if (this.equals(zero())) return other;
if (this.equals(one()) || other.equals(one())) return one();

if (other instanceof SetDomainOne) {
throw new IllegalStateException("SetDomainOne.CombineWith-Dont");
// Set<Node<Stmt, Fact>> merged = Sets.newHashSet(getNodes());
// merged.addAll(((SetDomainImpl) other).getNodes());
// return new SetDomainImpl<N, Stmt, Fact>(merged);
}
return zero();
return this;
}

@NonNull
Expand Down
37 changes: 9 additions & 28 deletions SynchronizedPDS/src/main/java/sync/pds/weights/SetDomainZero.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,7 @@
*/
package sync.pds.weights;

import static sync.pds.weights.SetDomainOne.one;

import com.google.common.collect.Sets;
import java.util.Collection;
import java.util.HashSet;
import org.jspecify.annotations.NonNull;
import sync.pds.solver.nodes.Node;
import wpds.impl.Weight;
Expand All @@ -27,35 +23,24 @@ public class SetDomainZero implements SetDomain {

@NonNull private static final SetDomainZero zero = new SetDomainZero();

private SetDomainZero() {}
private SetDomainZero() {
/* Singleton */
}

public static SetDomainZero zero() {
return zero;
}

@NonNull
@Override
public Weight extendWith(@NonNull Weight other) {
if (other.equals(one())) {
return this;
}
if (this.equals(one())) {
return other;
}
return zero();
return this;
}

@NonNull
@Override
public Weight combineWith(@NonNull Weight other) {

if (other.equals(zero())) return this;
if (this.equals(zero())) return other;
if (this.equals(one()) || other.equals(one())) return one();

if (other instanceof SetDomainOne) {
HashSet<Node> merged = Sets.newHashSet(getNodes());
merged.addAll(((SetDomainImpl) other).getNodes());
throw new IllegalStateException("SetDomainZero.CombineWith-Dont");
// return new SetDomainImpl<N, Stmt, Fact>(merged);
}
return zero();
return other;
}

@NonNull
Expand All @@ -64,10 +49,6 @@ public Collection<Node> getNodes() {
throw new IllegalStateException("SetDomain.getNodes() - don't");
}

public static SetDomainZero zero() {
return zero;
}

@NonNull
@Override
public Collection<Node> elements() {
Expand Down
6 changes: 6 additions & 0 deletions WPDS/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
<dependency>
<groupId>de.fraunhofer.iem</groupId>
<artifactId>PDS</artifactId>
<version>4.0.0</version>
</dependency>
<dependency>
<groupId>de.fraunhofer.iem</groupId>
Expand All @@ -37,5 +38,10 @@
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
<dependency>
<groupId>org.jspecify</groupId>
<artifactId>jspecify</artifactId>
<version>1.0.0</version>
</dependency>
</dependencies>
</project>
4 changes: 2 additions & 2 deletions WPDS/src/test/java/tests/MinSeminringPostStarTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public void twoCall() {
}

private static MinSemiring w(int i) {
return new MinSemiring(i);
return new MinSemiringImpl(i);
}

static WeightedPAutomaton<StackSymbol, Abstraction, MinSemiring> waccepts(
Expand All @@ -124,7 +124,7 @@ public StackSymbol epsilon() {

@Override
public MinSemiring getOne() {
return MinSemiring.one();
return MinSemiringOne.one();
}

@Override
Expand Down
80 changes: 2 additions & 78 deletions WPDS/src/test/java/tests/MinSemiring.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,84 +14,8 @@
*/
package tests;

import de.fraunhofer.iem.Location;
import org.jspecify.annotations.NonNull;
import wpds.impl.Weight;

public class MinSemiring implements Weight {
int i;

public MinSemiring(int i) {
this.i = i;
}

private MinSemiring() {}

@NonNull
@Override
public Weight extendWith(@NonNull Weight other) {
if (other.equals(one())) return this;
if (this.equals(one())) return other;
MinSemiring o = (MinSemiring) other;
return new MinSemiring(o.i + i);
}

@NonNull
@Override
public Weight combineWith(@NonNull Weight other) {
if (other.equals(zero())) return this;
if (this.equals(zero())) return other;
MinSemiring o = (MinSemiring) other;
return new MinSemiring(Math.min(o.i, i));
}

private static MinSemiring one;

public static <N extends Location> MinSemiring one() {
if (one == null)
one =
new MinSemiring(0) {
@Override
public String toString() {
return "<ONE>";
}
};
return one;
}

private static MinSemiring zero;

public static <N extends Location> MinSemiring zero() {
if (zero == null)
zero =
new MinSemiring(110000) {
@Override
public String toString() {
return "<ZERO>";
}
};
return zero;
}

@Override
public String toString() {
return Integer.toString(i);
}

@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + i;
return result;
}

@Override
public boolean equals(Object obj) {
if (this == obj) return true;
if (obj == null) return false;
if (getClass() != obj.getClass()) return false;
MinSemiring other = (MinSemiring) obj;
return i == other.i;
}
public interface MinSemiring extends Weight {
int getValue();
}
76 changes: 76 additions & 0 deletions WPDS/src/test/java/tests/MinSemiringImpl.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
/**
* *****************************************************************************
* Copyright (c) 2018 Fraunhofer IEM, Paderborn, Germany
* <p>
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
* <p>
* SPDX-License-Identifier: EPL-2.0
* <p>
* Contributors:
* Johannes Spaeth - initial API and implementation
* *****************************************************************************
*/
package tests;

import static tests.MinSemiringOne.one;
import static tests.MinSemiringZero.zero;

import org.jspecify.annotations.NonNull;
import wpds.impl.Weight;

public class MinSemiringImpl implements MinSemiring {

protected final int value;

public MinSemiringImpl(int value) {
this.value = value;
}

public int getValue() {
return value;
}

@NonNull
@Override
public Weight extendWith(@NonNull Weight other) {
if (other == one()) {
return this;
}
MinSemiringImpl o = (MinSemiringImpl) other;
return new MinSemiringImpl(o.value + value);
}

@NonNull
@Override
public Weight combineWith(@NonNull Weight other) {
if (other == zero()) {
return this;
}
MinSemiringImpl o = (MinSemiringImpl) other;
return new MinSemiringImpl(Math.min(o.value, value));
}

@Override
public String toString() {
return Integer.toString(value);
}

@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + value;
return result;
}

@Override
public boolean equals(Object obj) {
if (this == obj) return true;
if (obj == null) return false;
if (getClass() != obj.getClass()) return false;
MinSemiringImpl other = (MinSemiringImpl) obj;
return value == other.value;
}
}
Loading