1

我想写一个自动生成室内环境的程序。为此,我考虑了将问题表述为CSP的想法,其中变量为:

  • x_o,y_o:物体o在环境中的位置

  • theta_o:对象o的方向

域是:

  • x 和 y 的某个范围 [a,b](即 2D 网格的尺寸)

  • [0,90,180,270] 度的方向。

为了解决这个问题,我在 Eclipse 4.7.1a 中使用了Choco 。

我的问题如下:

我想表达一个约束,例如:对象 a在对象 b的前面。

由于对象有一个方向,我认为表达这种约束的一种可能方法是:

  • x_b == x_a + cos(theta_a) && y_b == y_a + sin(theta_a)

这个资源中,我发现 Choco 使用Ibex来解决实际限制。我按照安装说明将共享库添加到java.library.path. 为了定义一个真正的约束,我遵循了这个文档,但是当我运行这段代码时:

import org.chocosolver.solver.Model;
import org.chocosolver.solver.Solution;
import org.chocosolver.solver.variables.RealVar;

public class EnvironmentGenerationMain {

    public static void main(String[] args) {
        Model model = new Model("Environment generation problem");
        System.out.println(model.getName());

        //A
        RealVar x_a = model.realVar("X_a", 0, 2, 1.0d);
        RealVar y_a = model.realVar("Y_a", 0, 2, 1.0d);
        RealVar z_a = model.realVar("Z_a", 0, 270, 90.0d);

        //A
        RealVar x_b = model.realVar("X_b", 0, 2, 1.0d);
        RealVar y_b = model.realVar("Y_b", 0, 2, 1.0d);
        RealVar z_b = model.realVar("Z_b", 0, 270, 90.0d);

        model.post(model.realIbexGenericConstraint("{0}={1}+cos{2}", x_b,x_a,z_a));
        model.post(model.realIbexGenericConstraint("{0}={1}+sin{2}", y_b,y_a,z_a));


        Solution solution = model.getSolver().findSolution();
        if(solution != null){
            System.out.println(solution.toString());
        }

    }

}

这是我得到的错误:

Environment generation problem
#
# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGSEGV (0xb) at pc=0x00007f7e322b0891, pid=21072, tid=0x00007f7e63562700
#
# JRE version: OpenJDK Runtime Environment (8.0_151-b12) (build 1.8.0_151-8u151-b12-0ubuntu0.16.04.2-b12)
# Java VM: OpenJDK 64-Bit Server VM (25.151-b12 mixed mode linux-amd64 compressed oops)
# Problematic frame:
# C  [libibex-java.so+0x4891]  Java_org_chocosolver_solver_constraints_real_Ibex_add_1ctr+0x61
#
# Failed to write core dump. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
#
# An error report file with more information is saved as:
# /home/dede/eclipse-workspace/EnvironmentGeneration/hs_err_pid21072.log
#
# If you would like to submit a bug report, please visit:
#   http://bugreport.java.com/bugreport/crash.jsp
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#

我发现这是一个常见问题:

无法写入核心转储。核心转储已被禁用

但我在网上找到的答案都没有解决我的问题。

所以,如果有人能指出我的解决方案,我会很高兴!!!

谢谢。

4

1 回答 1

0

@Tobi 我正在使用 Linux

升级到 Choco 4.0.6 和 Ibex 2.6.3 解决了这个问题。为了让事情正常进行,我还必须调试代码。这是一个工作示例:

package it.semanticmapping.environmentgeneration;

import org.chocosolver.solver.Model;
import org.chocosolver.solver.Solution;
import org.chocosolver.solver.variables.RealVar;

public class EnvironmentGenerationMain {

    public static void main(String[] args) {
        // TODO Auto-generated method stub
        Model model = new Model("Environment Generation");
        System.out.println(model.getName());


        //A
        RealVar x_a = model.realVar("X_a", 0, 2, 0.0001d);
        RealVar y_a = model.realVar("Y_a", 0, 2, 0.0001d);
        RealVar z_a = model.realVar("Z_a", 0, Math.PI*3/2, Math.PI/2);

        //B
        RealVar x_b = model.realVar("X_b", 0, 2, 0.0001d);
        RealVar y_b = model.realVar("Y_b", 0, 2, 0.0001d);
        RealVar z_b = model.realVar("Z_b", 0, Math.PI*3/2, Math.PI/2);

        RealVar cost = model.realVar(0);

        model.post(model.realIbexGenericConstraint("{0}={1}", z_a,cost));
        model.post(model.realIbexGenericConstraint("{0}={1}+cos({2})", x_b,x_a,z_a));
        model.post(model.realIbexGenericConstraint("{0}={1}+sin({2})", y_b,y_a,z_a));
        model.post(model.realIbexGenericConstraint("{0}={1}", z_b, z_a));

        Solution solution = model.getSolver().findSolution();
        if(solution != null){
            System.out.println(solution.toString());
        }
    }

}
于 2017-12-15T08:56:25.490 回答