Skip to content

Instantly share code, notes, and snippets.

@qtothec
Created April 20, 2016 05:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save qtothec/30b5edd277e74171088dbb91b11ea77e to your computer and use it in GitHub Desktop.
Save qtothec/30b5edd277e74171088dbb91b11ea77e to your computer and use it in GitHub Desktop.
Demonstration of error message on empty rows
Solver command line: ['/home/qtothec/.solvers/ampl.linux64/conopt', '-s', 'test.nl', 'outlev=3']
outlev=3
outlev=3
** Fatal Error ** There are empty rows in the model.
constraint _scon[3]: Row is empty.
The model has 1 empty row(s).
CONOPT time Total 0.000 seconds
of which: Function evaluations 0.000 = 0.0%
1st Derivative evaluations 0.000 = 0.0%
CONOPT error: Status not called.
g3 1 1 0 # problem unknown
2 3 1 0 3 # vars, constraints, objectives, ranges, eqns
0 0 0 0 0 0 # nonlinear constrs, objs; ccons: lin, nonlin, nd, nzlb
0 0 # network constraints: nonlinear, linear
0 0 0 # nonlinear vars in constraints, objectives, both
0 0 0 1 # linear network variables; functions; arith, flags
0 0 0 0 0 # discrete variables: binary, integer, nonlinear (b,c,o)
4 1 # nonzeros in Jacobian, obj. gradient
0 0 # max name lengths: constraints, variables
0 0 0 0 0 # common exprs: b,c,o,c1,o1
C0
n0
C1
n0
C2
n0
O0 0
n0
x2
0 4.0
1 2.0
r
4 0.0
4 2.0
4 0.0
b
2 0
2 0
k1
2
J0 2
0 1
1 -2
J1 2
0 1
1 -1
G0 1
0 1
from __future__ import division
from pyomo.environ import *
m = ConcreteModel()
nlpsolver = SolverFactory('conopt')
nlpsolver.options['outlev'] = 3
i = m.i = RangeSet(3)
v = m.v = Var(i, domain=NonNegativeReals, initialize=0)
def def_constr(model, i):
if i == 1:
return v[1] == v[2] * v[3]
if i == 2:
return v[1] == v[2] + v[3]
if i == 3:
return v[2] == 2
m.c = Constraint(i, rule=def_constr)
m.obj = Objective(expr=v[1], sense=minimize)
nlpsolver.solve(m, tee=True, keepfiles=True)
m.display()
# Running with the new conditions below results in
# ** Fatal Error ** There are empty rows in the model.
v[2].fix(2)
nlpsolver.solve(m, tee=True, keepfiles=True)
CONOPT error: Status not called.
Options
3
1
1
0
3
0
2
0
objno 0 531
suffix 0 2 8 0 0
sstatus
0 -1073559336
1 32545
suffix 1 2 8 0 0
sstatus
0 -1073559336
1 32545
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment