Thank you for your help!
I will put here exactly what I need so that at last there are no more attempts to guess.
I am using this packages, I am developing a mathematical model and for this I needed to create dataframes and a database, which is the csv.
using JuMP
using GLPK
using DataFrames
using CSV
model = Model ()
In the tables are the information that will be used to construct the constraints. This information is the code output response values
Toy = CSV.read #dataframe 2x2, column "TypeToy" type String and column "LC" Int64
Process = CSV.read #dataframe 3x2, column "TypeProcess" type String and column "TD" Float64
Toy_Process = CSV.read #dataframe 6x3, column "TypeToy" and "TypeProcess" are String and column "TP" Float64
At this stage I need the program to recognize the size of the table by pulling this information from the database
n = size (Toy, 1)
m = size (Process, 1)
@variable (model, Y [1: n], lower_bound = 0)
Here I take only the values that will be used in the constraints
L = Int64 (Toy.LC)
D = Float64. (Process.TD)
T = Float64. (Toy_Process.TP)
@objective (model, Max, sum (Y [i] * L [i] for i in 1: 2))
In order to calculate the matrix, I used the “transpose”
Yy = transpose (Y)
Finally, the loop will cycle through the tables in the database and print the response in matrix form
global a = Int64
global b = Int64
a = 1
b = n
for j in 1: m
@constraint (model, Yy [1: n]. * T [a: b]. <= D [j])
global a = a + n
global b = b + n
end
print (model)
Taking the information from the CSV file, which works like the database, the code should give me this answer:
Max 12 Y [1] + 60 Y [2]
Subject to
Y [1]> = 0.0
Y [2]> = 0.0
0.1 Y [1] + 0.4 Y [2] <= 15.0
0.1 Y [1] + 0.75 Y [2] <= 22.0
0.25 Y [1] + 0.5 Y [2] <= 36.0
But unfortunately I can not get the answer in matrix form