ACassimiro / TSNsched

Automated Schedule Generation for Time-Sensitive Networks (TSN).
GNU General Public License v3.0
82 stars 37 forks source link

when set two flows with different periods,cant get the reult,which log the "The specified constraints MIGHT NOT be satisfiable" #26

Open Glory-Yin opened 2 years ago

Glory-Yin commented 2 years ago

here is the test code,which overwrites the SmallScenario.java the network is 4 devices and 6 switches and 2 flows,when flow1 send at 2ms, flow2 send at 2ms,the result is ok when flow1 send at 2ms, flow2 send at 3ms,the result is NOT be satisfiable. but i dont know why,becasue the z3 just give the final result,but which constraint is unknown.

package com.tsnsched.generated_scenarios; import java.util.; import java.io.; import com.tsnsched.core.nodes.; import com.tsnsched.core.components.Cycle; import com.tsnsched.core.components.Flow; import com.tsnsched.core.components.PathNode; import com.tsnsched.core.network.; import com.tsnsched.core.schedule_generator.*; import com.tsnsched.core.components.Port;

public class SmallScenario { public void runTestCase(){

    /*
     * GENERATING DEVICES
     */
    Device ccu = new Device(1000, 0, 1000, 1500);
    ccu.setName("ccu");

    Device ccu2 = new Device(1000, 0, 1000, 1500);
    ccu2.setName("ccu2");

    Device tcu = new Device(1000, 0, 1000, 1500);
    tcu.setName("tcu");

    Device bcu = new Device(1000, 0, 1000, 1500);
    bcu.setName("bcu");

    /*
     * GENERATING SWITCHES
     */
    TSNSwitch switch0 = new TSNSwitch("switch0", 100, 1, 125, 1, 400, 3000);
    TSNSwitch switch1 = new TSNSwitch("switch1", 100, 1, 125, 1, 400, 3000);
    TSNSwitch switch2 = new TSNSwitch("switch2", 100, 1, 125, 1, 400, 3000);
    TSNSwitch switch3 = new TSNSwitch("switch3", 100, 1, 125, 1, 400, 3000);
    TSNSwitch switch4 = new TSNSwitch("switch4", 100, 1, 125, 1, 400, 3000);
    TSNSwitch switch5 = new TSNSwitch("switch5", 100, 1, 125, 1, 400, 3000);

    /*
     * GENERATING SWITCH CONNECTION PORTS
     */
    Cycle cycle0 = new Cycle(50);
    Port port0 = switch0.createPort(switch1, cycle0);//switch0 use x11 to connect switch1 
    port0.setPortNum(11);
    port0.setName(port0.getName()+ "Port"+ "11");

    Cycle cycle1 = new Cycle(50);
    Port port1 = switch1.createPort(switch0, cycle1);
    port1.setPortNum(4);
    port1.setName(port1.getName()+ "Port"+ "4");

    Cycle cycle2 = new Cycle(50);
    Port port2 = switch1.createPort(switch2, cycle2);   
    port2.setPortNum(1);
    port2.setName(port2.getName()+ "Port"+ "1");

    Cycle cycle3 = new Cycle(50);
    Port port3 = switch2.createPort(switch1, cycle3);
    port3.setPortNum(2);
    port3.setName(port3.getName()+ "Port"+ "2");

    Cycle cycle4 = new Cycle(50);
    Port port4 = switch2.createPort(switch3, cycle4);
    port4.setPortNum(1);
    port4.setName(port4.getName()+ "Port"+ "1");

    Cycle cycle5 = new Cycle(50);
    Port port5 = switch3.createPort(switch2, cycle5);
    port5.setPortNum(2);
    port5.setName(port5.getName()+ "Port"+ "2");

    Cycle cycle6 = new Cycle(50);
    Port port6 = switch3.createPort(switch4, cycle6);
    port6.setPortNum(1);
    port6.setName(port6.getName()+ "Port"+ "1");

    Cycle cycle7 = new Cycle(50);
    Port port7 = switch4.createPort(switch3, cycle7);
    port7.setPortNum(2);
    port7.setName(port7.getName()+ "Port"+ "2");

    Cycle cycle8 = new Cycle(50);
    Port port8 = switch4.createPort(switch5, cycle8);
    port8.setPortNum(4);
    port8.setName(port8.getName()+ "Port"+ "4");

    Cycle cycle9 = new Cycle(50);
    Port port9 = switch5.createPort(switch4, cycle9);   
    port9.setPortNum(11);
    port9.setName(port9.getName()+ "Port"+ "11");

    /*
     * LINKING SWITCHES TO DEVICES
     */
    Cycle cycle10 = new Cycle(50);
    Port port10 = switch0.createPort(ccu, cycle10);
    port10.setPortNum(9);
    port10.setName(port10.getName()+ "Port"+ "9");

    Cycle cycle11 = new Cycle(50);
    Port port11 = switch5.createPort(tcu, cycle11);
    port11.setPortNum(9);
    port11.setName(port11.getName()+ "Port"+ "9");

    Cycle cycle12 = new Cycle(50);
    Port port12 = switch2.createPort(ccu2, cycle12);
    port12.setPortNum(9);
    port12.setName(port12.getName()+ "Port"+ "9");

    Cycle cycle13 = new Cycle(50);
    Port port13 = switch4.createPort(bcu, cycle13);
    port13.setPortNum(9);
    port13.setName(port13.getName()+ "Port"+ "9");

    /*
     * GENERATING FLOWS
     */
    LinkedList<PathNode> nodeList;

    Flow flow1 = new Flow(1,0,2000);
    //Flow flow1 = new Flow(Flow.UNICAST);
    flow1.setStartDevice(ccu);
    flow1.addToPath(ccu,switch0);
    flow1.addToPath(switch0,switch1);
    flow1.addToPath(switch1,switch2);
    flow1.addToPath(switch2,ccu2);
    flow1.addToPath(switch2,switch3);
    flow1.addToPath(switch3,switch4);
    flow1.addToPath(switch4,bcu);
    flow1.addToPath(switch4,switch5);
    flow1.addToPath(switch5,tcu);

    flow1.setPriorityValue(5);
    flow1.setFixedPriority(true);
    //flow1.setPacketSize(1500);
    //flow1.setFlowMaximumLatency(1000);
    flow1.setFlowSendingPeriodicity(2000);

    Flow flow2 = new Flow(1,0,2000);
    //Flow flow2 = new Flow(Flow.UNICAST);
    flow2.setStartDevice(ccu);
    flow2.addToPath(ccu,switch0);
    flow2.addToPath(switch0,switch1);
    flow2.addToPath(switch1,switch2);
    flow2.addToPath(switch2,ccu2);
    flow2.addToPath(switch2,switch3);
    flow2.addToPath(switch3,switch4);
    flow2.addToPath(switch4,bcu);
    flow2.addToPath(switch4,switch5);
    flow2.addToPath(switch5,tcu);
    flow2.setPriorityValue(5);
    flow2.setFixedPriority(true);   
    //flow2.setPacketSize(1500);
    flow2.setFlowSendingPeriodicity(2000);//when set it to 3ms,the result is not satisfied
    //flow2.setFlowMaximumLatency(1000);

    /*
     * GENERATING THE NETWORK
     */
    Network net = new Network(25);
    net.addDevice(ccu);
    net.addDevice(ccu2);
    net.addDevice(tcu);
    net.addDevice(bcu);

    net.addSwitch(switch0);
    net.addSwitch(switch1);
    net.addSwitch(switch2);
    net.addSwitch(switch3);
    net.addSwitch(switch4);
    net.addSwitch(switch5);

    net.addFlow(flow1);
    net.addFlow(flow2);

    ScheduleGenerator scheduleGenerator = new ScheduleGenerator(false);
    scheduleGenerator.generateSchedule(net);

}

}