标签: optaplanner

IntelliJ IDEA中错误的Manifest.mf创建.jar

我试图通过IntelliJ IDEA的jar工件将使用OptaPlanner 6.0.1库的项目打包到.jar中,而不是我的manifest.mf包含标准

Manifest-Version: 1.0
Main-Class: a.b.c.app
Run Code Online (Sandbox Code Playgroud)

jar使用的是ecta-3.7.2.jar中提供的一个,这是OptaPlanner的支持库之一:

Manifest-Version: 1.0
Build-Jdk: 1.6.0_26
Built-By: ibrandt
Created-By: Apache Maven
Archiver-Version: Plexus Archiver
Run Code Online (Sandbox Code Playgroud)

因此,"no main manifest attribute, in appname.jar"尝试运行应用程序时会发生错误.如果我手动将.jar文件中的清单替换为我的一切正常.有什么办法可以解决这个问题吗?

我将这些库保存在一个单独的/ lib目录中,并将它们作为Extracted Directory添加到jar工件的根目录中,IntelliJ IDEA是v13.0.1.

java intellij-idea optaplanner

99
推荐指数
4
解决办法
6万
查看次数

使用Optaplanner解决VRPTWPD

我是optaplanner的新手,我希望用它来解决拾取和交付的VRPTW问题(VRPTWPD).

我首先从示例repo中获取VRPTW代码.我想添加它来解决我的问题.但是,我无法返回一个符合优先级/车辆限制的解决方案(必须在交付之前完成拾取,并且两者必须由同一车辆完成).

我一直在返回一个解决方案,其中硬分数是我期望的这样一个解决方案(即我可以在一个小样本问题中加起来所有违规,并看到硬分数与我为这些违规分配的处罚相匹配).

我尝试的第一种方法是遵循Geoffrey De Smet在此处概述的步骤 - /sf/answers/1336104731/

每个Customer都有一个变量customerType,描述它是一个皮卡(PU)还是一个交付(DO).它还有一个名为变量的变量parcelId,用于指示要拾取或交付的包裹.

我在Customer命名中添加了一个阴影变量parcelIdsOnboard.这是一个HashSet,它包含了驾驶员在访问给定时所拥有的所有parcelId Customer.

VariableListener保持parcelIdsOnboard更新的我看起来像这样:

public void afterEntityAdded(ScoreDirector scoreDirector, Customer customer) {
    if (customer instanceof TimeWindowedCustomer) {
        updateParcelsOnboard(scoreDirector, (TimeWindowedCustomer) customer);
    }
}

public void afterVariableChanged(ScoreDirector scoreDirector, Customer customer) {
    if (customer instanceof TimeWindowedCustomer) {
        updateParcelsOnboard(scoreDirector, (TimeWindowedCustomer) customer);
    }
}

protected void updateParcelsOnboard(ScoreDirector scoreDirector, TimeWindowedCustomer sourceCustomer) {
    Standstill previousStandstill = sourceCustomer.getPreviousStandstill();
    Set<Integer> parcelIdsOnboard = (previousStandstill instanceof …
Run Code Online (Sandbox Code Playgroud)

java drools optaplanner

13
推荐指数
1
解决办法
1300
查看次数

Optaplanner将客户从VRP解决方案中移除

基于这个问题,我尝试了以下内容:

public void doFactChange() {
    Location toBeRemovedLocation = customerToBeRemoved.getLocation();
    Location lookUpWorkingObject = (Location) scoreDirector.lookUpWorkingObject(toBeRemovedLocation);
    scoreDirector.beforeProblemFactRemoved(lookUpWorkingObject);
    routingSolution.getLocationList().remove(lookUpWorkingObject);
    scoreDirector.afterProblemFactRemoved(lookUpWorkingObject);
    Customer workingCustomer = (Customer) scoreDirector.lookUpWorkingObject(customerToBeRemoved);

    for (Customer customer : routingSolution.getCustomerList()) {
        while (customer != null) {
            if (customer == workingCustomer) {
                if (customer.getPreviousStandstill() != null) {
                    scoreDirector.beforeVariableChanged(customer, "previousStandstill");
                    customer.getPreviousStandstill().setNextCustomer(customer.getNextCustomer());

                    scoreDirector.afterVariableChanged(customer, "previousStandstill");
                }

                scoreDirector.beforeVariableChanged(customer, "nextCustomer");
                customer.getNextCustomer().setPreviousStandstill(customer.getPreviousStandstill());
                scoreDirector.afterVariableChanged(customer, "nextCustomer");
            }
            customer = customer.getNextCustomer();
        }
    }

    scoreDirector.beforeEntityRemoved(workingCustomer);
    routingSolution.getCustomerList().remove(workingCustomer);
    scoreDirector.afterEntityRemoved(workingCustomer);
    scoreDirector.triggerVariableListeners();
}
Run Code Online (Sandbox Code Playgroud)

注意:customerToBeRemoved是在调用之前创建的实例对象doFactChange()

但是我甚至在打电话之前就收到了以下例外 scoreDirector.triggerVariableListeners

java.lang.IllegalStateException:实体(Customer - 9048381398840634905)有一个变量(previousStandstill),其值(Customer - 9070671076516032025)具有sourceVariableName变量(nextCustomer),其值(Customer-8518512081385427431)不是该实体.验证sourceVariableName变量的输入问题的一致性.

另一个问题:

我试图直接删除实体,如下所示: …

java optaplanner

13
推荐指数
1
解决办法
320
查看次数

带有logback的SLF4J仍然提示无法加载类"org.slf4j.impl.StaticLoggerBinder"

我有一个maven项目,它使用slf4j和logback作为记录器.我可以看到这两个工件都在我的maven依赖项树项目中.但每当我尝试运行我的项目时,我都会提示:

SLF4J:无法加载类"org.slf4j.impl.StaticLoggerBinder".SLF4J:默认为无操作(NOP)记录器实现SLF4J:有关更多详细信息,请参阅http://www.slf4j.org/codes.html#StaticLoggerBinder.

我检查链接,有人说:

在类路径上放置一个(并且只有一个)slf4j-nop.jar,slf4j-simple.jar,slf4j-log4j12.jar,slf4j-jdk14.jar或logback-classic.jar应该可以解决问题.

我已经将logback-classic添加到我的项目中(我使用的是1.0.9),但我仍然提示该消息并且我的日志没有运行.

任何人都可以帮我解决这个问题吗?谢谢.

更新:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.employee.scheduler</groupId>
<artifactId>rostering</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>nurserostering</name>

<build>
    <pluginManagement>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <!-- or whatever version you use -->
                    <source>1.7</source>
                    <target>1.7</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <configuration>
                    <archive>
                        <manifest>
                            <!-- Needed for runExamples.sh and runExamples.bat -->
                            <addClasspath>true</addClasspath>
                            <classpathPrefix>../../binaries/</classpathPrefix>
                        </manifest>
                    </archive>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <configuration>
                    <executable>java</executable>
                    <classpathScope>runtime</classpathScope>
                    <arguments>
                        <argument>-Xms256m</argument>
                        <argument>-Xmx1024m</argument>
                        <argument>-server</argument>
                        <argument>-cp</argument>
                        <classpath />
                        <argument>com.employee.scheduler.nurserostering.app.NurseRosteringApp</argument>
                    </arguments>
                </configuration>
            </plugin>
        </plugins>
    </pluginManagement>
</build>

<dependencies>
    <dependency>
        <groupId>org.optaplanner</groupId>
        <artifactId>optaplanner-core</artifactId> …
Run Code Online (Sandbox Code Playgroud)

java logback slf4j maven optaplanner

10
推荐指数
2
解决办法
3841
查看次数

将日历日期转换为 LocalDate

我决定从 5.5 升级到 Optaplanner 7.5 Nurseroster,但遇到了一些愚蠢的问题。下面是一个。我以前使用的例程如下。然而现在新版本需要 LocalDate。我有一个 MySql 数据库后端,用户通过日历选择名册计划计划。任何建议将不胜感激。

int shiftDateSize = maxDayIndex + 1;
        List<ShiftDate> shiftDateList = new ArrayList<ShiftDate>(shiftDateSize);
        //shiftDateMap = new HashMap<String, ShiftDate>(shiftDateSize);
        long id = 0L;
        int dayIndex = 0;
        calendar.setTime(startDate);
        for (int i = 0; i < shiftDateSize; i++) {
            ShiftDate shiftDate = new ShiftDate();
            shiftDate.setId(id);
            shiftDate.setDayIndex(dayIndex);
            **String dateString = dateFormat.format(calendar.getTime());**
            shiftDate.setDateString(dateString);
            **shiftDate.setDayOfWeek(DayOfWeek.valueOfCalendar(calendar.get(Calendar.DAY_OF_WEEK)));**
            shiftDate.setShiftList(new ArrayList<Shift>());
            shiftDateList.add(shiftDate);
            shiftDateMap.put(dateString, shiftDate);
            id++;
            dayIndex++;
            calendar.add(Calendar.DAY_OF_YEAR, 1);
        }
        nurseRoster.setShiftDateList(shiftDateList);
    } 
Run Code Online (Sandbox Code Playgroud)

java optaplanner

8
推荐指数
3
解决办法
2万
查看次数

我如何使用Drools Planner?

我有一个日程安排问题,每个学生表达他对讲座的偏好,同时为所有学生生成课程时间表(如果可能的话,以批处理模式).

根据我的阅读和理解,Drools Planner非常适合解决此类问题.我在我的Eclipse IDE中安装了Drools和GEF.一切都很好.不幸的是,我无法弄清楚如何构建一个简单的项目.

我在网上寻找参考资料,并找到了Drools Planner的例子,这些例子看起来很棒.但是,除了一些代码片段之外,我没有找到任何可以引导人们完成简单案例的好教程.

如何为匹配/日程安排问题建模,其中3名具有独特时间和课程偏好的学生希望注册4门课程?我如何启动代码,在哪里放置约束,我调用哪些类,等等?

任何帮助将不胜感激!!

谢谢!!

java optimization artificial-intelligence drools-planner optaplanner

6
推荐指数
1
解决办法
2577
查看次数

OptaPlanner是否支持对连续变量的优化和约束?

我正在阅读文档中的矛盾内容.

一方面,这段经文似乎表明连续的计划变量是可能的:

计划值范围是计划变量的可能计划值的集合.该集合可以是离散的(例如,行1,2,3或4)或连续的(例如,在0.0和1.0之间的任何双倍).

另一方面,在定义计划变量时,必须ValueRangeProvider在字段上指定要用于值集的注释:

Solution实现具有返回Collection的方法.该集合中的任何值都是此计划变量的可能计划值.

这两个片段都在文档的相同部分(http://docs.jboss.org/drools/release/latest/optaplanner-docs/html_single/#d0e2518)

那么,这是什么?我可以使用full double作为我的计划变量,还是需要将其范围限制为特定值Collection

看看实际的算法,我没有看到任何实际上适合优化连续变量的东西,所以我怀疑它是否可能,但是如果澄清并明确表示它会很好.

optimization rule-engine constraint-programming drools-planner optaplanner

5
推荐指数
1
解决办法
819
查看次数

替代c ++/c#中的drools-planner/optaplanner?

对于C++或C#中的optaplanner/drools planner,是否有类似的替代品?我只发现了2007年的一个非常古老的C#端口.或者你如何解决C++/C#中的NP-hard优化问题?

c++ optimization constraint-programming drools-planner optaplanner

5
推荐指数
1
解决办法
4187
查看次数

OptaPlanner的神话评分腐败

我为我的模型使用增量分数计算器.在"完全断言"模式下优化几小时/几天后,抛出了分数损坏异常:

java.lang.IllegalStateException: Score corruption: the workingScore (-86591/-2765/-422/-591) is not the uncorruptedScore (-86591/-2873/-422/-591) after completedAction [...]:
Uncorrupted: Score calculator 3718238 [schedule=Schedule6422-2015-04-16T09:47:36.932[-86591/-2873/-422/-591], prioritiesScore=-422, timelineGapsScore=-2873, requirementGapsScore=-86591, timelineVersionsScore=-591]
Corrupted: Score calculator 3717237 [schedule=Schedule6422-2015-04-16T09:47:36.932[-86591/-2873/-422/-591], prioritiesScore=-422, timelineGapsScore=-2873, requirementGapsScore=-86591, timelineVersionsScore=-591]
Run Code Online (Sandbox Code Playgroud)

这个分数在参数上有所不同timelineGapsScore.分数实例从分数计算对象字段创建的prioritiesScore,timelineGapsScore,requirementGapsScoretimelineVersionsScore.按日志记录,这两个分数的实例在这些字段中是等效的,但是optaplanner引擎找到差异(-86591/-2765/-422/-591)vs(-86591/-2873/-422/-591).怎么可能?

我怀疑解决方案克隆上的引用泄漏(它是特定的实现并进行深度复制),但仔细的代码检查不会显示此类错误.

UPD:我忘了提及:optaplanner以守护进程模式运行,模型能够实时更改事实.所以我怀疑模型中的竞争条件.但我不知道如何在optaplanner的引擎盖下实现注入变化(文档中的信息不够).

java optimization optaplanner

5
推荐指数
1
解决办法
691
查看次数

如何从 OptaPlanner 升级到 Timefold?

我们不久前将 OptaPlanner 分叉为 Timefold 。我们经常会收到这样的问题:

Timefold 更改所有导入语句和依赖项。如何有效地将 OptaPlanner 代码库迁移到 Timefold?

java optaplanner timefold

5
推荐指数
1
解决办法
481
查看次数