Hum a theme from the melody, then hum variations of the theme. Do this again, just before you go to bed.
Keep a portable tape recorder nearby. Your subconscious will continue to work and the recorder will be useful for capturing the results.
One caution - the subconscious does not work in a linear manner. It's very possible that you'll receive something which has nothing to do with your current project. Just be patient. If this project is important to you, you will receive things which you'll be able to use.
I discovered this process by accident while writing a first song - even tho I couldn't play at all, didn't know any theory, and of course had never even considered composition. If you give it a try for a couple of weeks, I think that you'll be pleased with the result.
The above is not at all intended to disparage studying or applying rules. It's just that they don't have anything to do with creating.
This exercise might help... If your piece is relatively tonal and you know some theory, try scratching out the melody with a 4-part chorale harmonization. Then take your alto and/or tenor line (or a combination of the two) and use it as a starting point for a countermelody. Add some variations and some movement, especially when the main melody is not moving as much. (You don't need to keep the chorale stuff, that was just an exercise to develop a harmonized line with good voice leading).