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
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.*;
aspect Connectives{
uncache Connective.eval();
syn boolean Connective.eval();
eq Conjunction.eval(){
return this.getLeft().eval() && this.getRight().eval();
uncache Connective.eval
Double
();
syn boolean Connective.eval
Double
();
eq Conjunction.eval
Double
(){
return this.getLeft().eval
Double
() && this.getRight().eval
Double
();
}
eq Disjunction.eval(){
return this.getLeft().eval() || this.getRight().eval();
eq Disjunction.eval
Double
(){
return this.getLeft().eval
Double
() || this.getRight().eval
Double
();
}
eq Implication.eval(){
return (!this.getLeft().eval()) || this.getRight().eval();
eq Implication.eval
Double
(){
return (!this.getLeft().eval
Double
()) || this.getRight().eval
Double
();
}
eq Negation.eval()= !getConnective().eval();
eq Atom.eval(){
return this.getRelation().eval();
eq Negation.eval
Double
()= !getConnective().eval
Double
();
eq Atom.eval
Double
(){
return this.getRelation().eval
Double
();
}
uncache Relation.eval();
syn boolean Relation.eval();
eq Subsetof.eval(){
uncache Relation.eval
Double
();
syn boolean Relation.eval
Double
();
eq Subsetof.eval
Double
(){
Set left=new HashSet<>();
for(String element : this.getLeft().Set()){
left.add(element);
...
...
@@ -28,48 +28,48 @@ aspect Connectives{
}
return right.containsAll(left);
}
eq Compare.eval(){
return (this.getLeft().eval() - this.getRight().eval())<0;
eq Compare.eval
Double
(){
return (this.getLeft().eval
Double
() - this.getRight().eval
Double
())<0;
}
eq Equal.eval(){
return this.getLeft().eval() - this.getRight().eval
()==0
;
eq Equal.eval
Double
(){
return
(
this.getLeft().eval
Double
() - this.getRight().eval
Double()) < 0.01
;
}
uncache Term.eval();
syn
int
Term.eval();
eq Plus.eval(){
return this.getLeft().eval() + this.getRight().eval();
uncache Term.eval
Double
();
syn
double
Term.eval
Double
();
eq Plus.eval
Double
(){
return this.getLeft().eval
Double
() + this.getRight().eval
Double
();
}
eq Minus.eval(){
return this.getLeft().eval() - this.getRight().eval();
eq Minus.eval
Double
(){
return this.getLeft().eval
Double
() - this.getRight().eval
Double
();
}
eq Multi.eval(){
return this.getLeft().eval() * this.getRight().eval();
eq Multi.eval
Double
(){
return this.getLeft().eval
Double
() * this.getRight().eval
Double
();
}
eq Divide.eval(){
return this.getLeft().eval() / this.getRight().eval();
eq Divide.eval
Double
(){
return this.getLeft().eval
Double
() / this.getRight().eval
Double
();
}
eq Mod.eval(){
return this.getLeft().eval() % this.getRight().eval();
eq Mod.eval
Double
(){
return this.getLeft().eval
Double
() % this.getRight().eval
Double
();
}
eq IfThenElse.eval(){
if(this.getIf().Satisfied()){
return this.getThen().eval();
}
return this.getElse().eval();
}
eq CompareFunction.eval(){
if(this.getLeft().eval() < this.getRight().eval()){
eq CompareFunction.evalDouble(){
if(this.getLeft().evalDouble() < this.getRight().evalDouble()){
return 1;
}
return 0;
}
eq EqualFunction.eval(){
if(this.getLeft().eval() == this.getRight().eval()){
eq IfThenElse.evalDouble(){
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 0;
}
eq SubsetofFunction.eval(){
eq SubsetofFunction.eval
Double
(){
Set left=new HashSet<>();
for(String element : this.getLeft().Set()){
left.add(element);
...
...
@@ -83,45 +83,45 @@ aspect Connectives{
}
return 0;
}
eq ConstantNum.eval(){
eq ConstantNum.eval
Double
(){
return this.getNum();
}
eq PillarID.eval(){
eq PillarID.eval
Double
(){
return this.getRel().ID();
}
eq TotalDiskAmount.eval(){
return this.getRel().
AmountD
();
eq TotalDiskAmount.eval
Double
(){
return this.getRel().
getNumDisk
();
}
eq DisksOnPillar.eval(){
eq DisksOnPillar.eval
Double
(){
return this.getRel().getNumDisk();
}
eq TopDiskSize.eval(){
eq TopDiskSize.eval
Double
(){
return this.getRel().getDisk(this.getRel().getNumDisk()-1).getSize();
}
//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 the pillar is not empty, check if the top disk has size 1
return this.getRel().getDisk(this.getRel().getNumDisk()-1).getSize();
}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();
}
eq Term3.eval(){
eq Term3.eval
Double
(){
return this.getRel().ID();
}
uncache Condition.Satisfied();
syn boolean Condition.Satisfied();
eq CompareFunction.Satisfied(){
return this.getLeft().eval() < this.getRight().eval();
uncache Condition.Satisfied
Double
();
syn boolean Condition.Satisfied
Double
();
eq CompareFunction.Satisfied
Double
(){
return this.getLeft().eval
Double
() < this.getRight().eval
Double
();
}
eq EqualFunction.Satisfied(){
return this.getLeft().eval()
==
this.getRight().eval
(
);
eq EqualFunction.Satisfied
Double
(){
return
(
this.getLeft().eval
Double
()
-
this.getRight().eval
Double() < 0.01
);
}
eq SubsetofFunction.Satisfied(){
eq SubsetofFunction.Satisfied
Double
(){
Set left=new HashSet<>();
for(String element : this.getLeft().Set()){
left.add(element);
...
...
@@ -132,8 +132,4 @@ aspect Connectives{
}
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