GithubHelp home page GithubHelp logo

markdown-linear-programming-r's Introduction

Linear Programming for Soda company


linear-regression

import library

library(lpSolve)

Objective Function

  • Max(13X1 + 23X2 + 30X3)

Subject to (Constraints)

  • 5X1 + 15X2 + 4X3 <= 480 (CO2)
  • 4X1 + 4X2 + 10X3 <= 160 (Water)
  • 35X1 + 20X2 + 15X3 <= 1190 (Flavor)
  • 5X1 + 10X2 + 20X3 <= 200 (number of worker * work hours * 5 days)
  • X1, X2, X3 >= 0 (We don't want a negative amount of batches)

create Objective coeffation

obj_coeff <- c(13,23,30)

constraints matrix

constraints <- matrix(
  c(
    5,15,4,
    4,4,10,
    35,20,15,
    5,10,20
  ), nrow =4, byrow= TRUE
)

rename column and row names

colnames(constraints) = c("Strwaberry" , "Orange" , "Grape")
rownames(constraints) = c("CO2" , "Water" , "Flavor" , "Production Time")
View(constraints)

create direction vector

direction_c <- c("<=","<=","<=","<=") 

create resources vectore

resources <- c(480,160,1190,200) # 200 = number of employee * work hours * work day

create linear programming object

solve_lp <- lp(
  "max", # find max result
  obj_coeff,
  constraints,
  direction_c,
  resources
)
solve_lp$objval # Objective value
solve_lp$solution # solution 

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.