Answer the question
In order to leave comments, you need to log in
Linear programming problem. How to add a constraint to a model?
Hello.
It is necessary to solve the following problem. It so happened that you need to do this in javascript :(
The system has the form CX = 0, where C is an n by n matrix, and X is a vector to be found. In addition, one more restriction is introduced - the inequality x1 + x2 + .. + xn <= 1. Objective function: F = x1+x2+...xn -> max.
To solve the problem, I found such a solution . I tried to make a model. It is not clear how to add the constraint x1+x2+..+xn <= 1. Unfortunately, there are few examples and they are all simple.
{
"optimize":{
"1s":"max",
"2s":"max",
"3s":"max"
},
"constraints":{
"1":{"min":1},
"2":{"min":1},
"3":{"min":1}
},
"variables":{
"1s":{"1":0,"2":-1,"3":0.2844},
"2s":{"1":0.1653,"2":0.1873,"3":-1},
"3s":{"1":0.0551,"2":0.115,"3":0.0987}
}
}
Answer the question
In order to leave comments, you need to log in
The solution of the system C·X = B is the vector X = C -1 ·B.
In your case, B = 0, which means that for ΔC ≠ 0 we get X = 0 (Cramer's rule), and for ΔC = 0, the system has an infinite number of solutions and we must first transform it using the Gauss method, highlighting the dependent variables.
2·x + 3·y - z = 0
4·x + 6·y -2·z = 0
3·x - y + 2·z = 0
x + 3/2·y - 1/2·z = 0
0 = 0
- 11/2·y + 7/2·z = 0
y = 7/11·z
x = -5/11·z
x + y + z = -5/11·z + 7/11·z + z = 13/11·z <= 1
x + y + z = 13/11·z -> max
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question