コード例 #1
0
ファイル: int.py プロジェクト: mtanneau/cblib-base
def getval(prob, cnam=None, cdim=None):
    if (cnam is None and cdim is None) or (prob.intvarnum == 0):
        return (prob.intvarnum)

    else:
        cnam = __common__.parse_cnam(cnam)
        cdim = __common__.parse_cdim(cdim)

        prob.intvar.sort()
        numint = 0
        curint = 0
        j = -1
        for k in range(prob.varstacknum):
            if cnam(prob.varstackdomain[k]) and cdim(prob.varstackdim[k]):
                for km in range(prob.varstackdim[k]):
                    j += 1

                    while j > prob.intvar[curint]:
                        curint += 1
                        if curint >= prob.intvarnum:
                            return (numint)

                    if j == prob.intvar[curint]:
                        numint += 1
            else:
                j += prob.varstackdim[k]

        return (numint)
コード例 #2
0
ファイル: binary.py プロジェクト: mtanneau/cblib-base
def getval(prob, cnam=None, cdim=None):
  if prob.intvarnum == 0:
    return( 0 )
  
  elif cnam is None and cdim is None:
    return( sum([1 for j in prob.intvar if -0.5 <= prob.blx[j] and prob.bux[j] <= 1.5]) )
  
  else:
    cnam = __common__.parse_cnam(cnam)
    cdim = __common__.parse_cdim(cdim)
    
    prob.intvar.sort()
    numint = 0
    curint = 0
    j = -1
    for k in range(prob.varstacknum):
      if cnam(prob.varstackdomain[k]) and cdim(prob.varstackdim[k]):
        for km in range(prob.varstackdim[k]):
          j += 1
  
          while j > prob.intvar[curint]:
            curint += 1
            if curint >= prob.intvarnum:
              return( numint )
  
          if j == prob.intvar[curint] and -0.5 <= prob.blx[j] and prob.bux[j] <= 1.5:
            numint += 1
      else:
        j += prob.varstackdim[k]
  
    return( numint )
コード例 #3
0
def getval(prob, cnam=None, cdim=None):
    if (cnam is None and cdim is None) or (prob.mapstacknum == 0):
        return (prob.mapstacknum)

    else:
        cnam = __common__.parse_cnam(cnam)
        cdim = __common__.parse_cdim(cdim)
        return sum([
            1 for k in range(prob.mapstacknum)
            if cnam(prob.mapstackdomain[k]) and cdim(prob.mapstackdim[k])
        ])
コード例 #4
0
def getval(prob, cdim=None):
    if (cdim is None) or (prob.psdmapnum == 0):
        return (prob.psdmapnum)
    else:
        cdim = __common__.parse_cdim(cdim)
        return (sum([1 for n in prob.psdmapdim if cdim(n)]))
コード例 #5
0
def getval(prob, cdim=None):
    if prob.psdvarnum == 0:
        return (0)
    else:
        cdim = __common__.parse_cdim(cdim)
        return (sum([n * (n + 1) / 2 for n in prob.psdvardim if cdim(n)]))