Skip to content
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

Hints #152

Open
wants to merge 52 commits into
base: hints
Choose a base branch
from
Open

Hints #152

Changes from 1 commit
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
2f6f143
Update README.md
nmacedo Feb 5, 2020
cfda1fb
Update README.md
nmacedo Feb 5, 2020
6006397
Merge pull request #114 from haslab/dev
nmacedo Aug 7, 2020
5fefab1
Update .travis.yml
nmacedo Nov 13, 2020
f630973
Update .travis.yml
nmacedo Nov 13, 2020
55bb7ec
Update .travis.yml
nmacedo Nov 13, 2020
258da57
meteor updated
nmacedo Jan 20, 2023
7123311
Update gitignore
h-neto May 4, 2023
4aeba79
Rewritten API in Quarkus
h-neto May 16, 2023
72d585b
Proguess Save In Hint Implementation
h-neto Jun 2, 2023
419a638
Implemented Difference Algorithm
h-neto Jun 3, 2023
e8526c6
Mutaters + Several BugFixes/Workarounds
h-neto Jun 13, 2023
0cf234b
Update
h-neto Jun 21, 2023
2f1d190
Renable Mutation Hints
h-neto Jun 21, 2023
e2305c0
Small fix
h-neto Jun 28, 2023
44757f1
Small Fix
h-neto Jul 3, 2023
eb35428
Prestatistics cleanup
h-neto Jul 4, 2023
83528d4
Fixes + Test Methods
h-neto Jul 12, 2023
3782351
Major Cleanup
h-neto Jul 17, 2023
c72f847
Refactors
h-neto Jul 18, 2023
d4291f4
Cleanup of Edit operations
h-neto Jul 18, 2023
5ea93d2
QoL change
h-neto Jul 18, 2023
6f0a8c4
Position Map fix
h-neto Jul 18, 2023
43403e7
Nomenclature Fix
h-neto Jul 20, 2023
f652059
Update + Refactor
h-neto Jul 27, 2023
1fcb167
Quarkus Update
h-neto Jul 27, 2023
a18aafb
Update
h-neto Sep 12, 2023
95a6208
Update
h-neto Sep 13, 2023
4ca279d
Update
h-neto Sep 14, 2023
a11f2df
BugFixes
h-neto Sep 22, 2023
17a0466
Update
h-neto Sep 28, 2023
20e3645
Cleanup
h-neto Oct 9, 2023
53cd3c6
Rewrite Policy Algorithm
h-neto Oct 13, 2023
4278cb6
FIX
h-neto Oct 13, 2023
df5ec5c
UPDATE
h-neto Oct 15, 2023
af7fd78
Fix
h-neto Oct 15, 2023
dd02d57
Update
h-neto Oct 16, 2023
ea415c0
Normalization Redone
h-neto Oct 17, 2023
879e1b7
Fixes
h-neto Oct 17, 2023
fd9c49e
Update
h-neto Oct 20, 2023
75dd408
Update
h-neto Oct 21, 2023
8355c7d
Update
h-neto Oct 23, 2023
afdc3ff
Create LICENSE
nmacedo Oct 24, 2023
7eedff4
meteor and deps updated
nmacedo Oct 24, 2023
80aa185
Merge branch 'dev' of github.com:haslab/Alloy4Fun into dev
nmacedo Oct 24, 2023
c97f9b2
Merge pull request #151 from haslab/dev
nmacedo Oct 24, 2023
0057047
Fixes
h-neto Oct 24, 2023
be8a95a
Fix
h-neto Oct 24, 2023
457f346
Merge pull request #1 from haslab/master
h-neto Feb 7, 2024
cacc4d7
Dependency Fix
h-neto Jun 16, 2024
b6b89e3
Merge remote-tracking branch 'origin/master' into dev
h-neto Jun 16, 2024
b8f8950
Cleanup
h-neto Jun 16, 2024
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
Prev Previous commit
Next Next commit
Fixes
  • Loading branch information
h-neto committed Oct 17, 2023
commit 879e1b7a150c38ad8ac379b7f309d3a28f47be76
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package pt.haslab.specassistant.data.aggregation;

public class EntityDouble {
public Double d;
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package pt.haslab.specassistant.data.transfer;
package pt.haslab.specassistant.data.aggregation;

public class EntityStringLong {
public String s;
Original file line number Diff line number Diff line change
@@ -41,8 +41,6 @@ public class HintNode extends PanacheMongoEntity {

public Double score;

public Double delta;

public HintNode() {
}

Original file line number Diff line number Diff line change
@@ -4,6 +4,7 @@
import jakarta.enterprise.context.ApplicationScoped;
import org.bson.Document;
import org.bson.types.ObjectId;
import pt.haslab.specassistant.data.aggregation.EntityDouble;
import pt.haslab.specassistant.data.models.HintNode;
import pt.haslab.specassistant.services.policy.Probability;
import pt.haslab.specassistant.services.policy.Reward;
@@ -147,7 +148,7 @@ public void unsetDelta(ObjectId graph_id) {
update(new Document("$unset", new Document("delta", null))).where("graph_id", graph_id);
}

public Optional<HintNode> getHightestDelta(ObjectId graph_id) {
return find(new Document("graph_id", graph_id), new Document("delta", -1)).firstResultOptional();
public Optional<Double> getHightestDelta(ObjectId graph_id) {
return Optional.of(mongoCollection().aggregate(List.of(new Document("$match", new Document("graph_id", graph_id)), new Document("$project", new Document("d", "$delta")), new Document("$sort", new Document("delta", -1))), EntityDouble.class).iterator().next()).map(d -> d.d);
}
}
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@
import org.bson.Document;
import org.bson.types.ObjectId;
import pt.haslab.specassistant.data.models.Model;
import pt.haslab.specassistant.data.transfer.EntityStringLong;
import pt.haslab.specassistant.data.aggregation.EntityStringLong;

import java.util.Collection;
import java.util.Collections;
Original file line number Diff line number Diff line change
@@ -42,6 +42,31 @@ private void clearPolicy(ObjectId graph_id) {
edgeRepo.clearPolicyFromGraph(graph_id);
}


























public void policy_iteration(ObjectId graph_id, Double gamma, Reward r, Probability p) {
boolean unstable = true;
FutureUtil.inlineRuntime(randoomPolicy(graph_id));
@@ -93,7 +118,7 @@ public void policy_evaluation_mongo_pipeline(ObjectId graph_id, Double gamma, Re
do {
nodeRepo.unsetDelta(graph_id);
nodeRepo.policyImprovemenentInnerLoop(graph_id, gamma, r, p);
} while (nodeRepo.getHightestDelta(graph_id).map(x -> x.delta > r.getRequiredPrecision()).orElse(false));
} while (nodeRepo.getHightestDelta(graph_id).map(delta -> delta > r.getRequiredPrecision()).orElse(false));
}

public CompletableFuture<Void> randoomPolicy(ObjectId graph_id) {
@@ -119,15 +144,15 @@ public Boolean policy_improvement(ObjectId graph_id, Double gamma, Reward r, Pro
if (!actions.isEmpty()) {
try {

HintEdge old_ = actions.stream().filter(HintEdge::getPolicy).findFirst().orElseThrow();
HintEdge new_ = actions.stream().max(Comparator.comparingDouble(x -> bellman(gamma, r, p, x, n, nodeRepo.findById(x.destination)))).orElseThrow();
HintEdge old_ = actions.stream().filter(HintEdge::getPolicy).findFirst().orElseThrow();
HintEdge new_ = actions.stream().max(Comparator.comparingDouble(x -> bellman(gamma, r, p, x, n, nodeRepo.findById(x.destination)))).orElseThrow();

if (!Objects.equals(old_.id, new_.id)) {
edgeRepo.removeFromPolicy(old_.id);
edgeRepo.setAsPolicy(new_.id);
improved.set(true);
}
}catch (NoSuchElementException e){
if (!Objects.equals(old_.id, new_.id)) {
edgeRepo.removeFromPolicy(old_.id);
edgeRepo.setAsPolicy(new_.id);
improved.set(true);
}
} catch (NoSuchElementException e) {
throw e;
}
}