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