Example #1
0
   def polyfile_homotopy(self, Uid, msg):
      from phc_file import rm_exts, phc_start
      from os import path
      
      [poly_id, poly_id_start, poly_data] = msg.split('|')
      
      # Generate poly file
      file_id = "../users/%s/%s" %(Uid, poly_id)

      exts = ['cmd', 'sol','phc']
      rm_exts(file_id,exts)

      print "msg = %s"% msg
   
      # Generate start system file from phc file         
      file_id_start= "../users/%s/%s" %(Uid, poly_id_start)
      
      rm_exts(file_id_start, ['cmd'])
      
      if not path.isfile(file_id_start+".start"):
         phc_start(file_id_start)
      
      with open('%s.cmd'%file_id_start, 'w') as f:
         f.write("y\n%s.sol\n%s.start\n0\n0\n0\n0\n"%(file_id, file_id_start))
      f.close()
      
      return file_id, file_id_start
Example #2
0
    def polyfile_homotopy(self, Uid, msg):
        from phc_file import rm_exts, phc_start
        from os import path

        [poly_id, poly_id_start, poly_data] = msg.split('|')

        # Generate poly file
        file_id = "../users/%s/%s" % (Uid, poly_id)

        exts = ['cmd', 'sol', 'phc']
        rm_exts(file_id, exts)

        print "msg = %s" % msg

        # Generate start system file from phc file
        file_id_start = "../users/%s/%s" % (Uid, poly_id_start)

        rm_exts(file_id_start, ['cmd'])

        if not path.isfile(file_id_start + ".start"):
            phc_start(file_id_start)

        with open('%s.cmd' % file_id_start, 'w') as f:
            f.write("y\n%s.sol\n%s.start\n0\n0\n0\n0\n" %
                    (file_id, file_id_start))
        f.close()

        return file_id, file_id_start
Example #3
0
    def polyclient_newhom(self):
        # check whether polynomial system is efficient
        rm_all_exts(self.file_id)

        newpoly = [self.client_opt, self.client_id, self.client_msg]
        self.client_msg = self.client_msg.split('|')

        if len(self.client_msg) == 1:
            file_id_start = get_file_id(self.client_id, self.client_msg[0])
            if not path.isfile(file_id_start + ".start"):
                phc_start(file_id_start)
            self.msg = 'homotopy start system generated'

        else:
            with open('%s.poly' % self.file_id, 'w') as f:
                f.write(self.client_msg[2])
                f.close()

            # distribute job to small or large queue
            worker_ind, deg = self.job_distributor()

            if worker_ind == 0:
                phcdb.delpoly(self.client_id, self.poly_id)
                with open('%s.err' % self.file_id, 'r') as f:
                    self.msg = f.read() + "received"
            else:
                print "**********%s" % deg
                rm_exts(self.file_id, 'err')

                with open('%s.sta' % self.file_id, 'w') as f:
                    f.write('submitted')
                    f.close()

            queue_local.put(newpoly)

            self.msg = 'homotopy received'

            # update userstatus to computing
            phcdb.delpoly(self.client_id, self.poly_id)
            phcdb.newpoly(self.client_id, self.poly_id, deg,
                          path.getctime('%s.poly' % self.file_id))
Example #4
0
    def polyclient_newhom(self):
        # check whether polynomial system is efficient
        rm_all_exts(self.file_id)

        newpoly = [self.client_opt, self.client_id, self.client_msg]
        self.client_msg = self.client_msg.split("|")

        if len(self.client_msg) == 1:
            file_id_start = get_file_id(self.client_id, self.client_msg[0])
            if not path.isfile(file_id_start + ".start"):
                phc_start(file_id_start)
            self.msg = "homotopy start system generated"

        else:
            with open("%s.poly" % self.file_id, "w") as f:
                f.write(self.client_msg[2])
                f.close()

            # distribute job to small or large queue
            worker_ind, deg = self.job_distributor()

            if worker_ind == 0:
                phcdb.delpoly(self.client_id, self.poly_id)
                with open("%s.err" % self.file_id, "r") as f:
                    self.msg = f.read() + "received"
            else:
                print "**********%s" % deg
                rm_exts(self.file_id, "err")

                with open("%s.sta" % self.file_id, "w") as f:
                    f.write("submitted")
                    f.close()

            queue_local.put(newpoly)

            self.msg = "homotopy received"

            # update userstatus to computing
            phcdb.delpoly(self.client_id, self.poly_id)
            phcdb.newpoly(self.client_id, self.poly_id, deg, path.getctime("%s.poly" % self.file_id))