34 lines
979 B
Python
34 lines
979 B
Python
# coding=utf-8
|
|
|
|
from rsome import dro
|
|
# from rsome import grb_solver as grb
|
|
from rsome import eco_solver as eco
|
|
import rsome as rso
|
|
import numpy as np
|
|
|
|
|
|
def simple_linear():
|
|
model = dro.Model('LP model') # create a Model object
|
|
x = model.dvar() # define a decision variable x
|
|
y = model.dvar() # define a decision variable y
|
|
|
|
model.max(3*x + 4*y) # maximize the objective function
|
|
model.st(2.5*x + y <= 20) # specify the 1st constraints
|
|
model.st(5*x + 3*y <= 30) # specify the 2nd constraints
|
|
model.st(x + 2*y <= 16) # specify the 3rd constraints
|
|
model.st(abs(y) <= 2) # specify the 4th constraints
|
|
|
|
model.solve() # solve the model by the default solver
|
|
|
|
|
|
def main():
|
|
model = dro.Model("electricSystem")
|
|
|
|
# w = model.dvar(w)
|
|
model.solve(eco)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
# simple_linear()
|
|
main()
|