Exemplo n.º 1
0
    def post(self):
        calc_mode = self.request.get('calc_mode')
        num = self.request.get('num')
        
        cocomo = None
        if (calc_mode in ('kdsi','effort')) and re.match(r'^[0-9]+[\.]{0,1}[0-9]*$',num):
            cocomo = Cocomo(calc_mode,kdsi=float(num),effort=float(num))
            #logging.warn(json.write(cocomo.to_dict()))
            return self.response.out.write(json.write(cocomo.to_dict()))

        return self.response.out.write(json.write({'error':u'入力項目に誤りがあります.'}))
    def post(self):
        calc_mode = self.request.get('calc_mode')
        num = self.request.get('num')
        
        cocomo = None
        if (calc_mode in ('kdsi','effort')) and re.match(r'^[0-9]+[\.]{0,1}[0-9]*$',num):
            cocomo = Cocomo(calc_mode,kdsi=float(num),effort=float(num))
            #logging.warn(json.write(cocomo.to_dict()))
            return self.response.out.write(json.write(cocomo.to_dict()))

        return self.response.out.write(json.write({'error':u'入力項目に誤りがあります.'}))
Exemplo n.º 3
0
 def __init__(self):
   Problem.__init__(self)
   self.name = XOMO.__name__
   self.cocomo = Cocomo()
   self.names, lows, ups = [],[],[]
   for one in self.cocomo.about():
     self.names.append(one.txt)
     lows.append(one.min)
     ups.append(one.max)
   self.decisions = [Decision(self.names[i], lows[i], ups[i]) for i in range(len(self.names))]
   self.objectives = [Objective("effort", to_minimize=True, low = 0, high=43000),
                      Objective("months", to_minimize=True, low = 0, high=120),
                      Objective("defects", to_minimize=True, low = 0, high=1180000),
                      Objective("risk", to_minimize=True, low = 0, high=17)]
Exemplo n.º 4
0
def all():
  n=1024
  for k in cocoeg.better:
    sys.stderr.write("%s\n" % k)
    c= lambda: Cocomo( 
                 [dict(kloc=F(2,100)),
                 cocoeg.better[k] ])
    print(k, perc([c().effort() for _ in range(n)]),
             perc([c().risk() for _ in range(n)]))
Exemplo n.º 5
0
class XOMO(Problem):
  """
  XOMO
  """
  def __init__(self):
    Problem.__init__(self)
    self.name = XOMO.__name__
    self.cocomo = Cocomo()
    self.names, lows, ups = [],[],[]
    for one in self.cocomo.about():
      self.names.append(one.txt)
      lows.append(one.min)
      ups.append(one.max)
    self.decisions = [Decision(self.names[i], lows[i], ups[i]) for i in range(len(self.names))]
    self.objectives = [Objective("effort", to_minimize=True, low = 0, high=43000),
                       Objective("months", to_minimize=True, low = 0, high=120),
                       Objective("defects", to_minimize=True, low = 0, high=1180000),
                       Objective("risk", to_minimize=True, low = 0, high=17)]

  @staticmethod
  def get_extremes():
    xomo = XOMO()
    mins = [sys.maxint]*4
    maxs = [-sys.maxint]*4
    for j in range(100000):
      print(j)
      x = xomo.cocomo.xys()
      for i, one in enumerate(x):
        if one < mins[i]: mins[i] = one
        if one > maxs[i]: maxs[i] = one
    print(mins)
    print(maxs)

  def evaluate(self, decisions):
    x = {}
    for n, d in zip(self.names, decisions): x[n] = int(round(d))
    return self.cocomo.xys(x)
Exemplo n.º 6
0
def one():
  n=256
  for k1 in cocoeg.projects:
    print("#")
    e = {}
    r = {}
    for k2 in cocoeg.better:
      c= lambda: Cocomo( [cocoeg.better[k2] ,
                          cocoeg.projects[k1]])
      e[k2] = [c().effort() for _ in range(n)]
      r[k2] = [c().risk()   for _ in range(n)]
    print("\n" + k1, "effort")
    group(e, width= 30, show="%6.0f",
             chops= [.1, .3,  .5, .7,  .9])
    print("\n" + k2, "risk")
    group(r, width= 30, show="%6.0f",
             chops= [.1, .3,  .5, .7,  .9])
Exemplo n.º 7
0
      time= dict(acap=sw46, pcap=sw46, tool=sw26), #10
      tool= dict(acap=nw,   pcap=nw,   pmat=nw)) # 6
    

class Risk
from cocomo import Cocomo,F,I
import sys,cocoeg
from lib import perc
from rx import group

def perc(a,p=[.25,.5,.75]):
  ls = sprted(a)
  return [ l[int(p0 * len(a))] for p0 in p ]

c= lambda: Cocomo(
       [dict(goal=F(1), kloc=F(2,100), 
             acap=I(1), ltex=I(5), sced=I(5))])


# d.effort(), d.risk())
#print(perc([c().effort() for _ in range(256)]),
 #     perc([c().risk() for _ in range(256)]))

def all():
  n=1024
  for k in cocoeg.better:
    sys.stderr.write("%s\n" % k)
    c= lambda: Cocomo( 
                 [dict(kloc=F(2,100)),
                 cocoeg.better[k] ])
    print(k, perc([c().effort() for _ in range(n)]),
Exemplo n.º 8
0
    def post(self):
        calc_mode = self.request.get('calc_mode')
        num = self.request.get('num')

        cocomo = None
        if (calc_mode in ('kdsi','effort')) and re.match(r'^[0-9]+[\.]{0,1}[0-9]*$',num):
            cocomo = Cocomo(calc_mode,kdsi=float(num),effort=float(num))

            self.response.headers.add_header("Content-Disposition", 'attachment; filename="cocomo.xls"' )
            
            #
            font_title = xlwt.Font()
            font_title.bold = True 
            style_title = xlwt.XFStyle()
            style_title.font = font_title

            #
            font_num = xlwt.Font()
            font_num.colour_index = 4
            style_num = xlwt.XFStyle()
            style_num.num_format_str = '0.00'
            style_num.font = font_num
            
            #
            font_link = xlwt.Font()
            font_link.colour_index = 4
            font_link.underline = xlwt.Font.UNDERLINE_DOUBLE
            style_link = xlwt.XFStyle()
            style_link.font = font_link
            #
            
            wb = xlwt.Workbook(encoding='utf-8')
            ws = wb.add_sheet(u'COCOMO')
            
            #
            base_col = 1
            r = 1
            
            col_w = (0x0a00,0x1e00,0x0a00,0x0a00,0x2800,0x0a00,0x0a00,)
            for i, v in enumerate(col_w):
                ws.col(i).width = v
                
            #
            ws.write(r, base_col, u'COCOMO による工数計算', style_title)
            
            #
            n = "HYPERLINK"
            ws.write(r, base_col+2, xlwt.Formula(n + '("http://typea-service.appspot.com/cocomo";"COCOMO")'), style_link)
            
            #
            r += 2
            ws.write(r, base_col, u'COCOMO計算式', style_title)
            dat = (
                (u'プログラムサイズ(KLOC)', cocomo.kdsi),  
                (u'工数(PM)',          cocomo.effort),
                (u'開発期間(M)',        cocomo.tdev),  
                (u'開発要員(P)',        cocomo.fsp),   
                (u'生産性(KLOC/PM)',    cocomo.prod),  
            )
            for d in dat:
                r += 1
                ws.write(r, base_col,     d[0])
                ws.write(r, base_col + 1, d[1], style_num)    

            #
            r += 2
            ws.write(r, base_col, u'工数の局面への分布', style_title)
            dat = (
                (u'計画と要件定義',        cocomo.plan_requirements),
                (u'製品設計',             cocomo.product_design),
                (u'詳細設計',             cocomo.detailed_design),
                (u'プログラミングと単体テスト',  cocomo.code_unit_test),
                (u'統合とテスト',           cocomo.integration_test),
                (u'合計',                cocomo.total),
            )
            for d in dat:
                r += 1
                ws.write(r, base_col,     d[0])
                ws.write(r, base_col + 1, d[1], style_num)    
            #
            r += 2
            ws.write(r, base_col, u'活動の局面ごとの分布', style_title)
            sub_title = ( u'', u'', u'', u'プログラミング', u'', u'' )
            r += 1
            c = base_col
            for t in sub_title:
                ws.write(r, c, t)
                c += 1 
            #    
            sub_title = ( u'局面', u'計画と要件定義', u'製品設計', u'詳細設計-プログラミングと単体テスト', u'統合とテスト', u'合計' )
            r += 1
            c = base_col
            for t in sub_title:
                ws.write(r, c, t)
                c += 1 
            #
            sub_title = (
                u'要件分析',
                u'製品設計',
                u'プログラミング',
                u'テスト計画',
                u'検証',
                u'プロジェクト管理',
                u'構成管理と品質保障',
                u'文書化',
                u'合計',
            )
            r2 = r
            for t in sub_title:
                r2 += 1
                ws.write(r2, base_col, t)
            
            #
            dat = (
                cocomo.phase_plan_requirements, 
                cocomo.phase_product_design,    
                cocomo.phase_programming,       
                cocomo.phase_integration_test,  
                cocomo.phase_total,             
            )
            c = base_col
            for d in dat:
                r3 = r
                c += 1
                for rd in d:
                    r3 += 1
                    ws.write(r3, c,  rd, style_num)
            
            wb.save(self.response.out)

            return None

        return self.response.out.write(json.write({'error':u'入力項目に誤りがあります.'}))