室内環境を自動生成するプログラムを書きたいです。この目的のために、問題を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(シータ_a) && y_b == y_a + sin(シータ_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.
#
これは一般的な問題であることがわかりました。
コア ダンプの書き込みに失敗しました。コア ダンプが無効になりました
しかし、ウェブで見つけた答えはどれも私の問題を解決しませんでした。
だから、誰かが私に解決策を指摘できればとてもうれしいです!!!
ありがとう。