Error code: <bound method Model.optimize of <gurobi.Model Continuous instance Greenhouse Renewable Energy Use: 0 constrs, 0 vars, No parameter changes>>
Answered#conda install -c gurobi gurobi
from gurobipy import *
import gurobipy as gp
import pandas as pd #for csv reading
import numpy as np
import matplotlib.pyplot as plt #for plotting
dataset = pd.read_csv('AssB_all_input_data_summer_and_winter_profiles.csv',encoding= 'unicode_escape',
index_col= 'hour',
sep = ',')
#dataset = pd.read_csv("C:/Users/oliviapark/Thesis_Greenhouse Climate Optimization/csv/AssB_all_input_data_summer_and_winter_profiles.csv")
dataset.head()
#supplemental lighting input data
hoursof_sl = pd.read_csv ('hoursofsl.csv',
#encoding= 'unicode_escape',
index_col= 'Hour',
sep = ',')
print(hoursof_sl)
print(type(hoursof_sl))
#make hoursof_sl into list
hoursof_sll=hoursof_sl['Supplemental Lighting'].to_list()
print(hoursof_sll)
#ventilation input data
hoursof_v = pd.read_csv ('hoursofvent.csv',
#encoding= 'unicode_escape',
index_col = 'Hour',
sep = ',')
hoursof_sl.head()
hoursof_v.head()
cost = list(dataset['c - Electricity Price (/MWh)'])
print(cost)
#assign the column to a variable
Ppvt = list(dataset['summer profile'])
print(Ppvt)
#MODEL
model = gp.Model('Greenhouse Renewable Energy Use')
#ASSIGN TIME FRAME
T = 23
t = np.linspace(0, T, 24) #linspace equal intervals in the 24 hrs
# Make an array from 0 to 50 in 1000 steps
#h_range = np.linspace(0, 50, 1000)
print(t)
int_t= t.astype(int) #make into integers not numpy.float64
#print(type(int_array[0]))
t1 = int_t.tolist() #make into list
print(t1)
N = 286 #has 286 light bulbs
#ASSIGN VARIABLES
pgridabs = model.addVars(T,name ='power absorbed from grid') #t1 cannot be a list to be in this argument
Psl = model.addVars(T,N, name ='supplemental lighting power')
#print(pgridabs[0,0])
#ENERGY BALANCE
model.addConstrs(pgridabs[t1] + Ppvt[t1] == gp.quicksum(Psl[t1,n] for n in range(N)) for t1 in range (T))
#Supplemental Lighting
p_sl_min = 0.054
#per lamp each hour
p_sl_bet = 17
p_sl_max = 0.066
p_sl_ttl = 292.864
#each light bulb cannot exceed or fall behind the min and max
model.addConstrs(Psl[t1,n] <= p_sl_max for t1 in range(T) for n in range (N))
model.addConstrs(Psl[t1,n] >= p_sl_min for t1 in range (T) for n in range (N))
#supplemental lighting constraint multiplying with time so that it operates during 0500-2300
model.addConstrs(gp.quicksum(Psl[t1,n]* hoursof_sll[t1] for t1 in range (T)) <= p_sl_ttl for n in range(N))
obj = gp.quicksum(cost[t1] * pgridabs[t1] for t1 in range(T))
#minimize total cost of generaton while ----> with more variables will change
model.setObjective(obj,gp.GRB.MINIMIZE)
model.optimize
The error code indicating 0 constrs, 0 vars, No parameter changes.. it took me ages to correct the dimension mismatch in the constraints and now I have this error code.
Does anyone know the reason for this error?
-
Official comment
This post is more than three years old. Some information may not be up to date. For current information, please check the Gurobi Documentation or Knowledge Base. If you need more help, please create a new post in the community forum. Or why not try our AI Gurobot?. -
This is not an error message. You are effectively printing the Model.optimize() function instead of calling it. To call Model.optimize(), add closing parentheses:
model.optimize()
Gurobi reports no variables or constraints in the model because Model.update() was not called after adding the variables and constraints. That said, Gurobi performs a model update internally when Model.optimize() is called. As a result, there is no need to explicitly call Model.update() in your code unless you want to query information about the variables/constraints before solving the model.
0 -
Thank you for the reply - indeed the parentheses did the work.
I have an academic license and it seems that this has limitations..can students have a full license?
GurobiError Traceback (most recent call last) <ipython-input-2-4b5bdce5b8bd> in <module> 102 103 model.setObjective(obj,gp.GRB.MINIMIZE) --> 104 model.optimize() 105 106 #P = model.getAttr("X") src/gurobipy/model.pxi in gurobipy.Model.optimize() GurobiError: Model too large for size-limited license; visit https://www.gurobi.com/free-trial for a full license
GurobiError Traceback (most recent call last) <ipython-input-2-4b5bdce5b8bd> in <module> 102 103 model.setObjective(obj,gp.GRB.MINIMIZE) --> 104 model.optimize() 105 106 #P = model.getAttr("X") src/gurobipy/model.pxi in gurobipy.Model.optimize() GurobiError: Model too large for size-limited license; visit https://www.gurobi.com/free-trial for a full license
0 -
It doesn't look like your academic license file is properly set up. An academic license gives you access to all of Gurobi's features without any restrictions on problem size. I suspect Gurobi is detecting only the size-limited license file included in a pip installation of gurobipy.
To set up a free academic license, connect your computer to your university's network, then follow the instructions for a named-user academic license at https://www.gurobi.com/academia/academic-program-and-licenses/. This involves downloading Gurobi Optimizer so you can run a \( \texttt{grbgetkey} \) command to set up the academic license file on your computer.
0
Post is closed for comments.
Comments
4 comments