A method for solving a quadratic optimization problem, the method comprising: providing a two-dimensional spin-transfer torque magnetic random access memory, STT-MRAM, reconfigurable nanomagnet array , each nanomagnet in the nanomagnet array being implemented by a disk-shaped magnetic tunnel junction, MTJ, nanomagnet connected in series with a complementary metal-oxide semiconductor, CMOS, transistor adapted for disk-shaped MJT nanomagnet , deselection and read mechanism; associating each of a plurality of variables of a quadratic optimization problem with a nanomagnet of the nanomagnet array by identifying the plurality of variables of the quadratic optimization problem and selectively mapping or not mapping a nanomagnet of the nanomagnet array to each of the variables of the quadratic optimization problem, wherein the distances between the nanomagnets that have been mapped to the variables of the quadratic optimization problem are such that a magnetic coupling energy of the nanomagnets is proportional to an energy relationship between the plurality of variables in the quadratic optimization problem; driving the nanomagnets of the nanomagnet array to an excited state; allowing the nanomagnets of the nanomagnet array to enter a relaxed state after being driven to an excited state, wherein the nanomagnets magnetically couple with one another in the relaxed state to minimize the total magnetic coupling energy of the nanomagnet array; and sensing a magnetic coupling of the nanomagnets of the nanomagnet array by sensing a state of each of the plurality of nanomagnets of the nanomagnet array to identify one or more nanomagnets of the plurality of nanomagnets that are in a single domain state and mapping the single domain state nanomagnets back to the plurality of variables of the quadratic optimization problem to solve the quadratic optimization problem. providing a two-dimensional spin-transfer torque magnetic random access memory, STT-MRAM, reconfigurable nanomagnet array , each nanomagnet in the nanomagnet array being implemented by a disk-shaped magnetic tunnel junction, MTJ, nanomagnet connected in series with a complementary metal-oxide semiconductor, CMOS, transistor adapted for disk-shaped MJT nanomagnet , deselection and read mechanism; associating each of a plurality of variables of a quadratic optimization problem with a nanomagnet of the nanomagnet array by identifying the plurality of variables of the quadratic optimization problem and selectively mapping or not mapping a nanomagnet of the nanomagnet array to each of the variables of the quadratic optimization problem, wherein the distances between the nanomagnets that have been mapped to the variables of the quadratic optimization problem are such that a magnetic coupling energy of the nanomagnets is proportional to an energy relationship between the plurality of variables in the quadratic optimization problem; driving the nanomagnets of the nanomagnet array to an excited state; allowing the nanomagnets of the nanomagnet array to enter a relaxed state after being driven to an excited state, wherein the nanomagnets magnetically couple with one another in the relaxed state to minimize the total magnetic coupling energy of the nanomagnet array; and sensing a magnetic coupling of the nanomagnets of the nanomagnet array by sensing a state of each of the plurality of nanomagnets of the nanomagnet array to identify one or more nanomagnets of the plurality of nanomagnets that are in a single domain state and mapping the single domain state nanomagnets back to the plurality of variables of the quadratic optimization problem to solve the quadratic optimization problem. <EOS>