Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 205399

Minimising objective function problem using lpsolve in R

$
0
0

I'm tackling a simple linear optimisation problem. I have a bunch of crops with have their associated land requirements per tonne and their water footprints per tonne. I want to know how many tonnes of each crop I need in order to minimise the water footprint. For the first run, I'll have created a linear optimisation with only a land constraint. The land must equal 2958700. However, when I run my code my solution says "0" for all crops. Can someone help pls.

water_footprint<-c(2990.3, 5980.1, 31679.5,8802.3,16404.3)

crop_name<-c("banana","guava","mango","maize","rice")

crop_dataframe<-data.frame(crop_name,land,water_footprint)

const.mat<-land
const.dir<-c("=")
const.rhs<-2958700

library(lpSolve)
min_waterfootpint<-lp(direction = "min", water_footprint, const.mat, const.dir, const.rhs)$solution
paste(min_waterfootpint)

Viewing all articles
Browse latest Browse all 205399

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>