# How to use Initial States in Qiskits QAOA?

The class QAOA from qiskit: https://qiskit.org/documentation/stubs/qiskit.aqua.algorithms.QAOA.html
has the parameter initial_state from the type InitialState. https://qiskit.org/documentation/apidoc/qiskit.aqua.components.initial_states.html#module-qiskit.aqua.components.initial_states

class QAOA(operator=None, optimizer=None, p=1, initial_state=None, mixer=None, initial_point=None, gradient=None, expectation=None, include_custom=False, max_evals_grouped=1, aux_operators=None, callback=None, quantum_instance=None)


But this doesnt work.

qaoa_mes = QAOA(H, p=p, optimizer=optimizer, initial_state = Zero, quantum_instance=Aer.get_backend("qasm_simulator"))
results = qaoa_mes.run()


Any Ideas?

You need to add the number of qubits for the initial state, this worked for me :

n_qubits = 2 #or whatever you want for your example
qaoa_mes = QAOA(H, p=p, optimizer=optimizer, initial_state = Zero(n_qubits), quantum_instance=Aer.get_backend("qasm_simulator"))


You can also pass a list for the initial point, for example :

qaoa_mes = QAOA(H, p=p, optimizer=optimizer, initial_state = [0.,0.], quantum_instance=Aer.get_backend("qasm_simulator"))


You can even pass a circuit for the initial point, there :

n_qubits = 2
initial = QuantumCircuit(n_qubits)
#add any gate you want in the circuit, for example :
initial.h(0)
initial.cx(0,1)

qaoa_mes = QAOA(H, p=p, optimizer=optimizer, initial_state = initial, quantum_instance=Aer.get_backend("qasm_simulator"))


If you need something else feel free to ask ! :)

• Good answer Lena, +1. I have not try it but it seems like you should be able to pass in quantum circuit for initial state, yes? For instance, if I want to pass in an initial state that uses all $2^n$ eigenbasis then it probably not a good idea to pass in as a state vector. I know the OP didn't ask for this but it would be great if you can add that details. :) Jan 21 at 10:46
• Indeed @KAJ226, thanks for pointing that out, it is possible to put in a circuit, I will add that. Thanks ! :)
– Lena
Jan 21 at 10:55
• @Lena Thank you so much! Jan 22 at 12:19