Skip to main content

  | मौसम…

411 समाचार
Public archive edition · Attributed source reporting with original dates · AI drafts are excluded

411 REFERENCE · Wikibooks

Scientific Calculations with Julia/Profit Maximization

Reference material by Wikibooks contributors. This retains its source identity and is not 411 news reporting.

Scientific Calculations with Julia Profit Maximization Personal Budget Optimization Cost Minimization Profit maximization is a classic example of linear programming, which in its standard form is expressed in three parts: A linear function to be maximized: Constraint problem of the following form: Non-negative variables The problem is usually expressed in matrix form as follows: Example calculation with Julia A company produces tables and cabinets that it intends to sell at prices of €400 and €200, respectively. Producing them requires 6 units of wood, 2 worker hours, and 100 minutes of machine time for the tables, and 10 units of wood, 4 worker hours, and 40 minutes of machine time for the cabinets. The company has 4,000 units of wood available daily, 250 workers working 8 hours a day, or 2,000 worker hours, and 50 machines operating 16 hours a day, or 48,000 machine hours. First, you need to install the JuMP and HiGHS packages. From the REPL, type: using Pkg Pkg.add("JuMP") Pkg.add("HiGHS") From Jupyter, in two code cells, type: ] add HiGHS ] add JuMP And then click Run. Then run the code to create the linear programming model: using JuMP using HiGHS model = Model(HiGHS.Optimizer) @variable(model, x >= 0) @variable(model, y >= 0) @objective(model, Max, 200y + 400x) @constraint(model, c1, 10y + 6x <= 4000) @constraint(model, c2, 4y + 2x <= 2000) @constraint(model, c3, 40y + 100x <= 48000) print(model) optimize!(model) max Subject to 200𝑦+400𝑥 6𝑥+10𝑦≤4000 2𝑥+4𝑦≤2000 100𝑥+40𝑦≤48000 𝑥≥0 𝑦≥0 Running HiGHS 1.5.3 [date: 1970-01-01, git hash: 45a127b78] Copyright (c) 2023 HiGHS under MIT licence terms Presolving model 3 rows, 2 cols, 6 nonzeros 3 rows, 2 cols, 6 nonzeros Presolve : Reductions: rows 3(-0); columns 2(-0); elements 6(-0) - Not reduced Problem not reduced by presolve: solving the LP Using EKK dual simplex solver - serial Iteration Objective Infeasibilities num(sum) 0 -3.7499962007e+01 Ph1: 3(5.6875); Du: 2(37.5) 0s 2 1.9789473684e+05 Pr: 0(0) 0s Model status : Optimal Simplex iterations: 2 Objective value : 1.9789473684e+05 HiGHS run time : 0.03 println("termination_status = ",termination_status(model)) println("primal_status = ",primal_status(model)) println("dual_status = ",dual_status(model)) println("objective_value = ",objective_value(model)) println("x = ",value(x)) println("y = ",value(y)) println("c1 = ",shadow_price(c1)) println("c2 = ",shadow_price(c2)) println("c3 = ",shadow_price(c3)) termination_status = OPTIMAL primal_status = FEASIBLE_POINT dual_status = FEASIBLE_POINT objective_value = 197894.73684210528 x = 421.05263157894734 y = 147.36842105263167 c1 = 5.2631578947368425 c2 = -0.0 c3 = 3.6842105263157894 That is, the company earns a maximum daily profit of €197,894 by producing 147 cabinets and 421 tables.