[gecode-users] Problem with linear constraint over integers using minimodel ("undef ref")
Sascha Schnug
saschaschnug at web.de
Tue Mar 28 02:14:29 CEST 2017
Hi,
i'm a new user of Gecode and i have some trouble.
I'm using Gecode 5.0, compiled with the defaults plus gmp & mpfr (although i don't think it's
needed for my case) under Windows using Cygwin (gcc/g++: 5.4). (If i recall correctly;
i needed to manually modify the 3rd-party code where the rounding-mode is selected).
While i made good progress at first (despite the fact that i'm rediscovering C++), the following
part of my code is not working:
Excerpt:
--------
#include <gecode/int.hh>
#include <gecode/search.hh>
#include <gecode/minimodel.hh>
#include <gecode/float.hh> // for later use
using Gecode;
protected:
IntVarArray q_start;
IntVarArray q_end;
IntVarArray q_length;
public:
IntVarArgs q_start_;
IntVarArgs q_end_;
IntVarArgs q_length_;
..........
for(int i=0; i<n_q; i++)
{
q_start_ << IntVar(*this, 0, 95);
q_end_ << IntVar(*this, 0, 95);
q_length_ << IntVar(*this, 0, 95);
}
q_start = IntVarArray(*this, q_start_);
q_end = IntVarArray(*this, q_end_);
q_length = IntVarArray(*this, q_length_);
..........
for(int q=0; q<n_q; ++q)
{
// get length of window / THIS SEEMS TO BE THE PROBLEM!
rel(*this, 1*q_length[q] == 1*q_end[q] - 1*q_start[q]); // minimodel-like
}
I think this follows the examples in the guide as well as other resources.
My Makefile looks like this (following https://gist.github.com/fepa/2187179; also uses the order mentioned in guide):
# Configure this makefile if needed then run
# $ make all
# to compile and link
# What files to compile
OBJS=problem.cpp solver.cpp
# What file to compile to
MAINFILE=solver
# What compiler to use
CC=g++
# Where is your gecode library?
# (Gecode's default 'make install' behavior installs gecode libraries and headers under /usr/local)
GECODEDIR=/usr/local
# 'make all' does both compiling and link (i.e 'make compile link')
all: compile link
# 'make compile' compiles files
compile: $(OBJS)
$(CC) -I$(GECODEDIR)/include -c $(OBJS)
# 'make link' links compiled files
link: $(OBJS)
$(CC) -o $(MAINFILE) -L$(GECODEDIR)/lib $(MAINFILE).o \
-lgecodeflatzinc -lgecodedriver \
-lgecodesearch -lgecodeminimodel -lgecodeset \
-lgecodefloat \
-lgecodeint -lgecodekernel -lgecodesupport
# 'make clean' cleans up generated files from make commands
clean:
rm -rf *o $(MAINFILE)
Now this is the ugly output i receive:
$ make
g++ -I/usr/local/include -c solver_v4.cpp -D_GLIBCXX_DEBUG -D_GLIBCXX_DEBUG_PEDANTIC
g++ -o solver_v4 -L/usr/local/lib solver_v4.o \
-lgecodeflatzinc -lgecodedriver -lgecodefloat \
-lgecodesearch -lgecodeminimodel -lgecodeset \
-lgecodeint -lgecodekernel -lgecodesupport
/usr/local/lib/libgecodeminimodel.a(float-expr.o): In function `Gecode::LinFloatExpr::post(Gecode::Home) const':
/cygdrive/x/gecode-5.0.0/gecode-5.0.0/gecode/minimodel/float-expr.cpp:220: undefined reference to `Gecode::Float::Linear::estimate(Gecode::Float::Linear::Term*, int, Gecode::FloatVal, double&, double&)'
/cygdrive/x/gecode-5.0.0/gecode-5.0.0/gecode/minimodel/float-expr.cpp:220:(.text+0x3df3): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `Gecode::Float::Linear::estimate(Gecode::Float::Linear::Term*, int, Gecode::FloatVal, double&, double&)'
/cygdrive/x/gecode-5.0.0/gecode-5.0.0/gecode/minimodel/float-expr.cpp:223: undefined reference to `Gecode::Float::Linear::post(Gecode::Home, Gecode::Float::Linear::Term*, int, Gecode::FloatRelType, Gecode::FloatVal)'
/cygdrive/x/gecode-5.0.0/gecode-5.0.0/gecode/minimodel/float-expr.cpp:223:(.text+0x4029): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `Gecode::Float::Linear::post(Gecode::Home, Gecode::Float::Linear::Term*, int, Gecode::FloatRelType, Gecode::FloatVal)'
/usr/local/lib/libgecodeminimodel.a(float-expr.o): In function `Gecode::LinFloatExpr::post(Gecode::Home, Gecode::FloatRelType, Gecode::BoolVar const&) const':
/cygdrive/x/gecode-5.0.0/gecode-5.0.0/gecode/minimodel/float-expr.cpp:205: undefined reference to `Gecode::Float::Linear::post(Gecode::Home, Gecode::Float::Linear::Term*, int, Gecode::FloatRelType, Gecode::FloatVal, Gecode::Reify)'
/cygdrive/x/gecode-5.0.0/gecode-5.0.0/gecode/minimodel/float-expr.cpp:205:(.text+0x4277): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `Gecode::Float::Linear::post(Gecode::Home, Gecode::Float::Linear::Term*, int, Gecode::FloatRelType, Gecode::FloatVal, Gecode::Reify)'
/usr/local/lib/libgecodeminimodel.a(float-expr.o): In function `Gecode::LinFloatExpr::post(Gecode::Home, Gecode::FloatRelType) const':
/cygdrive/x/gecode-5.0.0/gecode-5.0.0/gecode/minimodel/float-expr.cpp:182: undefined reference to `Gecode::Float::Linear::post(Gecode::Home, Gecode::Float::Linear::Term*, int, Gecode::FloatRelType, Gecode::FloatVal)'
/cygdrive/x/gecode-5.0.0/gecode-5.0.0/gecode/minimodel/float-expr.cpp:182:(.text+0x468d): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `Gecode::Float::Linear::post(Gecode::Home, Gecode::Float::Linear::Term*, int, Gecode::FloatRelType, Gecode::FloatVal)'
collect2: error: ld returned 1 exit status
make: *** [Makefile:24: link] Error 1
I'm kinda lost right now as i have no idea what the problem is. I did not check Gecode's sources yet.
My makefile uses some of GCC's STL-debugging tools, but they are not the reason for this.
Another remark:
In my previous compilation (without gmp + mpfr; added now) i build all the examples too.
-> all examples using float & minimodel are behaving strange:
=> they all seem to run without errors, but do not produce any output (clean shell)
I did not research the Script-like usage of gecode a lot, but i expect those examples should
produce output too like all the others.
Thanks for taking the time to read this! I hope i did not forget to mention relevant information.
-
Sascha-Dominic Schnug
More information about the users
mailing list