I'm using CPLEX Community Edition with Pyomo but think that although the model is beeing solved, I cannot get the solution (Variables, in Pyomo terminology).Following is a example - with minor modification to cope with minor change in notation of pyomo - from http://www.ibm.com/developerworks/cloud/library/cl-optimizepythoncloud1/The major problem is:# ---------------------------------------------------------- # Solution Information # ---------------------------------------------------------- Solution: - number of solutions: 0 number of solutions displayed: 0I expected to have the Variables here.Code bellow:#Explicit importing makes it more clear what a user needs to define#versus what is included within the pyomo libraryfrom pyomo.environ import (ConcreteModel, Objective, Var, NonNegativeReals,maximize, Constraint)Products = ['Doors', 'Windows']ProfitRate = {'Doors':300, 'Windows':500}Plants = ['Door Fab', 'Window Fab', 'Assembly']HoursAvailable = {'Door Fab':4, 'Window Fab':12, 'Assembly':18}HoursPerUnit = {('Doors','Door Fab'):1, ('Windows', 'Window Fab'):2,('Doors','Assembly'):3, ('Windows', 'Assembly'):2,('Windows', 'Door Fab'):0, ('Doors', 'Window Fab'):0}#Concrete Modelmodel = ConcreteModel()#Decision Variablesmodel.WeeklyProd = Var(Products, within=NonNegativeReals)#Objectivemodel.obj = Objective(expr=sum(ProfitRate[i] * model.WeeklyProd[i] for i in Products),sense = maximize)def CapacityRule(model, p):"""User Defined Capacity RuleAccepts a pyomo Concrete Model as the first positional argument,and and a plant index as a second positional argument"""return sum(HoursPerUnit[i,p] * model.WeeklyProd[i] for i in Products) <= HoursAvailable[p]# This statement is what Pyomo needs to generate one constraint for each plantmodel.Capacity = Constraint(Plants, rule = CapacityRule)# ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------from pyomo.opt import SolverFactoryopt = SolverFactory("cplex")results = opt.solve(model)#sends results to stdoutresults.write()# ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------Output# ========================================================== # = Solver Results = # ========================================================== # ---------------------------------------------------------- # Problem Information # ---------------------------------------------------------- Problem: - Name: tmp524cn2mb Lower bound: 3600.0 Upper bound: 3600.0 Number of objectives: 1 Number of constraints: 4 Number of variables: 3 Number of nonzeros: 5 Sense: maximize # ---------------------------------------------------------- # Solver Information # ---------------------------------------------------------- Solver: - Status: ok User time: 0.01 Termination condition: optimal Termination message: Dual simplex - Optimal\x3a Objective = 3.6000000000e+03 Error rc: 0 Time: 0.10359001159667969 # ---------------------------------------------------------- # Solution Information # ---------------------------------------------------------- Solution: - number of solutions: 0 number of solutions displayed: 0
Dear all,--I had been using Pyomo with the Community Edition of CPLEX without problems. I had to reinstall everything in my computer for order reasons and suddenly I can't get it to work anymore.I used to create "SolverFactory('cplex')" and with this run "solve" in a model and the result was a dictionary with 'Solution' key that had the variables of the optimization.Now I have the following output, where the problematic part is the value of 'Solution' key (no variables solved appearing):Problem: - Name: tmpz1of1gmt Lower bound: 1.507233057183755 Upper bound: 1.507233057183755 Number of objectives: 1 Number of constraints: 64 Number of variables: 21 Number of nonzeros: 111 Sense: minimize Solver: - Status: ok User time: 0.12 Termination condition: optimal Termination message: MIP - Integer optimal solution\x3a Objective = 1.5072330572e+00 Statistics: Branch and bound: Number of bounded subproblems: 272 Number of created subproblems: 272 Error rc: 0 Time: 0.22814488410949707 Solution: - number of solutions: 0 number of solutions displayed: 0If is necessary, I can create a toy example to reproduce my problem.
You received this message because you are subscribed to the Google Groups "Pyomo Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pyomo-forum...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.