LeapHybridSampler multiple samples

Hi everyone,

I am using LeapHybridSampler() to solve an optimization problem: I look for the solutions that minimize a given Ising Hamiltonian and I would like to collect some statistics on these solutions. 

I was wondering if it is possible to collect many samples without having to call many times the sample_ising function. Moreover, because I have to solve the same minimization problem many times, is it possible to reduce the total charge time (like reducing some loading time)?

Best regards,

Cristian

0

Comments

1 comment
  • Hi Cristian,

    Thank you for reaching out.  The problem upload time is not charged, however, it's possible to bypass the problem upload. Please look at the following example: 

    # This uses the underlying dwave-cloud-client infrastructure to bypass 
    # the problem upload. 
    
    import dimod 
    from dwave.system import LeapHybridSampler 
    
    num_submissions = 5 
    time_limit = 5 
    
    bqm = dimod.BQM({0: 362781.0}, {}, 0.0, 'BINARY') 
    
    sampler = LeapHybridSampler() 
    
    # upload the problem and get the resulting id from the returned Future 
    problem_id = sampler.solver.upload_problem(bqm.to_file()).result() 
    
    # submit the id multiple times with the same timelimit 
    samplesets = [] 
    for _ in range(num_submissions): 
        future = sampler.solver.sample_bqm(problem_id, time_limit=time_limit) 
        samplesets.append(future.sampleset)  # nonblocking 
    
    # combine all of the returned samplesets into one (blocking) 
    combined_sampleset = dimod.concatenate(samplesets) 
    
    # get the best feasible 
    best_sampleset = combined_sampleset.lowest() 
    
    print(best_sampleset)

     
    Please let us know if you have any questions. 

    Best Regards,
    Tanjid

     

    0
    Comment actions Permalink

Please sign in to leave a comment.

Didn't find what you were looking for?

New post