Error message when trying to solve sub-problems.

Hi,

Using the hybrid library, I do not have any issue when trying to solve the problem using tabu search.

workflow = hybrid.Loop(hybrid.TabuProblemSampler(), max_iter=None, max_time=3600,convergence=3, terminate=energy_reached)

response = workflow.run(hybrid.State.from_problem(model)).result()

 

However, when I tried to decompose a problem and use tabu to solve the sub problem.

workflow = hybrid.Loop(hybrid.EnergyImpactDecomposer(size=30, rolling=True, rolling_history=0.15) | hybrid.TabuSubproblemSampler() | hybrid.SplatComposer(), max_iter=None, max_time=3600,convergence=3, terminate=energy_reached)
response = workflow.run(hybrid.State.from_problem(model)).result()

I encounter the following error:

File "<ipython-input-15-159105353b21>", line 1, in <module>
runfile('C:/Users/User/Desktop/dwave/DSM_DW.py', wdir='C:/Users/User/Desktop/dwave')

File "C:\Users\User\Anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 827, in runfile
execfile(filename, namespace)

File "C:\Users\User\Anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 110, in execfile
exec(compile(f.read(), filename, 'exec'), namespace)

File "C:/Users/User/Desktop/dwave/DSM_DW.py", line 132, in <module>
response = workflow.run(hybrid.State.from_problem(model)).result()

File "C:\Users\User\Anaconda3\lib\concurrent\futures\_base.py", line 432, in result
return self.__get_result()

File "C:\Users\User\Anaconda3\lib\concurrent\futures\_base.py", line 384, in __get_result
raise self._exception

File "C:\Users\User\Anaconda3\lib\concurrent\futures\thread.py", line 57, in run
result = self.fn(*self.args, **self.kwargs)

File "C:\Users\User\Anaconda3\lib\site-packages\hybrid\core.py", line 394, in dispatch
new_state = self.next(state, **kwargs)

File "C:\Users\User\Anaconda3\lib\site-packages\hybrid\core.py", line 506, in next
result = orig_next(self, state, **runopts)

File "C:\Users\User\Anaconda3\lib\site-packages\hybrid\flow.py", line 795, in next
output_state = self.runnable.run(input_state, **runopts).result()

File "C:\Users\User\Anaconda3\lib\concurrent\futures\_base.py", line 425, in result
return self.__get_result()

File "C:\Users\User\Anaconda3\lib\concurrent\futures\_base.py", line 384, in __get_result
raise self._exception

File "C:\Users\User\Anaconda3\lib\site-packages\hybrid\concurrency.py", line 55, in submit
return Present(result=fn(*args, **kwargs))

File "C:\Users\User\Anaconda3\lib\site-packages\hybrid\core.py", line 394, in dispatch
new_state = self.next(state, **kwargs)

File "C:\Users\User\Anaconda3\lib\site-packages\hybrid\flow.py", line 130, in next
return state.result()

File "C:\Users\User\Anaconda3\lib\concurrent\futures\_base.py", line 425, in result
return self.__get_result()

File "C:\Users\User\Anaconda3\lib\concurrent\futures\_base.py", line 384, in __get_result
raise self._exception

File "C:\Users\User\Anaconda3\lib\site-packages\hybrid\concurrency.py", line 55, in submit
return Present(result=fn(*args, **kwargs))

File "C:\Users\User\Anaconda3\lib\site-packages\hybrid\core.py", line 384, in dispatch
return self.error(exc)

File "C:\Users\User\Anaconda3\lib\site-packages\hybrid\core.py", line 356, in error
raise exc

File "C:\Users\User\Anaconda3\lib\site-packages\hybrid\core.py", line 381, in dispatch
state = future.result()

File "C:\Users\User\Anaconda3\lib\concurrent\futures\_base.py", line 425, in result
return self.__get_result()

File "C:\Users\User\Anaconda3\lib\concurrent\futures\_base.py", line 384, in __get_result
raise self._exception

File "C:\Users\User\Anaconda3\lib\site-packages\hybrid\concurrency.py", line 55, in submit
return Present(result=fn(*args, **kwargs))

File "C:\Users\User\Anaconda3\lib\site-packages\hybrid\core.py", line 394, in dispatch
new_state = self.next(state, **kwargs)

File "C:\Users\User\Anaconda3\lib\site-packages\hybrid\samplers.py", line 381, in next
tenure=self.tenure, timeout=self.timeout, num_reads=self.num_reads)

File "C:\Users\User\Anaconda3\lib\site-packages\tabu\sampler.py", line 170, in sample
raise ValueError("mismatch between variables in 'initial_states' and 'bqm'")

ValueError: mismatch between variables in 'initial_states' and 'bqm'

0

Comments

1 comment
  • Hello,

    The Error is caused by the existence of the subsamples parameter being passed to the TabuSubproblemSampler on the second iteration of the loop.

    In this workflow the Decomposer selects a subproblem from the whole problem.
    This subproblem is likely different than the one selected on the first iteration through the loop.
    This means that the points in the subproblem from iteration to iteration changes, so they don't match the subsamples present in their current iteration.

    To fix this problem we can remove the subsamples from the previous iteration of the loop like this:

    workflow = hybrid.Loop(hybrid.EnergyImpactDecomposer(size=30, rolling=True, rolling_history=0.15) | hybrid.Const(subsamples=None) | hybrid.TabuSubproblemSampler() | hybrid.SplatComposer(), max_iter=None, max_time=3600,convergence=3, terminate=energy_reached)

    The subsamples are being added to the overall whole set of samples via the SplatComposer, so excluding these subsamples using Const does not exclude them from the TabuSubproblemSampler, since they are in the samples passed back to the Decomposer at the beginning of the subsequent iteration of the loop.

    There are valid ways to use the subsamples on subsequent iterations of TabuSubproblemSampler, but with this kind of Decomposer they are causing an issue.

    I hope this helps! Please let us know if you need clarification or have more questions.

    Best regards!

    0
    Comment actions Permalink

Please sign in to leave a comment.

Didn't find what you were looking for?

New post