public List < SatConstraint > makeConstraints ( ) { List < SatConstraint > cstrs = new ArrayList <> ( ) ; //VM1 and VM2 must be running on distinct nodes cstrs . add ( new Spread ( new HashSet <> ( Arrays . asList ( vms . get ( 1 ) , vms . get ( 2 ) ) ) ) ) ; //VM0 must have at least 3 virtual CPU dedicated to it cstrs . add ( new Preserve ( vms . get ( 0 ) , "cpu" , 3 ) ) ; //N3 must be set offline cstrs . add ( new Offline ( nodes . get ( 3 ) ) ) ; //VM4 must be running, It asks for 3 cpu and 2 mem resources cstrs . add ( new Running ( vms . get ( 4 ) ) ) ; cstrs . add ( new Preserve ( vms . get ( 4 ) , "cpu" , 3 ) ) ; cstrs . add ( new Preserve ( vms . get ( 4 ) , "mem" , 2 ) ) ; //VM3 must be turned off, i.e. set back to the ready state cstrs . add ( new Ready ( vms . get ( 3 ) ) ) ; return cstrs ; }
Declare some constraints .