Skip to content

dwave.system.temperatures.fast_effective_temperature does not accept dwave.samplers.sa.SimulatedAnnealingSampler #553

Description

@VolodyaCO

Description
I'm trying to get the effective temperature using the fast_effective_temperature function on a simulated annealing sampler, but I'm getting the following error:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In[44], [line 1](vscode-notebook-cell:?execution_count=44&line=1)
----> [1](vscode-notebook-cell:?execution_count=44&line=1) fast_effective_temperature(qpu_model.sampler, num_reads=1000, sampler_params={"beta_range" : [target_beta]*2})

File ~/miniforge3/envs/jt310/lib/python3.10/site-packages/dwave/system/temperatures.py:769, in fast_effective_temperature(sampler, num_reads, seed, h_range, sampler_params, optimize_method, num_bootstrap_samples)
    [766](https://file+.vscode-resource.vscode-cdn.net/env/lib/python3.10/site-packages/dwave/system/temperatures.py:766)         raise ValueError('h_range[1] exceeds programmable range')
    [768](https://file+.vscode-resource.vscode-cdn.net/env/lib/python3.10/site-packages/dwave/system/temperatures.py:768) prng = np.random.RandomState(seed)
--> [769](https://file+.vscode-resource.vscode-cdn.net/env/lib/python3.10/site-packages/dwave/system/temperatures.py:769) h_values = h_range[0] + (h_range[1]-h_range[0])*prng.rand(len(sampler.nodelist))
    [770](https://file+.vscode-resource.vscode-cdn.net/env/lib/python3.10/site-packages/dwave/system/temperatures.py:770) bqm = dimod.BinaryQuadraticModel.from_ising({var: h_values[idx] for idx,var in enumerate(sampler.nodelist)}, {})
    [772](https://file+.vscode-resource.vscode-cdn.net/env/lib/python3.10/site-packages/dwave/system/temperatures.py:772) #Create local sampling_params copy - default necessary additional fields:

AttributeError: 'SimulatedAnnealingSampler' object has no attribute 'nodelist'

To Reproduce

From the code it's clear that the SimulatedAnnealingSampler initialiser does not create a property/attribute called nodelist.

Expected behavior
If no structure is given to SimulatedAnnealingSampler when instiantiating it, i.e., no initialisation arguments are needed, I'd expect the temperature routine to fail. Maybe the temperature routine should not accept any dimod.Sampler as sampler.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions