Commit 8e495e94 authored by Iran's avatar Iran
Browse files

finilized

parent 47a8f588
......@@ -10,39 +10,25 @@ apply plugin: 'application'
// The main class that will be executed when you do 'gradle run'
mainClassName = 'TestingMetaCSP'
sourceCompatibility = 1.6
targetCompatibility = 1.6
repositories {
// The meta-csp-framework (and all its dependencies) is on
// the Maven Central repository
mavenCentral()
// You can include any other Maven repository like this:
//maven {
// url '<URL of the repo>'
//}
//dependencies {
// compile 'com.github.FedericoPecora:meta-csp-framework:Tag'
//}
}
version = '0.0.0-SNAPSHOT'
// Call your group something meaninful, e.g., '<inverse-url>.<project-name>'
group = 'org.metacsp.project-template'
dependencies {
// This pulls in the meta-csp-framework jar
compile 'org.metacsp:meta-csp-framework:1.2.5'
// In this section you declare where to find the dependencies of your project
repositories {
maven { url 'https://jitpack.io' }
mavenCentral()
}
// Add the following if you need to include jars that are not
// in Maven Central and that you have places in the directory "lib"
// (NOTE: you have to create this directory if you need it)
//compile fileTree(dir: 'lib', include: '**/*.jar')
configurations.all {
resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
}
dependencies {
//compile 'com.github.FedericoPecora:coordination_oru:0.1.0'
//compile 'org.metacsp:meta-csp-framework:1.3.4'
compile 'com.github.FedericoPecora:coordination_oru:master-SNAPSHOT'
compile 'com.github.FedericoPecora:meta-csp-framework:master-SNAPSHOT'
compile fileTree(dir: 'lib', include: ['*.jar'])
}
File mode changed from 100644 to 100755
......@@ -21,11 +21,11 @@
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
******************************************************************************/
package oru.smarter;
import org.metacsp.booleanSAT.BooleanSatisfiabilitySolver;
import org.metacsp.booleanSAT.BooleanVariable;
import org.metacsp.framework.Constraint;
import org.metacsp.framework.ConstraintNetwork;
import org.metacsp.framework.ValueChoiceFunction;
import org.metacsp.framework.ValueOrderingH;
import org.metacsp.framework.VariableOrderingH;
import org.metacsp.meta.symbolsAndTime.ReusableResource;
......@@ -34,45 +34,50 @@ import org.metacsp.multi.activity.SymbolicVariableActivity;
import org.metacsp.multi.activity.ActivityNetworkSolver;
import org.metacsp.multi.allenInterval.AllenIntervalConstraint;
import org.metacsp.multi.allenInterval.AllenIntervalConstraint.Type;
import org.metacsp.time.APSPSolver;
import org.metacsp.time.Bounds;
import org.metacsp.utility.UI.Callback;
import org.metacsp.utility.timelinePlotting.TimelinePublisher;
import org.metacsp.utility.timelinePlotting.TimelineVisualizer;
/**
* @author Masoumeh Mansouri
*
*/
public class TestReusableResourceScheduler {
public static void main(String[] args) {
final Scheduler metaSolver = new Scheduler(0,600,0);
final ActivityNetworkSolver groundSolver = (ActivityNetworkSolver)metaSolver.getConstraintSolvers()[0];
SymbolicVariableActivity zero = (SymbolicVariableActivity)groundSolver.createVariable("comp1");
zero.setSymbolicDomain("2");
SymbolicVariableActivity one = (SymbolicVariableActivity)groundSolver.createVariable("comp1");
one.setSymbolicDomain("1");
SymbolicVariableActivity two = (SymbolicVariableActivity)groundSolver.createVariable("comp1");
two.setSymbolicDomain("3");
final SymbolicVariableActivity one = (SymbolicVariableActivity)groundSolver.createVariable("Robot 1");
one.setSymbolicDomain("2");
final SymbolicVariableActivity two = (SymbolicVariableActivity)groundSolver.createVariable("Robot 2");
two.setSymbolicDomain("1");
final SymbolicVariableActivity three = (SymbolicVariableActivity)groundSolver.createVariable("Robot 3");
three.setSymbolicDomain("3");
//DURATIONS
AllenIntervalConstraint dur1 = new AllenIntervalConstraint(AllenIntervalConstraint.Type.Duration, new Bounds(35, 55));
dur1.setFrom(zero);
dur1.setTo(zero);
dur1.setFrom(one);
dur1.setTo(one);
AllenIntervalConstraint dur2 = new AllenIntervalConstraint(AllenIntervalConstraint.Type.Duration, new Bounds(35, 55));
dur2.setFrom(one);
dur2.setTo(one);
dur2.setFrom(two);
dur2.setTo(two);
AllenIntervalConstraint dur3 = new AllenIntervalConstraint(AllenIntervalConstraint.Type.Duration, new Bounds(35, 55));
dur3.setFrom(two);
dur3.setTo(two);
dur3.setFrom(three);
dur3.setTo(three);
//PRECEDENCES
AllenIntervalConstraint con1 = new AllenIntervalConstraint(AllenIntervalConstraint.Type.Before, Type.Before.getDefaultBounds());
con1.setFrom(zero);
con1.setTo(one);
con1.setFrom(one);
con1.setTo(two);
//groundSolver.addConstraint(con1);
//Add the constraints
Constraint[] cons = new Constraint[]{dur1,dur2,dur3,con1};
Constraint[] cons = new Constraint[]{dur1,dur2,dur3};
groundSolver.addConstraints(cons);
//Most critical conflict is the one with most activities (largest peak)
VariableOrderingH varOH = new VariableOrderingH() {
@Override
......@@ -84,34 +89,46 @@ public class TestReusableResourceScheduler {
@Override
public void collectData(ConstraintNetwork[] allMetaVariables) {
}
};
//Add value ordering heuristic
ValueOrderingH valOH = new ValueOrderingH() {
@Override
public int compare(ConstraintNetwork o1, ConstraintNetwork o2) {
// TODO Auto-generated method stub
public int compare(ConstraintNetwork o1, ConstraintNetwork o2) {
return 0;
}
};
//introducing reusable resource with capacity 4
ReusableResource rr1 = new ReusableResource(varOH, valOH, 4);
rr1.setUsage(zero,one,two);
rr1.setUsage(one,two,three);
metaSolver.addMetaConstraint(rr1);
metaSolver.backtrack();
metaSolver.draw();
//Visualization
final TimelinePublisher tp = new TimelinePublisher(groundSolver.getConstraintNetwork(), "Robot 1", "Robot 2", "Robot 3");
TimelineVisualizer viz = new TimelineVisualizer(tp);
tp.publish(true, true);
System.out.println(zero);
System.out.println(one);
System.out.println(two);
Callback cb = new Callback() {
ConstraintNetwork.draw(metaSolver.getConstraintSolvers()[0].getConstraintNetwork());
@Override
public void performOperation() {
metaSolver.backtrack();
tp.publish(true, true);
metaSolver.draw();
}
};
ConstraintNetwork cn = metaSolver.getConstraintNetworksFromSolverHierarchy(APSPSolver.class)[0];
ConstraintNetwork.draw(cn, "APSPSolver (Floyd Warshall)", cb);
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment