Multiple planning entities for a Multiple-choiche multidimensional Knapsack optaplanner solution - optaplanner

I'm really new to Optaplanner and I'm trying to solve a problem that apparently doesn't fit any of the examples provided in the documentation.
I have a domain model for which multiple ServiceProvider(s) (#PlanningEntity) have to choose one from different SPOption (ProblemFact).
Each SPOption has a list of Container(s) (another #PlanningEntity) that have to be placed in a Server collection (if the option is chosen).
Currently when the solver starts it iterates over all the solution and change the planning variable choosedOption with one of the options provided in the list of options for each SPOption instance.
Though, it never assign to each of the Container instances in the SPOption's collection a Server (another Planning Variable in a different Planning Entity).
I report here a synthetic class model diagram with the annotations I used.
How can I get the solver iterate also on the Container's placing variable Server?
And here there's a pastebin of the solver configuration:
<solver>
<!-- Define the model -->
<!--<scanAnnotatedClasses/>-->
<solutionClass>domain.Fog</solutionClass>
<entityClass>domain.Container</entityClass>
<entityClass>domain.ServiceProvider</entityClass>
<scoreDirectorFactory>
<easyScoreCalculatorClass>score.FogEasyScoreCalculator</easyScoreCalculatorClass>
</scoreDirectorFactory>
<constructionHeuristic>
<queuedEntityPlacer>
<entitySelector id="placerEntitySelector">
<cacheType>PHASE</cacheType>
<entityClass>domain.Container</entityClass>
</entitySelector>
<changeMoveSelector>
<entitySelector mimicSelectorRef="placerEntitySelector"/>
</changeMoveSelector>
</queuedEntityPlacer>
</constructionHeuristic>
<constructionHeuristic>
<queuedEntityPlacer>
<entitySelector id="placerEntitySelector">
<cacheType>PHASE</cacheType>
<entityClass>domain.ServiceProvider</entityClass>
</entitySelector>
<changeMoveSelector>
<entitySelector mimicSelectorRef="placerEntitySelector"/>
</changeMoveSelector>
</queuedEntityPlacer>
</constructionHeuristic>
</solver>

Related

GWT - Multiple modules?

I am struggling in getting the structure of my GWT application right. (Am I the only one one who finds that GWT code very easily ends up very messy and unreadable?)
The application is supposed to be an interface to a couple of quite
distinct areas - let us say area A and B. At the moment i am trying to
implement it as an interface with two tabs - one taking you to area A
and one taking you to area B. I do not see how I can have a nice
separation of the code needed for the two different areas in this way
though - applying the MVP pattern (which I actually do not find that clear how to do in a case of a hierarchic interface like my tabs) I end up having area A and area B
code in for instance both the client.view and the client.presenter
package:
src
- main
- java
- client
+ event
- presenter
+ a_stuff
+ b_stuff
- view
+ a_stuff
+ b_stuff
:
I have not been able to find any good examples of how and when to use multiple
modules and I am wondering if my case might be one where multiple
modules would make sense? How would the code be structured in that case?
Maybe it is relevant to mention that I am using the latest GWT, Maven and IntelliJ IDEA.
Hints would be greatly appreciated,
thanks a lot from Stine :)
Here is a more thorough example that helped me get two modules working:
http://ashtoncthomas.blogspot.com/2011/02/multiple-modules-in-google-web-toolkit.html
It uses the structure:
src
- main
- java
a_stuff.gwt.xml
b_stuff.gwt.xml
- client
- shared_stuff
- a_stuff
- presenter
- view
- b_stuff
- presenter
- view
If you want two HTML pages - one for each module (like I did), then you need to create two pages:
war
page_a.html
page_b.html
And define your entry points in your two .gwt.xml files, for example (for a_stuff.gwt.xml):
<module rename-to='module_a'>
... your stuff here ...
<entry-point class="main.java.client.a_stuff.A_entry_point"></entry-point>
</module>
Where A_entry_point is a class that implements EntryPoint.
Then, in your HTML pages, only include the module you want (for example, in page_a.html):
<script type="text/javascript" language="javascript"
src="module_a/module_a.nocache.js"></script>
Also, if you're using Eclipse, then when you click on "GWT Compile Project", it will ask you to "Add an entry point class", so you must click on the "Add" button in the "Entry Point Modules" section of the GWT Compile window, and add both your entry point modules (a_stuff.gwt.xml and b_stuff.gwt.xml). You can add/remove entry point modules from here as needed, to choose which modules to compile.
The above worked for me. I used it to make two different versions of my website, each in a separate module.
Consider declaring multiple source elements in your yourmodule.gwt.xml file. If no source elements are declared, then by default gwt assumes a "client" declaration. See below:
<!--Default if not declared-->
<source path="client"/>
You can declare multiple source locations like this:
<source path="a_stuff"/>
<source path="b_stuff"/>
Now everything below each source will be compiled. "Client" is only the default, not the rule.
I suggest something like this:
src
- main
- java
+ a_stuff
-client
- presenter
- view
- event
+ b_stuff
-client
- presenter
- view
- event
Have a look at mvp4g
http://code.google.com/p/mvp4g/wiki/MultiModules

How to apply jsf primefaces theme for a single jsf page

I want to apply primefaces Trontastic theme only for one jsf page.
I have read answer give on Applying PrimeFaces theme only for one JSF page
I have done same changes in my code.
I have downloaded and kept trontastic-1.0.10.jar in WEB-INF\lib folder.
Extracted the jar and in the 'resources' folder I created a subfolder called "primefaces-trontastic". In this folder,I have copied the file theme.css from the theme and also the 'images' folder. In my xhtml I have added the below code inside
<h:outputStylesheet library="primefaces-trontastic" name="theme.css" />
But I found no change in my jsf page.
Do I need to do anything more?
I myself did it in a different way (no unzipping, keeping in sync etc... )
PF supports 'dynamic' themes by being able to interpret the theme definition in the web.xml as EL
<context-param>
<param-name>primefaces.THEME</param-name>
<param-value>#{myPreferences.theme}</param-value>
</context-param>
By haveing a 'preferences' bean and setting the theme name in there (see the showcase source code, it does exactely this when using the themeswitcher), you can switch. You can e.g. have a
<f:event type="preRenderView" listener="#{myPreferences.chooseTheme"} />
generically in your template an in the chooseTheme method look at the page that is being loaded and set a theme you want. You could (and I did not try this) maybe have a
<f:event type="preRenderView" listener="#{myPreferences.theme('one')"} />
in the generic template, and in a specific view maybe override it with.
<f:event type="preRenderView" listener="#{myPreferences.theme('two')"} />
But I'm not sure if this latter works

Is Boostrap compatible with Struts 2?

I am using Bootstrap for my UI development. When I use Struts 2 tags for textfield in it, the complete page alignment is destroyed. When I replace the s: (Struts 2 tags) tags with normal tags, it is working fine.
Do I need to include any extra jar?
Solution n.1:
Use the simple theme and write the Bootstrap-compliant HTML on your own:
<constant name="struts.ui.theme" value="simple" />
Solution n.2:
Use the Struts2 Boostrap plugin (showcase) and the bootstrap theme and let it automatically generate the Bootstrap-compliant HTML from Struts tags:
<constant name="struts.ui.theme" value="bootstrap" />
Struts 2 uses themes while rendering output of the JSP page. You can read more about themes in Struts 2 Themes. To change a default theme put this in the struts.xml
<constant name="struts.ui.theme" value="simple"/>

how to use prime faces extensions jar file in netbeans webapplication project

I am trying to use exporter feature of primefaces extension so that i can export multiple tables at a time but . I am getting following error :
The prefix "pe" for element "pe"dataExporter" is not bound.
code goes here
<h:commandLink>
<p:graphicImage value="../resources/images/excel.png" title=""/>
<pe:dataExporter type="xls" target="dailyShtSts" fileName="DailyCheckList" postProcessor="#{supportCrmIssuesTabController.postProcessXLS}"/>
</h:commandLink>
Are you declared xmlns:pe="http://primefaces.org/ui/extensions" on the tag html?
Anyway you must declare this and add the jars(org.apache... poi-xxx; poi-excelant-xxx; poi-ooxml-xxx; poi-scratchpad-xxx; and the xmlbeans-xxx) at java build path.
PS: xxx represents the version of the jar file.

Graphic Image would not able to pick image based upon theme

I have 3 different Theme in my project . All themes are working fine after changes context -param value into web.xml
it is like my current theme is
<context-param>
<param-name>primefaces.THEME</param-name>
<param-value>NSFPortalGreenTheme</param-value>
</context-param>
But during theme change ,I found that primefaces is unable to get the image from IMAGE folder of current theme
I have a code line for image is as below
<p:graphicImage library="images" alt="NSF" name="logo.png"></p:graphicImage>
How to pick images in different Theme.
Make sure you have primefaces 3.4+ as the library and name attributes were added only in version 3.4.
The directory structure should be something like this:
--resources
----theme1
-------images
----theme2
-------images
and then you can use specify the library name as the theme name in the <p:graphicImage> library attribute like this:
<p:graphicImage library="theme1" alt="NSF" name="images/logo.png" />

Resources