Skip to content

Commit

Permalink
Merge branch 'release/2.3.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
guidotack committed Jul 10, 2019
2 parents 879e795 + 776a1bb commit 6e40116
Show file tree
Hide file tree
Showing 22 changed files with 318 additions and 96 deletions.
2 changes: 2 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ build:wasm_complete:
cache:
key: "$CI_JOB_NAME"
paths: [.ccache, vendor.zip*]
when: manual

build:wasm_minimal:
image: trzeci/emscripten
Expand All @@ -123,6 +124,7 @@ build:wasm_minimal:
cache:
key: "$CI_JOB_NAME"
paths: [.ccache, vendor.zip*]
when: manual

# ----------- Trigger FindMUS pipeline -----------

Expand Down
17 changes: 17 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,23 @@
All bug numbers refer to the issue tracker at
https://github.com/MiniZinc/libminizinc/issues

Version 2.3.1
=============

Bug fixes:

- Report error when trying to assign an array literal to an array variable with incompatible index set.
- Fix partial evaluation of expressions, so that only par expressions are fully evaluated. Fixes #298.
- Remove carriage returns when reading piped solver output on Windows.
- Canonicalize paths of executables to avoid spurious warnings about multiple executables for the same solver.
- Add implementations for != on arrays.
- Compute quotient bounds before decomposition of int_div in linearisation library.
- Propagate domain constraints on variables that are aliased (previously domain constraints could get lost).
- Propagate domain constraints from left-hand-side to right-hand-side in variable assignments.
- piecewise-linear: reuse decomposition for X when only Y-values change.
- nosets: add set_in_imp(var set) and simplify set_in_reif, set_eq(var set, var set).
- linearisation: improved compilation of set_in constraints.

Version 2.3
===========

Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ cmake_minimum_required(VERSION 3.4.0)
# -- Project information and versioning.

project(libminizinc
VERSION 2.3.0
VERSION 2.3.1
LANGUAGES CXX C)

if(NOT BUILD_REF)
Expand Down
4 changes: 2 additions & 2 deletions cmake/modules/FindXpress.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ list(INSERT CMAKE_PREFIX_PATH 0 "${XPRESS_ROOT}" "$ENV{XPRESS_ROOT}")
#TODO: Check default installation locations
find_path(XPRESS_INCLUDE xprs.h
PATHS $ENV{XPRESSDIR} $ENV{XPRESS} $ENV{XPRESS_DIR}
HINTS /opt/xpressmp
HINTS /opt/xpressmp C:/xpressmp
PATH_SUFFIXES include)

foreach(XPRESS_LIB xprb xprs)
set(XPRESS_LIB_LOC "XPRESS_LIB_LOC-NOTFOUND")
find_library(XPRESS_LIB_LOC NAMES ${XPRESS_LIB} lib${XPRESS_LIB}
PATHS $ENV{XPRESSDIR} $ENV{XPRESS} $ENV{XPRESS_DIR}
HINTS /opt/xpressmp
HINTS /opt/xpressmp C:/xpressmp
PATH_SUFFIXES lib)
if("${XPRESS_LIB_LOC}" STREQUAL "XPRESS_LIB_LOC-NOTFOUND")
# message(STATUS "FICO Xpres: Could not find library `${XPRESS_LIB}`")
Expand Down
4 changes: 2 additions & 2 deletions cmake/support/config_emscripten.cmake
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
if (DEFINED EMSCRIPTEN)
add_custom_command(OUTPUT ${PROJECT_BINARY_DIR}/CMakeFiles/file_packager.js
COMMAND python ${EMSCRIPTEN_ROOT_PATH}/tools/file_packager.py minizinc.data --preload ${PROJECT_SOURCE_DIR}/share@/minizinc --from-emcc --js-output=${PROJECT_BINARY_DIR}/CMakeFiles/file_packager.js
COMMAND python ${EMSCRIPTEN_ROOT_PATH}/tools/file_packager.py minizinc.data --lz4 --preload ${PROJECT_SOURCE_DIR}/share@/minizinc --from-emcc --js-output=${PROJECT_BINARY_DIR}/CMakeFiles/file_packager.js
COMMENT "building data store minizinc.data")

set(EMSCRIPTEN_CXX_FLAGS "-s MINIZ_NO_ARCHIVE_APIS -s MINIZ_NO_ZLIB_APIS")
set(EMSCRIPTEN_LINK_FLAGS " -s FORCE_FILESYSTEM=1 -s MODULARIZE=1 -s EXTRA_EXPORTED_RUNTIME_METHODS=\"['cwrap', 'FS', 'ENV']\" -s DISABLE_EXCEPTION_CATCHING=0 -s BINARYEN_TRAP_MODE=\"clamp\" -s ALLOW_MEMORY_GROWTH=1 --no-heap-copy")
set(EMSCRIPTEN_LINK_FLAGS " -s FORCE_FILESYSTEM=1 -s LZ4=1 -s MODULARIZE=1 -s EXTRA_EXPORTED_RUNTIME_METHODS=\"['cwrap', 'FS', 'ENV']\" -s DISABLE_EXCEPTION_CATCHING=0 -s BINARYEN_TRAP_MODE=\"clamp\" -s ALLOW_MEMORY_GROWTH=1 --no-heap-copy")

# -------------------------------------------------------------------------------------------------------------------
# -- Web Assembly Configuration.
Expand Down
2 changes: 1 addition & 1 deletion cmake/targets/libminizinc_cplex.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ if(CPLEX_FOUND AND USE_CPLEX)
target_compile_definitions(mzn PRIVATE HAS_CPLEX)
target_sources(mzn PRIVATE $<TARGET_OBJECTS:minizinc_cplex>)
set_target_properties(mzn PROPERTIES COMPILE_FLAGS ${CPLEX_COMPILE_FLAGS})
target_link_libraries(mzn ${CMAKE_THREAD_LIBS_INIT} ${CPLEX_LIBRARIES})
target_link_libraries(mzn ${CPLEX_LIBRARIES})
endif()
1 change: 0 additions & 1 deletion cmake/targets/libminizinc_gecode.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ if(GECODE_FOUND AND USE_GECODE)
target_compile_definitions(mzn PRIVATE HAS_GECODE)
target_sources(mzn PRIVATE $<TARGET_OBJECTS:minizinc_gecode>)

target_link_libraries(mzn ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries(mzn Gecode::Driver Gecode::Float Gecode::Int Gecode::Kernel Gecode::Search Gecode::Set)
if(WIN32 AND GECODE_HAS_GIST)
target_link_libraries(mzn Gecode::Gist)
Expand Down
2 changes: 1 addition & 1 deletion cmake/targets/libminizinc_gurobi.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ if(GUROBI_FOUND)
### Setup correct compilation into the MiniZinc library
target_compile_definitions(mzn PRIVATE HAS_GUROBI)
target_sources(mzn PRIVATE $<TARGET_OBJECTS:minizinc_gurobi>)
target_link_libraries(mzn ${GUROBI_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries(mzn ${GUROBI_LIBRARIES})

endif()
2 changes: 1 addition & 1 deletion cmake/targets/libminizinc_scip.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ if(SCIP_FOUND AND USE_SCIP)
### Setup correct compilation into the MiniZinc library
target_compile_definitions(mzn PRIVATE HAS_SCIP)
target_sources(mzn PRIVATE $<TARGET_OBJECTS:minizinc_scip>)
target_link_libraries(mzn ${SCIP_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries(mzn ${SCIP_LIBRARIES})

endif()
4 changes: 2 additions & 2 deletions cmake/targets/libminizinc_xpress.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ if(XPRESS_FOUND AND USE_XPRESS)
)

target_include_directories(minizinc_xpress PRIVATE ${XPRESS_INCLUDE_DIRS})
target_link_libraries(minizinc_xpress minizinc_core xprb xprs ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries(minizinc_xpress minizinc_core ${XPRESS_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
add_dependencies(minizinc_xpress minizinc_parser)

### Setup correct compilation into the MiniZinc library
target_compile_definitions(mzn PRIVATE HAS_XPRESS)
target_sources(mzn PRIVATE $<TARGET_OBJECTS:minizinc_xpress>)
target_link_libraries(mzn xprb xprs ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries(mzn ${XPRESS_LIBRARIES})

endif()
1 change: 1 addition & 0 deletions cmake/targets/libmzn.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ add_library(mzn
$<TARGET_OBJECTS:minizinc_fzn>
$<TARGET_OBJECTS:minizinc_nl>
)
target_link_libraries(mzn ${CMAKE_THREAD_LIBS_INIT})

### Add Solver Interfaces to the MiniZinc library when available
include(cmake/targets/libminizinc_cplex.cmake)
Expand Down
1 change: 1 addition & 0 deletions include/minizinc/flatten_internal.hh
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ namespace MiniZinc {

void setComputedDomain(EnvI& envi, VarDecl* vd, Expression* domain, bool is_computed);
EE flat_exp(EnvI& env, Ctx ctx, Expression* e, VarDecl* r, VarDecl* b);
EE flatten_id(EnvI& env, Ctx ctx, Expression* e, VarDecl* r, VarDecl* b, bool doNotFollowChains);

class CmpExpIdx {
public:
Expand Down
13 changes: 10 additions & 3 deletions include/minizinc/process.hh
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,22 @@ namespace MiniZinc {
assert( pOs!=0 || pSo!=0 );
while (!done) {
char buffer[5255];
char nl_buffer[5255];
DWORD count = 0;
BOOL bSuccess = ReadFile(g_hCh, buffer, sizeof(buffer) - 1, &count, NULL);
if (bSuccess && count > 0) {
buffer[count] = 0;
int nl_count = 0;
for (int i=0; i<count; i++) {
if (buffer[i] != 13) {
nl_buffer[nl_count++] = buffer[i];
}
}
nl_buffer[nl_count] = 0;
std::lock_guard<std::mutex> lck(*mtx);
if (pSo)
pSo->feedRawDataChunk( buffer );
pSo->feedRawDataChunk( nl_buffer );
if (pOs)
(*pOs) << buffer << std::flush;
(*pOs) << nl_buffer << std::flush;
}
else {
if (pSo)
Expand Down
42 changes: 22 additions & 20 deletions lib/eval_par.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1875,26 +1875,28 @@ namespace MiniZinc {
ret->type(t);
return ret;
}
if (e->type().isintset()) {
return EvalSetLit::e(env,e);
}
if (e->type().isfloatset()) {
return EvalFloatSetLit::e(env,e);
}
if (e->type().isboolset()) {
return EvalBoolSetLit::e(env,e);
}
if (e->type()==Type::parint()) {
return EvalIntLit::e(env,e);
}
if (e->type()==Type::parbool()) {
return EvalBoolLit::e(env,e);
}
if (e->type()==Type::parfloat()) {
return EvalFloatLit::e(env,e);
}
if (e->type()==Type::parstring()) {
return EvalStringLit::e(env,e);
if (e->type().ispar()) {
if (e->type().isintset()) {
return EvalSetLit::e(env,e);
}
if (e->type().isfloatset()) {
return EvalFloatSetLit::e(env,e);
}
if (e->type().isboolset()) {
return EvalBoolSetLit::e(env,e);
}
if (e->type()==Type::parint()) {
return EvalIntLit::e(env,e);
}
if (e->type()==Type::parbool()) {
return EvalBoolLit::e(env,e);
}
if (e->type()==Type::parfloat()) {
return EvalFloatLit::e(env,e);
}
if (e->type()==Type::parstring()) {
return EvalStringLit::e(env,e);
}
}
switch (e->eid()) {
case Expression::E_ITE:
Expand Down
49 changes: 48 additions & 1 deletion lib/flatten.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1963,6 +1963,28 @@ namespace MiniZinc {
}
SetLit* ibv_l = new SetLit(Location().introduce(),ibv);
vd->ti()->domain(ibv_l);
if (Id* rhs_ident = vd->e()->dyn_cast<Id>()) {
if (rhs_ident->decl()->ti()->domain()) {
IntSetVal* rhs_domain = eval_intset(env,rhs_ident->decl()->ti()->domain());
IntSetRanges dr(rhs_domain);
IntSetRanges ibr(ibv);
Ranges::Inter<IntVal,IntSetRanges,IntSetRanges> i(dr,ibr);
IntSetVal* rhs_newibv = IntSetVal::ai(i);
if (rhs_domain->card() != rhs_newibv->card()) {
rhs_ident->decl()->ti()->domain(ibv_l);
rhs_ident->decl()->ti()->setComputedDomain(false);
if (rhs_ident->decl()->type().isopt()) {
std::vector<Expression*> args(2);
args[0] = rhs_ident;
args[1] = ibv_l;
Call* c = new Call(Location().introduce(), "var_dom", args);
c->type(Type::varbool());
c->decl(env.model->matchFn(env, c, false));
(void) flat_exp(env, Ctx(), c, constants().var_true, constants().var_true);
}
}
}
}
if (vd->type().isopt()) {
std::vector<Expression*> args(2);
args[0] = vd->id();
Expand Down Expand Up @@ -2000,6 +2022,29 @@ namespace MiniZinc {
}
SetLit* fbv_l = new SetLit(Location().introduce(),fbv);
vd->ti()->domain(fbv_l);
if (Id* rhs_ident = vd->e()->dyn_cast<Id>()) {
if (rhs_ident->decl()->ti()->domain()) {
FloatSetVal* rhs_domain = eval_floatset(env,rhs_ident->decl()->ti()->domain());
FloatSetRanges dr(rhs_domain);
FloatSetRanges ibr(fbv);
Ranges::Inter<FloatVal,FloatSetRanges,FloatSetRanges> i(dr,ibr);
FloatSetVal* rhs_newfbv = FloatSetVal::ai(i);
if (rhs_domain->card() != rhs_newfbv->card()) {
rhs_ident->decl()->ti()->domain(fbv_l);
rhs_ident->decl()->ti()->setComputedDomain(false);
if (rhs_ident->decl()->type().isopt()) {
std::vector<Expression*> args(2);
args[0] = rhs_ident;
args[1] = fbv_l;
Call* c = new Call(Location().introduce(), "var_dom", args);
c->type(Type::varbool());
c->decl(env.model->matchFn(env, c, false));
(void) flat_exp(env, Ctx(), c, constants().var_true, constants().var_true);
}
}
}
}

if (vd->type().isopt()) {
std::vector<Expression*> args(2);
args[0] = vd->id();
Expand Down Expand Up @@ -2525,9 +2570,11 @@ namespace MiniZinc {
if (v->e()->type().ispar() && !v->e()->type().isopt() && !v->e()->type().cv() && v->e()->type().dim() > 0 && v->e()->ti()->domain()==NULL
&& (v->e()->type().bt()==Type::BT_INT || v->e()->type().bt()==Type::BT_FLOAT)) {
// Compute bounds for array literals
CallStackItem csi(env,v->e());
GCLock lock;
ArrayLit* al = eval_array_lit(env, v->e()->e());
v->e()->e(al);
checkIndexSets(env,v->e(), v->e()->e());
if (v->e()->type().bt()==Type::BT_INT && v->e()->type().st()==Type::ST_PLAIN) {
IntVal lb = IntVal::infinity();
IntVal ub = -IntVal::infinity();
Expand All @@ -2554,7 +2601,7 @@ namespace MiniZinc {
setComputedDomain(env, v->e(), new SetLit(Location().introduce(), FloatSetVal::a(lb, ub)), true);
}
} else if (v->e()->type().isvar() || v->e()->type().isann()) {
(void) flat_exp(env,Ctx(),v->e()->id(),NULL,constants().var_true);
(void) flatten_id(env,Ctx(),v->e()->id(),NULL,constants().var_true,true);
} else {
if (v->e()->e()==NULL) {
if (!v->e()->type().isann())
Expand Down
11 changes: 9 additions & 2 deletions lib/flatten/flatten_id.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

namespace MiniZinc {

EE flatten_id(EnvI& env,Ctx ctx, Expression* e, VarDecl* r, VarDecl* b) {
EE flatten_id(EnvI& env,Ctx ctx, Expression* e, VarDecl* r, VarDecl* b, bool doNotFollowChains) {
CallStackItem _csi(env,e);
EE ret;
Id* id = e->cast<Id>();
Expand All @@ -26,7 +26,9 @@ namespace MiniZinc {
throw FlatteningError(env,e->loc(), "undefined identifier");
}
}
id = follow_id_to_decl(id)->cast<VarDecl>()->id();
if (!doNotFollowChains) {
id = follow_id_to_decl(id)->cast<VarDecl>()->id();
}
if (ctx.neg && id->type().dim() > 0) {
if (id->type().dim() > 1)
throw InternalError("multi-dim arrays in negative positions not supported yet");
Expand Down Expand Up @@ -178,4 +180,9 @@ namespace MiniZinc {
}
return ret;
}

EE flatten_id(EnvI& env,Ctx ctx, Expression* e, VarDecl* r, VarDecl* b) {
return flatten_id(env,ctx,e,r,b,false);
}

}
2 changes: 1 addition & 1 deletion lib/solver_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ namespace MiniZinc {
sc._executable = exePath;
std::string exe = FileUtils::find_executable(FileUtils::file_path(exePath, basePath));
int nr_found = (int) (! exe.empty());
std::string tmp = FileUtils::find_executable(exePath);
std::string tmp = FileUtils::file_path(FileUtils::find_executable(exePath));
nr_found += (int) ( (! tmp.empty()) && tmp != exe);
exe = exe.empty() ? tmp : exe;
if (nr_found > 0) {
Expand Down
Loading

0 comments on commit 6e40116

Please sign in to comment.