Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
U
UpdatedHanoi
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Yingjian Wang
UpdatedHanoi
Commits
2c771235
Commit
2c771235
authored
3 years ago
by
Yingjian Wang
Browse files
Options
Downloads
Patches
Plain Diff
Update Constraints.jrag
parent
2a28a070
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/jastadd/hanoi/ConstraintsEvalForDouble.jrag
+135
-0
135 additions, 0 deletions
src/main/jastadd/hanoi/ConstraintsEvalForDouble.jrag
with
135 additions
and
0 deletions
src/main/jastadd/hanoi/Constraints.jrag
→
src/main/jastadd/hanoi/Constraints
EvalForDouble
.jrag
+
135
−
0
View file @
2c771235
import java.util.*;
import java.util.*;
aspect Connectives{
aspect Connectives{
uncache Connective.eval();
uncache Connective.eval
Double
();
syn boolean Connective.eval();
syn boolean Connective.eval
Double
();
eq Conjunction.eval(){
eq Conjunction.eval
Double
(){
return this.getLeft().eval() && this.getRight().eval();
return this.getLeft().eval
Double
() && this.getRight().eval
Double
();
}
}
eq Disjunction.eval(){
eq Disjunction.eval
Double
(){
return this.getLeft().eval() || this.getRight().eval();
return this.getLeft().eval
Double
() || this.getRight().eval
Double
();
}
}
eq Implication.eval(){
eq Implication.eval
Double
(){
return (!this.getLeft().eval()) || this.getRight().eval();
return (!this.getLeft().eval
Double
()) || this.getRight().eval
Double
();
}
}
eq Negation.eval()= !getConnective().eval();
eq Negation.eval
Double
()= !getConnective().eval
Double
();
eq Atom.eval(){
eq Atom.eval
Double
(){
return this.getRelation().eval();
return this.getRelation().eval
Double
();
}
}
uncache Relation.eval();
uncache Relation.eval
Double
();
syn boolean Relation.eval();
syn boolean Relation.eval
Double
();
eq Subsetof.eval(){
eq Subsetof.eval
Double
(){
Set left=new HashSet<>();
Set left=new HashSet<>();
for(String element : this.getLeft().Set()){
for(String element : this.getLeft().Set()){
left.add(element);
left.add(element);
...
@@ -28,48 +28,48 @@ aspect Connectives{
...
@@ -28,48 +28,48 @@ aspect Connectives{
}
}
return right.containsAll(left);
return right.containsAll(left);
}
}
eq Compare.eval(){
eq Compare.eval
Double
(){
return (this.getLeft().eval() - this.getRight().eval())<0;
return (this.getLeft().eval
Double
() - this.getRight().eval
Double
())<0;
}
}
eq Equal.eval(){
eq Equal.eval
Double
(){
return this.getLeft().eval() - this.getRight().eval
()==0
;
return
(
this.getLeft().eval
Double
() - this.getRight().eval
Double()) < 0.01
;
}
}
uncache Term.eval();
uncache Term.eval
Double
();
syn
int
Term.eval();
syn
double
Term.eval
Double
();
eq Plus.eval(){
eq Plus.eval
Double
(){
return this.getLeft().eval() + this.getRight().eval();
return this.getLeft().eval
Double
() + this.getRight().eval
Double
();
}
}
eq Minus.eval(){
eq Minus.eval
Double
(){
return this.getLeft().eval() - this.getRight().eval();
return this.getLeft().eval
Double
() - this.getRight().eval
Double
();
}
}
eq Multi.eval(){
eq Multi.eval
Double
(){
return this.getLeft().eval() * this.getRight().eval();
return this.getLeft().eval
Double
() * this.getRight().eval
Double
();
}
}
eq Divide.eval(){
eq Divide.eval
Double
(){
return this.getLeft().eval() / this.getRight().eval();
return this.getLeft().eval
Double
() / this.getRight().eval
Double
();
}
}
eq Mod.eval(){
eq Mod.eval
Double
(){
return this.getLeft().eval() % this.getRight().eval();
return this.getLeft().eval
Double
() % this.getRight().eval
Double
();
}
}
eq IfThenElse.eval(){
eq CompareFunction.evalDouble(){
if(this.getIf().Satisfied()){
if(this.getLeft().evalDouble() < this.getRight().evalDouble()){
return this.getThen().eval();
}
return this.getElse().eval();
}
eq CompareFunction.eval(){
if(this.getLeft().eval() < this.getRight().eval()){
return 1;
return 1;
}
}
return 0;
return 0;
}
}
eq EqualFunction.eval(){
eq IfThenElse.evalDouble(){
if(this.getLeft().eval() == this.getRight().eval()){
if(this.getIf().SatisfiedDouble()){
return this.getThen().evalDouble();
}
return this.getElse().evalDouble();
}
eq EqualFunction.evalDouble(){
if(this.getLeft().evalDouble() == this.getRight().evalDouble()){
return 1;
return 1;
}
}
return 0;
return 0;
}
}
eq SubsetofFunction.eval(){
eq SubsetofFunction.eval
Double
(){
Set left=new HashSet<>();
Set left=new HashSet<>();
for(String element : this.getLeft().Set()){
for(String element : this.getLeft().Set()){
left.add(element);
left.add(element);
...
@@ -83,45 +83,45 @@ aspect Connectives{
...
@@ -83,45 +83,45 @@ aspect Connectives{
}
}
return 0;
return 0;
}
}
eq ConstantNum.eval(){
eq ConstantNum.eval
Double
(){
return this.getNum();
return this.getNum();
}
}
eq PillarID.eval(){
eq PillarID.eval
Double
(){
return this.getRel().ID();
return this.getRel().ID();
}
}
eq TotalDiskAmount.eval(){
eq TotalDiskAmount.eval
Double
(){
return this.getRel().
AmountD
();
return this.getRel().
getNumDisk
();
}
}
eq DisksOnPillar.eval(){
eq DisksOnPillar.eval
Double
(){
return this.getRel().getNumDisk();
return this.getRel().getNumDisk();
}
}
eq TopDiskSize.eval(){
eq TopDiskSize.eval
Double
(){
return this.getRel().getDisk(this.getRel().getNumDisk()-1).getSize();
return this.getRel().getDisk(this.getRel().getNumDisk()-1).getSize();
}
}
//customerized terms
//customerized terms
eq Term1.eval(){//return the size of top disk
eq Term1.eval
Double
(){//return the size of top disk
if(this.getRel().getNumDisk()>0){
if(this.getRel().getNumDisk()>0){
//if the pillar is not empty, check if the top disk has size 1
//if the pillar is not empty, check if the top disk has size 1
return this.getRel().getDisk(this.getRel().getNumDisk()-1).getSize();
return this.getRel().getDisk(this.getRel().getNumDisk()-1).getSize();
}else{
}else{
return -1;//no disk, the number is invalid, return -1
return -1
.0
;//no disk, the number is invalid, return -1
}
}
}
}
eq Term2.eval(){
eq Term2.eval
Double
(){
return this.getRel().moveSeq();
return this.getRel().moveSeq();
}
}
eq Term3.eval(){
eq Term3.eval
Double
(){
return this.getRel().ID();
return this.getRel().ID();
}
}
uncache Condition.Satisfied();
uncache Condition.Satisfied
Double
();
syn boolean Condition.Satisfied();
syn boolean Condition.Satisfied
Double
();
eq CompareFunction.Satisfied(){
eq CompareFunction.Satisfied
Double
(){
return this.getLeft().eval() < this.getRight().eval();
return this.getLeft().eval
Double
() < this.getRight().eval
Double
();
}
}
eq EqualFunction.Satisfied(){
eq EqualFunction.Satisfied
Double
(){
return this.getLeft().eval()
==
this.getRight().eval
(
);
return
(
this.getLeft().eval
Double
()
-
this.getRight().eval
Double() < 0.01
);
}
}
eq SubsetofFunction.Satisfied(){
eq SubsetofFunction.Satisfied
Double
(){
Set left=new HashSet<>();
Set left=new HashSet<>();
for(String element : this.getLeft().Set()){
for(String element : this.getLeft().Set()){
left.add(element);
left.add(element);
...
@@ -132,8 +132,4 @@ aspect Connectives{
...
@@ -132,8 +132,4 @@ aspect Connectives{
}
}
return right.containsAll(left);
return right.containsAll(left);
}
}
public String[] Term.Set(){
String[] str=new String[]{};
return str;
}
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment