2 # Copyright (C) 2006-2021 CEA/DEN, EDF R&D
4 # This library is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU Lesser General Public
6 # License as published by the Free Software Foundation; either
7 # version 2.1 of the License, or (at your option) any later version.
9 # This library is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 # Lesser General Public License for more details.
14 # You should have received a copy of the GNU Lesser General Public
15 # License along with this library; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
24 class TestPlayGround0(unittest.TestCase):
26 pg=pilot.PlayGround([("a0",28),("a1",28),("a2",28)])
27 pd=pilot.ContigPartDefinition(pg,0,3*28)
28 cw=pilot.ComplexWeight(0.,1.,4)
29 res=pg.partition([(pd,cw),(pd,cw)],[4,4])
31 assert(isinstance(res[0],pilot.ContigPartDefinition))
32 assert(isinstance(res[1],pilot.ContigPartDefinition))
33 assert(res[0].getStart()==0 and res[0].getStop()==44)
34 assert(res[1].getStart()==44 and res[1].getStop()==84)
35 assert(sum([elt.getNumberOfCoresConsumed() for elt in res])==pg.getNumberOfCoresAvailable())
36 pd2=pilot.AllPartDefinition(pg)
37 assert(pd2.getNumberOfCoresConsumed()==84)
38 res=pg.partition([(pd2,cw),(pd2,cw),(pd2,cw)],[4,4,4])
40 assert(isinstance(res[0],pilot.ContigPartDefinition))
41 assert(isinstance(res[1],pilot.ContigPartDefinition))
42 assert(isinstance(res[2],pilot.ContigPartDefinition))
43 assert(res[0].getStart()==0 and res[0].getStop()==28)
44 assert(res[1].getStart()==28 and res[1].getStop()==56)
45 assert(res[2].getStart()==56 and res[2].getStop()==84)
47 pg.setData([("a0",2),("a1",8),("a2",8)])
48 cw2=pilot.ComplexWeight(0.,4.,1)
49 res=pg.partition([(pilot.AllPartDefinition(pg),cw),(pilot.AllPartDefinition(pg),cw)],[4,1])
51 assert(isinstance(res[0],pilot.ContigPartDefinition))
52 assert(isinstance(res[1],pilot.NonContigPartDefinition))
53 assert(res[0].getStart()==2 and res[0].getStop()==10)
54 assert(res[1].getIDs()==(0,1,10,11,12,13,14,15,16,17))
58 """ test focused on complicated cut due to lack of cores"""
59 pg=pilot.PlayGround([("a0",13)])
60 pd=pilot.ContigPartDefinition(pg,0,13)
61 cw=pilot.ComplexWeight(0.,1.,4)
62 cw2=pilot.ComplexWeight(0.,2.,4)
63 res=pg.partition([(pd,cw),(pd,cw2)],[4,4])
65 assert(isinstance(res[0],pilot.ContigPartDefinition) and isinstance(res[1],pilot.ContigPartDefinition))
66 assert(res[0].getStart()==0 and res[0].getStop()==4)
67 assert(res[1].getStart()==4 and res[1].getStop()==12)# 1 core lost
69 pg=pilot.PlayGround([("a0",2),("a1",27)])
70 cw3=pilot.ComplexWeight(0.,20,1)
71 cw4=pilot.ComplexWeight(0.,1.,8)
72 pd=pilot.ContigPartDefinition(pg,0,29)
73 res=pg.partition([(pd,cw3),(pd,cw4)],[4,8])
75 assert(isinstance(res[0],pilot.ContigPartDefinition) and isinstance(res[1],pilot.ContigPartDefinition))
76 assert(res[0].getStart()==10 and res[0].getStop()==26)
77 assert(res[1].getStart()==2 and res[1].getStop()==10)# 5 cores lost
82 if __name__ == '__main__':