"The Devil Was Sick", a short story by Bruce Elliott, which was also an unaccepted answer to the old question Short story about psychologist analyzing demon; first published in The Magazine of Fantasy and Science Fiction, April 1951, available at the Internet Archive. You may have read it in one of these anthologies.
You may be conflating it with another story, as there is nothing about overcrowding or the military. It matches the rest or your description very well. Acleptos has been desperately trying to find an original thesis topic:
It began because the problem of finding a new subject for a thesis had become harder to solve than getting a degree. Acleptos had, by dint of a great deal of research, found three subjects which he thought the Machine might accept as being original.
He gulped a little as he presented his list to the all-seeing eye of the calculator. The list read, Activated sludge and what the ancients did about it. The downfall of democracy and why it came about. Devils, demons and demonology.
The Machine barely paused before it said: "In 4357 Jac Bard wrote the definitive work on activated sludge. Two hundred years later the last component in regard to the downfall of democracy was analyzed to the utmost by the historian Hermios." There was a tiny wait. Acleptos held his breath. If his last subject had been collected, annotated and written about in its entirety it might mean another twenty years work finding some more possible subjects. The Machine said: "There are two aspects of devils and demons that have not been presented to me so far. These are, were they real or hallucinatory, and if real, what were they. If hallucinatory, how brought about."
[. . . .]
Acleptos grinned to himself. Now he could go ahead. He would do his research, get his degree and then—then there would be no holding him back. He would be able to leave Earth and go on to his next step. He threw his head back and looked at the stars in the sky. That was the way it went. You were Earth-bound until you had done some original piece of research, but that finished you were allowed to migrate anywhere you wanted to go.
Acleptos invites his friend Ttom to watch him try to conjure a demon:
At midnight, with smiles still pulling at the corners of their mouths, Ttom sat outside the peculiar design that Acleptos had drawn on the floor. It was called a pentacle. Acleptos had placed a black candle in each of the angles. He had burned the foul smelling chemicals and he was now chanting in some gibberish that Ttom could not even make an attempt to understand.
It was amusing at first. As time dragged on both men became impatient. Nothing happened. Acleptos stopped chanting and said, "Well, I know the answer to the Machine's first question. Demons are hallucinatory and not real."
That was when it happened.