2

I am trying to solve a system of linear equations where the variables take binary values

import numpy as np
import numpy.linalg as LA
import scipy.optimize as optimize

A = np.array([[1/5, 1/2, 1/3], [1/4, 1/5, 1/6], [1/6, 2/9, 3/10]])
b = np.array([1, 1, 1])
x = LA.solve(A, b)

My matrix A has around 400 columns and 3000 rows. Just posted few columns due to space constraint. My output vector is always 1. All my variables can take only binary values - 0 or 1

4
  • I cant get your code to work, I get the following error LinAlgError: Singular matrix Commented Jul 25, 2018 at 13:32
  • Maybe this question could be usefull, about Mixed Integer Linear Programming. Another keyword seem to be 'system of boolean equations' instead of binary equations (for example) Commented Jul 25, 2018 at 14:16
  • Thankyou @xdze2, that helped. However I am stuck at formulating optimizing the squares function using Pulp Commented Jul 26, 2018 at 10:31
  • Are you even sure your linear system has at least one solution over the reals? This looks like a least-squares problem to me. Commented Jul 27, 2018 at 20:37

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.