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
d5c9e592
Commit
d5c9e592
authored
3 years ago
by
Yingjian Wang
Browse files
Options
Downloads
Patches
Plain Diff
Update Constraints.jrag
parent
8e11b086
Branches
main
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/Constraints.jrag
+139
-64
139 additions, 64 deletions
src/main/jastadd/hanoi/Constraints.jrag
with
139 additions
and
64 deletions
src/main/jastadd/hanoi/Constraints.jrag
+
139
−
64
View file @
d5c9e592
...
@@ -34,13 +34,72 @@ aspect Connectives{
...
@@ -34,13 +34,72 @@ aspect Connectives{
eq Equal.eval(){
eq Equal.eval(){
return this.getLeft().eval() - this.getRight().eval()==0;
return this.getLeft().eval() - this.getRight().eval()==0;
}
}
public double Term.eval(){
uncache Term.eval();
syn int Term.eval();
eq Plus.eval(){
return this.getLeft().eval() + this.getRight().eval();
}
eq Minus.eval(){
return this.getLeft().eval() - this.getRight().eval();
}
eq Multi.eval(){
return this.getLeft().eval() * this.getRight().eval();
}
eq Divide.eval(){
return this.getLeft().eval() / this.getRight().eval();
}
eq Mod.eval(){
return this.getLeft().eval() % this.getRight().eval();
}
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()){
return 1;
}
return 0;
}
eq EqualFunction.eval(){
if(this.getLeft().eval() == this.getRight().eval()){
return 1;
}
return 0;
return 0;
}
}
public int Term.evalD(){
eq SubsetofFunction.eval(){
Set left=new HashSet<>();
for(String element : this.getLeft().Set()){
left.add(element);
}
Set right=new HashSet<>();
for(String element : this.getRight().Set()){
right.add(element);
}
if(right.containsAll(left)){
return 1;
}
return 0;
return 0;
}
}
public double Term1.eval(){//return the size of top disk
eq ConstantNum.eval(){
return this.getNum();
}
eq PillarID.eval(){
return this.getRel().ID();
}
eq TotalDiskAmount.eval(){
return this.getRel().AmountD();
}
eq DisksOnPillar.eval(){
return this.getRel().getNumDisk();
}
eq TopDiskSize.eval(){
return this.getRel().getDisk(this.getRel().getNumDisk()-1).getSize();
}
//customerized terms
eq Term1.eval(){//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();
...
@@ -48,14 +107,30 @@ aspect Connectives{
...
@@ -48,14 +107,30 @@ aspect Connectives{
return -1;//no disk, the number is invalid, return -1
return -1;//no disk, the number is invalid, return -1
}
}
}
}
public doubl
e Term2.eval(){
e
q
Term2.eval(){
return this.getRel().moveSeq();
return this.getRel().moveSeq();
}
}
public doubl
e Term3.eval(){
e
q
Term3.eval(){
return this.getRel().ID();
return this.getRel().ID();
}
}
public double ConstantNum.eval(){
uncache Condition.Satisfied();
return this.getNum();
syn boolean Condition.Satisfied();
eq CompareFunction.Satisfied(){
return this.getLeft().eval() < this.getRight().eval();
}
eq EqualFunction.Satisfied(){
return this.getLeft().eval() == this.getRight().eval();
}
eq SubsetofFunction.Satisfied(){
Set left=new HashSet<>();
for(String element : this.getLeft().Set()){
left.add(element);
}
Set right=new HashSet<>();
for(String element : this.getRight().Set()){
right.add(element);
}
return right.containsAll(left);
}
}
public String[] Term.Set(){
public String[] Term.Set(){
String[] str=new String[]{};
String[] str=new String[]{};
...
...
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