League Champions
Home
Champions
Stats
List
Spotlight
Meta
Pro Picks
Art
Fan Art
Splash Art
Video Art
Gifs
Video Stills
About Us
Kayn Champion Spotlight
Your browser does not support HTML5 video.


{% block alpha_banner %}
{% include "includes/phase_banner_alpha.html" %}
{% endblock %}
Icons
This is the full set of Home Office icons. Add to the Trello board if there is an icon you would like to contribute to the set.
Quick links
More about why we use icons
The benefit of icons are categorised as
- helping users navigate through the service
- controllers to help users to sort, organise and adjust the information in the service, this can be a filter, closing modals or revealing addition content
- quick reference is the most subjective area and is relevant to the users, frequency of interaction with the service and reason for needing a quick reference icon/image.
The risk with using icons for quick reference is that users won't understand or misinterpret what the reference is. The options are similar and therefore either the same icons are used or additional icons are needed with only slight changes which are hard to differentiate and increase cognitive load and reduce comprehension.
Identifying whether your icons fit into one of these uses will help to answer whether it's appropriate to use it.
Navigation icons
| Icon |
Label |
Variable |
|
Home |
@hod-home |
|
Search |
@hod-search |
|
Login |
@hod-key |
|
Left |
@hod-arrow-left |
|
Down |
@hod-arrow-down |
|
Right |
@hod-arrow-right |
|
Up |
@hod-arrow-up |
Controller icons
| Icon |
Label |
Variable |
|
Zoom in |
@hod-search-plus |
|
Zoom out |
@hod-search-minus |
|
Left, Back |
@hod-chevron-left |
|
Right, Continue |
@hod-chevron-right |
|
Up, Close |
@hod-chevron-up |
|
Down, Expand |
@hod-chevron-down |
|
Add, Open |
@hod-plus |
|
Minus, Close |
@hod-minus |
|
Approved, Correct, Confirm |
@hod-checkmark |
|
Close, Delete, Remove |
@hod-cross |
Quick reference icons
| Icon |
Label |
Variable |
|
Location |
@hod-map-marker |
|
Settings |
@hod-cog |
|
Message, Chat, Comment |
@hod-comment |
|
Call |
@hod-phone |
|
Delete |
@hod-trash |
|
Image, Photo |
@hod-image |
|
Film, Video |
@hod-film |
|
File, Document |
@hod-file-empty |
|
Time |
@hod-clock |
|
Calendar, Date |
@hod-calendar |
|
Print |
@hod-printer |
|
Mobile |
@hod-mobile |
|
Link |
@hod-link |
|
Warning, Alert |
@hod-warning |
|
Info, Information |
@hod-info-circle |
|
Edit, Change |
@hod-pencil |

Content patterns
- any icon should use a visible and audible label to avoid confusion over what it is representing
- align icon in a central position in relation to any type
- type can sit to the left or right hand side of the icon
Interaction patterns
- minimum size for an icon is 16px
- if it's part of a button the hit area should be 36px
- the icon shouldn't change colour in a hover/active/focus states, only the background
- in the normal state, the icon can be a different colour using the GOV.UK colour palette - both in solid and reversed out state - as long as the colour combination meets the minimum WCAG 2.0 AA colour contrast check
Inclusive patterns
User research
- icons have proved supportive with the deaf community, as BSL is a visual method of communication
Services using this pattern
- Application platform
- Entities
Things to do
- more user research
- more access needs research including cognition and comprehension
- more research using icons as
:before
content on buttons
- greater knowledge of what icons are used within icon libraries (don't use them all)
- feedback on designer/developer needs
- clarity on alignment, padding and size for touchscreen hit area
- include in sketch file
{% endblock %}


Please wait...
You have 4 new Notifications
Campaign
Holiday Sale
is nearly reach budget limit.
10:00 AM Today
See all notifications
Welcome,
Student
Exp
14
Awards
13
Clients
213
Dashboard
Lecture Notes
Current Semester
Other Semesters
GPA Calculation
Assignments
Quizzes
Attendance
Marks
Chat-Box
Other
Medical
Staff
Noticeboard
Student Details
Choose Intake
Select Degree Programme
Select RegNO
Details of Medical Certificate
Select Type
Government
Private
Ayurvedic
Other
to
Choose file
Upload Medical
Reset Form


MARIA ™
Logged in as
Physician
MARIA
Artificial Intelligence Research Assistant for Medicine
Physician
Scientist
Leaderboard
Blockchain View
FHIR Viewer
Create Competition
Initiate Competition Factory
Prize
Deadline
Submit Training Set
Submit Test Set
Submit Test Outcome
Competitions
Description
Id
Prize
Deadline
Dataset
Submit Model
Execute Payouts
CompetitionId
Prize
Winner
Event
CompetitionId
Actor
Data
Cost
Timestamp


Extends the class object with class and instance accessors for class attributes, just like the native attr* accessors for instance attributes.
Defines both class and instance accessors for class attributes.
class Person cattr_accessor :hair_colors end Person.hair_colors = [:brown, :black, :blonde, :red] Person.hair_colors # => [:brown, :black, :blonde, :red] Person.new.hair_colors # => [:brown, :black, :blonde, :red]
If a subclass changes the value then that would also change the value for parent class. Similarly if parent class changes the value then that would change the value of subclasses too.
class Male < Person end Male.hair_colors << :blue Person.hair_colors # => [:brown, :black, :blonde, :red, :blue]
To opt out of the instance writer method, pass :instance_writer => false. To opt out of the instance reader method, pass :instance_reader => false.
class Person cattr_accessor :hair_colors, :instance_writer => false, :instance_reader => false end Person.new.hair_colors = [:brown] # => NoMethodError Person.new.hair_colors # => NoMethodError
Or pass :instance_accessor => false, to opt out both instance methods.
class Person cattr_accessor :hair_colors, :instance_accessor => false end Person.new.hair_colors = [:brown] # => NoMethodError Person.new.hair_colors # => NoMethodError
Also you can pass a block to set up the attribute with a default value.
class Person cattr_accessor :hair_colors do [:brown, :black, :blonde, :red] end end Person.class_variable_get("@@hair_colors") #=> [:brown, :black, :blonde, :red]
# File lib/active_support/core_ext/class/attribute_accessors.rb, line 164 def cattr_accessor(*syms, &blk) cattr_reader(*syms) cattr_writer(*syms, &blk) end
Defines a class attribute if it’s not defined and creates a reader method that returns the attribute value.
class Person cattr_reader :hair_colors end Person.class_variable_set("@@hair_colors", [:brown, :black]) Person.hair_colors # => [:brown, :black] Person.new.hair_colors # => [:brown, :black]
The attribute name must be a valid method name in Ruby.
class Person cattr_reader :"1_Badname " end # => NameError: invalid attribute name
If you want to opt out the instance reader method, you can pass :instance_reader => false or :instance_accessor => false.
class Person cattr_reader :hair_colors, :instance_reader => false end Person.new.hair_colors # => NoMethodError
# File lib/active_support/core_ext/class/attribute_accessors.rb, line 32 def cattr_reader(*syms) options = syms.extract_options! syms.each do |sym| class_eval( unless defined? @@#{sym} @@#{sym} = nil end def self.#{sym} @@#{sym} end, __FILE__, __LINE__ + 1) unless options[:instance_reader] == false || options[:instance_accessor] == false class_eval( def #{sym} @@#{sym} end, __FILE__, __LINE__ + 1) end end end
Defines a class attribute if it’s not defined and creates a writer method to allow assignment to the attribute.
class Person cattr_writer :hair_colors end Person.hair_colors = [:brown, :black] Person.class_variable_get("@@hair_colors") # => [:brown, :black] Person.new.hair_colors = [:blonde, :red] Person.class_variable_get("@@hair_colors") # => [:blonde, :red]
The attribute name must be a valid method name in Ruby.
class Person cattr_writer :"1_Badname " end # => NameError: invalid attribute name
If you want to opt out the instance writer method, pass :instance_writer => false or :instance_accessor => false.
class Person cattr_writer :hair_colors, :instance_writer => false end Person.new.hair_colors = [:blonde, :red] # => NoMethodError
Also, you can pass a block to set up the attribute with a default value.
class Person cattr_writer :hair_colors do [:brown, :black, :blonde, :red] end end Person.class_variable_get("@@hair_colors") # => [:brown, :black, :blonde, :red]
# File lib/active_support/core_ext/class/attribute_accessors.rb, line 92 def cattr_writer(*syms) options = syms.extract_options! syms.each do |sym| class_eval( unless defined? @@#{sym} @@#{sym} = nil end def self.#{sym}=(obj) @@#{sym} = obj end, __FILE__, __LINE__ + 1) unless options[:instance_writer] == false || options[:instance_accessor] == false class_eval( def #{sym}=(obj) @@#{sym} = obj end, __FILE__, __LINE__ + 1) end self.send("#{sym}=", yield) if block_given? end end
Declare a class-level attribute whose value is inheritable by subclasses. Subclasses can change their own value and it will not impact parent class.
class Base class_attribute :setting end class Subclass < Base end Base.setting = true Subclass.setting # => true Subclass.setting = false Subclass.setting # => false Base.setting # => true
In the above case as long as Subclass does not assign a value to setting by performing Subclass.setting = something , Subclass.setting would read value assigned to parent class. Once Subclass assigns a value then the value assigned by Subclass would be returned.
This matches normal Ruby method inheritance: think of writing an attribute on a subclass as overriding the reader method. However, you need to be aware when using class_attribute with mutable structures as Array or Hash. In such cases, you don’t want to do changes in places but use setters:
Base.setting = [] Base.setting # => [] Subclass.setting # => [] # Appending in child changes both parent and child because it is the same object: Subclass.setting << :foo Base.setting # => [:foo] Subclass.setting # => [:foo] # Use setters to not propagate changes: Base.setting = [] Subclass.setting += [:foo] Base.setting # => [] Subclass.setting # => [:foo]
For convenience, a query method is defined as well:
Subclass.setting? # => false
Instances may overwrite the class value in the same way:
Base.setting = true object = Base.new object.setting # => true object.setting = false object.setting # => false Base.setting # => true
To opt out of the instance reader method, pass :instance_reader => false.
object.setting # => NoMethodError object.setting? # => NoMethodError
To opt out of the instance writer method, pass :instance_writer => false.
object.setting = false # => NoMethodError
# File lib/active_support/core_ext/class/attribute.rb, line 68 def class_attribute(*attrs) options = attrs.extract_options! instance_reader = options.fetch(:instance_reader, true) instance_writer = options.fetch(:instance_writer, true) attrs.each do |name| class_eval def self.#{name}() nil end def self.#{name}?() !!#{name} end def self.#{name}=(val) singleton_class.class_eval do remove_possible_method(:#{name}) define_method(:#{name}) { val } end if singleton_class? class_eval do remove_possible_method(:#{name}) def #{name} defined?(@#{name}) ? @#{name} : singleton_class.#{name} end end end val end if instance_reader remove_possible_method :#{name} def #{name} defined?(@#{name}) ? @#{name} : self.class.#{name} end def #{name}? !!#{name} end end, __FILE__, __LINE__ + 1 attr_writer name if instance_writer end end
Classes are not duplicable:
c = Class.new # => #<Class:0x10328fd80> c.dup # => #<Class:0x10328fd80>
Note dup returned the same class object.
# File lib/active_support/core_ext/object/duplicable.rb, line 91 def duplicable? false end
# File lib/active_support/core_ext/class/delegating_attributes.rb, line 7 def superclass_delegating_accessor(name, options = {}) # Create private _name and _name= methods that can still be used if the public # methods are overridden. This allows _superclass_delegating_accessor("_#{name}") # Generate the public methods name, name=, and name? # These methods dispatch to the private _name, and _name= methods, making them # overridable singleton_class.send(:define_method, name) { send("_#{name}") } singleton_class.send(:define_method, "#{name}?") { !!send("_#{name}") } singleton_class.send(:define_method, "#{name}=") { |value| send("_#{name}=", value) } # If an instance_reader is needed, generate methods for name and name= on the # class itself, so instances will be able to see them define_method(name) { send("_#{name}") } if options[:instance_reader] != false define_method("#{name}?") { !!send("#{name}") } if options[:instance_reader] != false end
Generated with the Darkfish Rdoc Generator 2.


Configuration
In order to start using babelsheet, you have to configure your .env.babelsheet
file first. If you want, you can keep envs in .env
file, all variables stored in .env
will be overwritten by those stored in .env.babelsheet
.
Configuration file
BABELSHEET_CLIENT_ID=<GOOGLE-CLIENT-ID>
BABELSHEET_CLIENT_SECRET=<GOOGLE-CLIENT-SECRET>
BABELSHEET_SPREADSHEET_ID=<SPREADSHEET-ID>
BABELSHEET_SPREADSHEET_NAME=<SPREADSHEET-NAME>
BABELSHEET_REFRESH_TOKEN=<REFRESH-TOKEN>
BABELSHEET_REDIRECT_URI=http://localhost:3000/oauth2callback
BABELSHEET_REDIS_HOST=redis
BABELSHEET_REDIS_PORT=6379
BABELSHEET_HOST=localhost
BABELSHEET_PORT=3000
NODE_ENV=dev
APP_NAME=babelsheet-node
LOGGING_LEVEL=debug
Configuration options
BABELSHEET_CLIENT_ID
* - client id received from Google (see how to config)
BABELSHEET_CLIENT_SECRET
* - client secret received from Google (see how to config)
Spreadsheet ID can be taken from spreadsheet url. It's the part after BABELSHEET_SPREADSHEET_ID
* - spreadsheet ID from spreadsheet URL
How to get spreadsheet ID
/d/
sign:
https://docs.google.com/spreadsheets/d/<spreadsheet-id>/
Spreadsheet name is the name of the tab in spreadsheet document.
BABELSHEET_SPREADSHEET_NAME
* - sheet name
How to get spreadsheet name
BABELSHEET_REFRESH_TOKEN
* - refresh token (see how to obtain)
BABELSHEET_REDIRECT_URI
- url to which user should be redirected after receiving refresh token
BABELSHEET_REDIS_HOST
- host name of redis store
BABELSHEET_REDIS_PORT
- port of redis store
BABELSHEET_HOST
- host name for winston
BABELSHEET_PORT
- API port
NODE_ENV
- environment type
APP_NAME
- name which indentify app
LOGGING_LEVEL
- Log level debug/error/info
* - required
Configuring Google Spreadsheet API
- Create account in Google Cloud Platform.
Creating account in details
Go to https://cloud.google.com/. Click Try free, then fill the form, next click Agree and continue and Submit.
- Create a project in Google Cloud Platform and enable Google Sheets API usage (section API & Services dashboard).
Creating project with enable API in details
Go to https://console.cloud.google.com. Click Select a project, then NEW PROJECT, write name of the project and click CREATE.
Choose API.
Click ENABLE APIS AND SERVICES.
Find Google sheets.
Click Enable.
- Go to section Create credendials and fill in the form with proper product name, e-mail address, redirect uri as
http://localhost:3000/oauth2callback
then click Done.Creating credentials in details
From previous view, select Create credentials.
Fill the form and click Done.
IMPORTANT! Remember to add
http://localhost:3000/oauth2callback
to 'Authorised redirect URIs', you can add any other redirect uri, later passing it asBABELSHEET_REDIRECT_URI
in .env.babelsheet file. - You will be given Client ID and Client secret keys, use them in environment variables
BABELSHEET_CLIENT_ID
andBABELSHEET_CLIENT_SECRET
in.env.babelsheet
file. - You can get your spreadsheet ID and spreadsheet name, then you will be ready to generate translations.
Generating refresh token
- To generate refresh token, you have to configure Google Spreadsheet API first.
- When
BABELSHEET_CLIENT_ID
andBABELSHEET_CLIENT_SECRET
are stored in.env.babelsheet
file, you are ready to generate refresh-token. -
Run
babelsheet init
.If babelsheet is not installed, run
npm i -g babelsheet
to install.BABELSHEET_CLIENT_ID and BABELSHEET_CLIENT_SECRET as params
You don't have to create .env.babelsheet file, you can pass BABELSHEET_CLIENT_ID and BABELSHEET_CLIENT_SECRET values as parameters to babelsheet:
npm generate --client_id <yours-client-id> --client_secret <yours-client-secret>
Config in json file
You can also generate token in
data.json
file, just by passingjson
parameter optionnpm init --config-format json
. -
Browser window will be opened automatically. Log in into you Google account and then grant your application an access for reading spreadsheets in your account. You should be given a message
Authentication successful! Please return to the console
. - Refresh token is now stored in
.env.babelsheet
file. You can change storage type here. - More actions won't be needed because tokens will be refreshed automatically if necessary.


Component Diagram - AC System POC Components link
| Jump to: |
| Model Elements |
| Name | Description | ||
|
|
|||
|
|
Node.js application using the following tech stack
- express for HTTP support including authentication - socket.io for websockets support - rrdtool and standard file IO for reading sensor data - redis for pubsub/alerts
Session data must be encoded in the cookies, no session state will be held in the application or redis |
||
|
|
Ruby application using the following
- eventmachine for the web server - thin or similar web server - grape for REST API - grape-swagger for API documentation - rrd-ffi for writing sensor data to files |
||
|
|
|||
|
|
|||
|
|
|||
|
|
Stores data from devices in round-robin archives to allow results to be fetched and graph data to be generated in the front end |
||
|
|
|||
|
|
Can store device tokens for login as well as providing a service for pub/sub communication between the device API service and front end to send notification of alerts which can then be retrieved. Alerts can be stored here per device also. Need also a list of alerting devices here too |
||
|
|
|||
|
|
Use websockets for real time alerts. When scaling the notifications will rely on the alerts being sent to all nodes using pub/sub.
The client websocket connection also needs some form of keep-alive message so that fail-over to other nodes can be carried out by reconnecting if the current host goes down.
The websocket connection does pin the client to a given node though |


--- title: "My R Packages" author: "Remko Duursma" date: 2017-11-10 categories: ["R"] description: An index of my R packages, with links to documentation, source code, and publications or examples. ---
A somewhat comprehensive list of the R packages that I have developed over the years.
Analysis of leaf gas exchange. Fit A-Ci curves, simulate from the coupled leaf gas exchange model, fit Ball-Berry models of stomatal conductance, and more. Read open-access publication describing plantecophys.
Analysis and visualization of plant hydraulics data. Fit PLC curves to estimate P50 and related parameters, report uncertainty via bootstrap resampling, incorporate random effects, and more. Read open-access publication describing fitplc.
A very popular R package, the methods were developed by David Warton and described in this publication. Use the package to fit allometric relationships, used in many biological applications and even river networks on Mars.
Obtain species occurrence data from one of two web services, download corresponding climate data from WorldClim, rasterize occurrences, calculate climate envelopes. See here for an example demonstration.
Implementation of a functional-structural plant model, coupling plant architecture (Y-Plant) to the QuasiMC ray-tracer (developed by Mik Cieslak). Calculate radiative transfer in 3D plant canopies, estimate photosynthesis and transpiration for each leaf. I used this package in this publication. The package was recently removed from CRAN, the registration of Fortran code in the package turned into a bit of an annoyance.
Wrapper functions for the Maespa model, a detailed model to estimate vegetation water use and carbon uptake, and hydraulics of the soil-to-plant pathway. Read further on my website on the Maespa model.
Analysis of phenocam images for greenness. Uses the imager
R package to calculate greenness indices, as used to record phenology of leaf growth and senescence, with convenient functions to analyze many images, extract time and date of images, etc.
Calculate confidence intervals for predictions from linear mixed-effects models with the bootstrap, implemented as a wrapper around the bootMer
function. Read further in this blog post.


--- layout: post title: 노블리스 오블리주 date: 2011-04-01 13:24:20.000000000 +09:00 type: post parent_id: '0' published: true password: '' status: publish categories: [] tags: [] meta: _original_post_id: '48076980' _original_import_author: sheepless_ original_post_id: '48076980' _wp_old_slug: '48076980' author: login: mouthless email<EMAIL_ADDRESS>display_name: mouthless first_name: '' last_name: '' excerpt: Taken with picplz. ---
Taken with picplz.


import heapq class Solution: def eatenApples(self, apples: List[int], days: List[int]) -> int: n = len(apples) heap = [] ans = 0 now = 0 while now < n or heap: # 先接收当天的苹果 if now < n: heapq.heappush(heap, (now + days[now], apples[now])) # 再腐烂旧苹果 while heap and (heap[0][0] <= now or heap[0][1] == 0): heapq.heappop(heap) if heap: heap[0] = (heap[0][0], heap[0][1] - 1) ans += 1 now += 1 return ans


{{Waterloo}}
One of our goals this year was to engineer a version of the Cas9 protein that could recognize different protospacer adjacent motifs (PAMs) other than the regular NGG. Kleinstiver et al. recently published data on Cas9 mutants that effectively cut unique PAM sites. A specific EQR variant in the publication recognized a NGAG PAM site after three different amino acids in the original Cas9 were changed. The EQR variant includes the changes D1135E, R1335Q, and T1337R. Our goal was to try and replicate these mutations but instead with dCas9, which is commonly used since it represses a gene rather than cutting one. Target sites were designed in promoters of green fluorescent protein (GFP) with both an NGG PAM sequence and an NGAG PAM sequence.
All of our experiments to study GFP expression with and without addition of dCas9 were performed on the Amnis Image Stream machine (Amnis 2015). The Image Stream is a fluorescence microscope combined with a flow cytometer, letting one to perform a quantitative method of fluorescence detection while visualizing the actual cells. By measuring an average fluorescence intensity of cells, we can determine the average intensity of a cell population.
Our first step was to create the EQR variant in dCas9 by using site directed mutagenesis. This was done on a dCas9 plasmid ordered from AddGene. Two other plasmids were constructed with both a gene producing GFP and an sgRNA target recognizing either an NGG or an NGAG PAM site on the GFP promoter J23101.
The first experiment that was performed was to co-transform a plasmid containing both GFP and the sgRNA targeting the GFP promoter into the same cell as dCas9. This was a control experiment that will explain that the mutated EQR dCas9 performs worse than the original dCas9 when targeting an NGG PAM site.
The next experiment involved transforming the plasmid with GFP and an sgRNA targeting a region in the GFP promoter with an NGAG PAM site into E. coli. This was also co-transformed with both the orignial and the mutated versions of dCas9. This time, we expect to see the mutated EQR dCas9 perform better than the original in terms of repression of GFP.
The EQR muatated dCas9 was successfully constructed using the QuickChange protocol twice and sending for sequencing. Co-transformations were also accomplished and cells were analyzed using Flow cytometry.
These graphs show the results of the mean of the GFP intensity when the co-transformed cells were run on flow cytometry. A lower mean points to the result that the dCas9 is more effective at repressing expression of GFP. These results are inconclusive and we need to repeat the experiment multiple times to understand the effect of the EQR mutations on dCas9.


If you you are interested in learning HTML then you are in right place
Meet the team of our website
roll no-1728103
Cover page and linking of other pages
Topic-Forms
Topic-Lists
Roll no-1728100
Topic-HTML Input types
Topic-HTML Links
Topic-Framsets
Topic-StyleSheets
topic-Text Formatting
Topic-Headings
Roll no-1728094
Topic-Tables
Coordinator
Change your life today. ...
All THE BEST
We are Sorry for the inconvenience...


Introduction to Programming Stage 0
The web is made up of a Collection of HTML documents. (Hypertext Markup Language)
All types of files can be found on the web but HTML is the main type of content
HTML (Hypertext Markup Language)
HTML is made up of:
Text content – What you see.
Markup – what it looks like.
References to other documents – pictures, movies etc.
Links to other pages.
HTML Markup: Structeral makeup is of TAGS, Elements and Attributes
HTML Structural Vocabulary
Tag: Contained within brackets (>) most tags have an opening and closing.  There are some tags that don't require a closing like the line break tag "br".
Elements:This refers to everything withing the set of opening and closing tags.
Attributes:This is a variable contained within the HTML element.
< TAG ATTR=”Value”> contents < /TAG >
"a" The anchor tag is for making links.Attribute Example: (This website is < a href="www.udacity.com">my favorite< /a>) Will be seen as : This website is my favorite
IMAGE TAG : "img" for including images. No closing tag needed for images.
Image example < img src=”url” alt=”text” >
Img = image tag
Src = source This is the location of the image file.
url = link to image
alt = alternate attribute this contains text that will be displayed in case the image fails to load
Whitespace
HTML doesn’t recognize white space. You need to create it.
"br" tag break (void)
"p" paragraph
Inline vs. Block TAG
"br" Is an inline tag. Inline tags just manipulat code at the line. Other inline tags (b, em, img)
"p" Is a block tag. Blog tags create a scalable bloc of code to manipulate.
SPAN / DIV
text< /span> (inline)
div:
HTML Documents


Libraries store the energy that fuels the imagination. They open up windows to the world and inspire us to explore and achieve, and contribute to improving our quality of life-Sidney Sheldon
To build up a library is to create a life. It’s never just a random collection of books-Carlos María Domínguez


Last updated: 9/10/2013
FXML is a scriptable, XML-based markup language for constructing Java object graphs. It provides a convenient alternative to constructing such graphs in procedural code, and is ideally suited to defining the user interface of a JavaFX application, since the hierarchical structure of an XML document closely parallels the structure of the JavaFX scene graph.
This document introduces the FXML markup language and explains how it can be used to simplify development of JavaFX applications.
In FXML, an XML element represents one of the following:
Class instances, instance properties, static properties, and define blocks are discussed in this section below. Scripting is discussed in a later section.
Class instances can be constructed in FXML in several ways. The most common is via instance declaration elements, which simply create a new instance of a class by name. Other ways of creating class instances include referencing existing values, copying existing values, and including external FXML files. Each is discussed in more detail below.
<?import javafx.scene.control.Label?>
This PI imports all classes from the javafx.scene.control package into the current namespace:
<?import javafx.scene.control.*?>
<?import javafx.scene.control.Label?> <Label text="Hello, World!"/>
Note that the Label’s "text" property in this example is set using an XML attribute. Properties can also be set using nested property elements. Property elements are discussed in more detail later in this section. Property attributes are discussed in a later section.
Classes that don't conform to Bean conventions can also be constructed in FXML, using an object called a "builder". Builders are discussed in more detail later.
Internally, the FXML loader uses an instance of com.sun.javafx.fxml.BeanAdapter to wrap an instantiated object and invoke its setter methods. This (currently) private class implements the java.util.Map interface and allows a caller to get and set Bean property values as key/value pairs.
<HashMap foo="123" bar="456"/>
<String fx:value="Hello, World!"/> <Double fx:value="1.0"/> <Boolean fx:value="false"/>
Custom classes that define a static valueOf(String) method can also be constructed this way.
<FXCollections fx:factory="observableArrayList"> <String fx:value="A"/> <String fx:value="B"/> <String fx:value="C"/> </FXCollections>
Builder support in FXML is provided by two interfaces. The javafx.util.Builder interface defines a single method named build() which is responsible for constructing the actual object:
public interface Builder<T> { public T build(); }
A javafx.util.BuilderFactory is responsible for producing builders that are capable of instantiating a given type:
public interface BuilderFactory { public Builder<?> getBuilder(Class<?> type); }
A default builder factory, JavaFXBuilderFactory, is provided in the javafx.fxml package. This factory is capable of creating and configuring most immutable JavaFX types. For example, the following markup uses the default builder to create an instance of the immutable javafx.scene.paint.Color class:
<Color red="1.0" green="0.0" blue="0.0"/>
Note that, unlike Bean types, which are constructed when the element's start tag is processed, objects constructed by a builder are not instantiated until the element's closing tag is reached. This is because all of the required arguments may not be available until the element has been fully processed. For example, the Color object in the preceding example could also be written as:
<Color> <red>1.0</red> <green>0.0</green> <blue>0.0</blue> </Color>
The Color instance cannot be fully constructed until all three of the color components are known.
When processing markup for an object that will be constructed by a builder, the Builder instances are treated like value objects - if a Builder implements the Map interface, the put() method is used to set the builder's attribute values. Otherwise, the builder is wrapped in a BeanAdapter and its properties are assumed to be exposed via standard Bean setters.
The <fx:include> tag creates an object from FXML markup defined in another file. It is used as follows:
<fx:include source="filename"/>
where filename is the name of the FXML file to include.
For example, given the following markup:
<?import javafx.scene.control.*?> <?import javafx.scene.layout.*?> <VBox xmlns:fx="http://javafx.com/fxml"> <children> <fx:include source="my_button.fxml"/> </children> </VBox>
If my_button.fxml contains the following:
<?import javafx.scene.control.*?> <Button text="My Button"/>
the resulting scene graph would contain a VBox as a root object with a single Button as a child node.
Note the use of the "fx" namespace prefix. This is a reserved prefix that defines a number of elements and attributes that are used for internal processing of an FXML source file. It is generally declared on the root element of a FXML document. Other features provided by the "fx" namespace are described in the following sections.
<fx:include> also supports attributes for specifying the name of the resource bundle that should be used to localize the included content, as well as the character set used to encode the source file. Resource resolution is discussed in a later section.
<fx:include source="filename" resources="resource_file" charset="utf-8"/>
<Button> <minHeight><Double fx:constant="NEGATIVE_INFINITY"/></minHeight> </Button>
For example, the following markup assigns a previously-defined Image instance named "myImage" to the "image" property of an ImageView control:
<ImageView> <image> <fx:reference source="myImage"/> </image> </ImageView>
Note that, since it is also possible to dereference a variable using the attribute variable resolution operator (discussed later in the Attributes section), fx:reference is generally only used when a reference value must be specified as an element, such as when adding the reference to a collection:
<ArrayList> <fx:reference source="element1"/> <fx:reference source="element2"/> <fx:reference source="element3"/> </ArrayList>
For most other cases, using an attribute is simpler and more concise.
At the moment, no JavaFX platform classes provide such a copy constructor, so this element is provided primarily for use by application developers. This may change in a future release.
Elements whose tag names begin with a lowercase letter represent object properties. A property element may represent one of the following:
For example, the following FXML creates an instance of the Label class and sets the value of the label's "text" property to "Hello, World!":
<?import javafx.scene.control.Label?> <Label> <text>Hello, World!</text> </Label>
This produces the same result as the earlier example which used an attribute to set the "text" property:
<?import javafx.scene.control.Label?> <Label text="Hello, World!"/>
Property elements are generally used when the property value is a complex type that can't be represented using a simple string-based attribute value, or when the character length of the value is so long that specifying it as an attribute would have a negative impact on readability.
The FXML loader uses the coerce() method of BeanAdapter to perform any required type conversions. This method is capable of performing basic primitive type conversions such as String to boolean or int to double, and will also convert String to Class or String to Enum. Additional conversions can be implemented by defining a static valueOf() method on the target type.
For example, the "children" property of javafx.scene.Group is a read-only list property representing the group's child nodes:
<?import javafx.scene.*?> <?import javafx.scene.shape.*?> <Group xmlns:fx="http://javafx.com/fxml"> <children> <Rectangle fx:id="rectangle" x="10" y="10" width="320" height="240" fill="#ff0000"/> ... </children> </Group>
As each sub-element of the <children> element is read, it is added to the list returned by Group#getChildren().
The "properties" property of javafx.scene.Node is an example of a read-only map property. The following markup sets the "foo" and "bar" properties of a Label instance to "123" and "456", respectively:
<?import javafx.scene.control.*?> <Button> <properties foo="123" bar="456"/> </Button>
For example, since javafx.scene.layout.Pane (the superclass of javafx.scene.layout.VBox) defines a default property of "children", a <children> element is not required; the loader will automatically add the sub-elements of the VBox to the container's "children" collection:
<?import javafx.scene.*?> <?import javafx.scene.shape.*?> <VBox xmlns:fx="http://javafx.com/fxml"> <Button text="Click Me!"/> ... </VBox>
Note that default properties are not limited to collections. If an element's default property refers to a scalar value, any sub-element of that element will be set as the value of the property.
For example, since javafx.scene.control.ScrollPane defines a default property of "content", a scroll pane containing a TextArea as its content can be specified as follows:
<ScrollPane> <TextArea text="Once upon a time..."/> </ScrollPane>
Taking advantage of default properties can significantly reduce the verbosity of FXML markup.
Static properties are prefixed with the name of class that defines them. For example, The following FXML invokes the static setter for GridPane's "rowIndex" and "columnIndex" properties:
<GridPane> <children> <Label text="My Label"> <GridPane.rowIndex>0</GridPane.rowIndex> <GridPane.columnIndex>0</GridPane.columnIndex> </Label> </children> </TabPane>
This translates roughly to the following in Java:
GridPane gridPane = new GridPane(); Label label = new Label(); label.setText("My Label"); GridPane.setRowIndex(label, 0); GridPane.setColumnIndex(label, 0); gridPane.getChildren().add(label);The calls to GridPane#setRowIndex() and GridPane#setColumnIndex() "attach" the index data to the Label instance. GridPane then uses these during layout to arrange its children appropriately. Other containers, including AnchorPane, BorderPane, and StackPane, define similar properties.
As with instance properties, static property elements are generally used when the property value cannot be efficiently represented by an attribute value. Otherwise, static property attributes (discussed in a later section) will generally produce more concise and readable markup.
For example, when working with radio buttons, it is common to define a ToggleGroup that will manage the buttons' selection state. This group is not part of the scene graph itself, so should not be added to the buttons' parent. A define block can be used to create the button group without interfering with the overall structure of the document:
<VBox> <fx:define> <ToggleGroup fx:id="myToggleGroup"/> </fx:define> <children> <RadioButton text="A" toggleGroup="$myToggleGroup"/> <RadioButton text="B" toggleGroup="$myToggleGroup"/> <RadioButton text="C" toggleGroup="$myToggleGroup"/> </children> </VBox>
Elements in define blocks are usually assigned an ID that can be used to refer to the element's value later. IDs are discussed in more detail in later sections.
An attribute in FXML may represent one of the following:
Each are discussed in more detail in the following sections.
<?import javafx.scene.control.*?> <Button text="Click Me!"/>
<Rectangle fx:id="rectangle" x="10" y="10" width="320" height="240" fill="#ff0000"/>
Unlike property elements, which are applied as they are processed, property attributes are not applied until the closing tag of their respective element is reached. This is done primarily to facilitate the case where an attribute value depends on some information that won't be available until after the element's content has been completely processed (for example, the selected index of a TabPane control, which can't be set until all of the tabs have been added).
Another key difference between property attributes and property elements in FXML is that attributes support a number of "resolution operators" that extend their functionality. The following operators are supported and are discussed in more detail below:
For example, the following markup creates an ImageView and populates it with image data from my_image.png, which is assumed to be located at a path relative to the current FXML file:
<ImageView> <image> <Image<EMAIL_ADDRESS></image> </ImageView>
Since Image is an immutable object, a builder is required to construct it. Alternatively, if Image were to define a valueOf(URL) factory method, the image view could be populated as follows:
<ImageView<EMAIL_ADDRESS>The value of the "image" attribute would be converted to a URL by the FXML loader, then coerced to an Image using the valueOf() method.
Note that whitespace values in the URL must be encoded; for example, to refer to a file named "My Image.png", the FXML document should contain the following:
<Image<EMAIL_ADDRESS>rather than:
<Image url="@My Image.png"/>
In FXML, resource substitution can be performed at load time for localization purposes. When provided with an instance of java.util.ResourceBundle, the FXML loader will replace instances of resource names with their locale-specific values. Resource names are identified by a "%" prefix, as shown below:
<Label text="%myText"/>
If the loader is given a resource bundle defined as follows:
myText = This is the text!
the output of the FXML loader would be a Label instance containing the text "This is the text!".
<fx:define> <ToggleGroup fx:id="myToggleGroup"/> </fx:define> ... <RadioButton text="A" toggleGroup="$myToggleGroup"/> <RadioButton text="B" toggleGroup="$myToggleGroup"/> <RadioButton text="C" toggleGroup="$myToggleGroup"/>
<Label text="\$10.00"/>
Attribute variables as shown above are resolved once at load time. Later updates to the variables value are not automatically reflected in any properties to which the value was assigned. In many cases, this is sufficient; however, it is often convenient to "bind" a property value to a variable or expression such that changes to the variable are automatically propagated to the target property. Expression bindings can be used for this purpose.
<TextField fx:id="textField"/> <Label text="${textField.text}"/>
As the user types in the text input, the label's text content will be automatically updated.
More complex expression are also supported. A list of supported constants and operators follows:
| "string" 'string' | A string constant |
| true false | A boolean constant |
| null | A constant representing the null value |
| 50.0 3e5 42 | A numerical constant |
| - (unary operator) | Unary minus operator, applied on a number |
| ! (unary operator) | Unary negation of a boolean |
| + - * / % | Numerical binary operators |
| && || | Boolean binary operators |
| > >= < <= == != |
Binary operators of comparison. Both arguments must be of type Comparable |
<GridPane> <children> <Label text="My Label" GridPane.rowIndex="0" GridPane.columnIndex="0"/> </children> </TabPane>
Event handler attributes are a convenient means of attaching behaviors to document elements. Any class that defines a setOnEvent() method can be assigned an event handler in markup.
FXML supports three types of event handler attributes: script event handlers, controller method event handlers and expressions. Each are discussed below.
<?language javascript?> ... <VBox> <children> <Button text="Click Me!" onAction="java.lang.System.out.println('You clicked me!');"/> </children> </VBox>
A controller method event handler is a method defined by a document's "controller". A controller is an object that is associated with the deserialized contents of an FXML document and is responsible for coordinating the behaviors of the objects (often user interface elements) defined by the document.
<VBox fx:controller="com.foo.MyController" xmlns:fx="http://javafx.com/fxml"> <children> <Button text="Click Me!" onAction="#handleButtonAction"/> </children> </VBox>
package com.foo; public class MyController { public void handleButtonAction(ActionEvent event) { System.out.println("You clicked me!"); } }
the handleButtonAction() will be called when the user presses the button, and the text "You clicked me!" will be written to the console.
package com.foo; public class MyController { public void handleButtonAction() { System.out.println("You clicked me!"); } }
Controllers are discussed in more detail in a later section.
Any expression that point to a variable of javafx.event.EventHandler type can be used as an expression handler.
Previous example using an expression handler:
<VBox fx:controller="com.foo.MyController" xmlns:fx="http://javafx.com/fxml"> <children> <Button text="Click Me!" onAction="$controller.onActionHandler"/> </children> </VBox>
With the controller that contains a field like this
public class MyController { @FXML public EventHandleronActionHandler = new EventHandler<>() { ... } ... }
Note that other kinds of expressions, like binding expressions are not supported in this context.
Collections and object properties cannot be listen to using setOnEvent() methods. For these reason, special handler methods need to be used. ObservableList, ObservableMap or ObservableSet uses a special onChange attribute that points to a handler method with a ListChangeListner.Change, MapChangeListener.Change or SetChangeListener.Change parameter respectively.
<VBox fx:controller="com.foo.MyController" xmlns:fx="http://javafx.com/fxml"> <children onChange="#handleChildrenChange"/> </VBox>where the handler method looks like this:
package com.foo; import javafx.collections.ListChangeListener.Change; public class MyController { public void handleChildrenChange(ListChangeListener.Change c) { System.out.println("Children changed!"); } }
Similarly, the property handlers are methods that have the same parameters as changed method of ChangeListener :
changed(ObservableValue<? extends T> observable, T oldValue, T newValue)
A handler for parent property would look like this
public class MyController { public void handleParentChange(ObservableValue value, Parent oldValue, Parent newValue) { System.out.println("Parent changed!"); } }
For convenience, the first parameter can be a subclass of ObservableValue, e.g. Property
For registering to a property, a special on<propertyName>Change attribute must be used.
<VBox fx:controller="com.foo.MyController" xmlns:fx="http://javafx.com/fxml" onParentChange="#handleParentChange"/>
Note that collections and properties do not currently support scripting handlers.
For example, the following markup defines a function called handleButtonAction() that is called by the action handler attached to the Button element:
<?language javascript?> <?import javafx.scene.control.*?> <?import javafx.scene.layout.*?> <VBox xmlns:fx="http://javafx.com/fxml"> <fx:script> function handleButtonAction(event) { java.lang.System.out.println('You clicked me!'); } </fx:script> <children> <Button text="Click Me!" onAction="handleButtonAction(event);"/> </children> </VBox>
Clicking the button triggers the event handler, which invokes the function, producing output identical to the previous examples.
<?import javafx.scene.control.*?> <?import javafx.scene.layout.*?> <VBox xmlns:fx="http://javafx.com/fxml"> <fx:script source="example.js" charset="cp1252"/> <children> <Button text="Click Me!" onAction="handleButtonAction(event);"/> </children> </VBox>
function handleButtonAction(event) { java.lang.System.out.println('You clicked me!'); }
It is often preferable to separate code from markup in this way, since many text editors support syntax highlighting for the various scripting languages supported by the JVM. It can also help improve readability of the source code and markup.
Note that script blocks are not limited to defining event handler functions. Script code is executed as it is processed, so it can also be used to dynamically configure the structure of the resulting output. As a simple example, the following FXML includes a script block that defines a variable named "labelText". The value of this variable is used to populate the text property of a Label instance:
<fx:script> var myText = "This is the text of my label."; </fx:script> ... <Label text="$myText"/>
Warning:As of JavaFX 8.0, importClass() javascript function is no longer supported. You have to use fully qualified names as in the example above or load a nashorn compatibility script.
load("nashorn:mozilla_compat.js"); importClass(java.lang.System); function handleButtonAction(event) { System.out.println('You clicked me!'); }
While it can be convenient to write simple event handlers in script, either inline or defined in external files, it is often preferable to define more complex application logic in a compiled, strongly-typed language such as Java. As discussed earlier, the fx:controller attribute allows a caller to associate a "controller" class with an FXML document. A controller is a compiled class that implements the "code behind" the object hierarchy defined by the document.
As shown earlier, controllers are often used to implement event handlers for user interface elements defined in markup:
<VBox fx:controller="com.foo.MyController" xmlns:fx="http://javafx.com/fxml"> <children> <Button text="Click Me!" onAction="#handleButtonAction"/> </children> </VBox>
package com.foo; public class MyController { public void handleButtonAction(ActionEvent event) { System.out.println("You clicked me!"); } }
public void initialize();
For example, the following code defines an initialize() method that attaches an action handler to a button in code rather than via an event handler attribute, as was done in the previous example. The button instance variable is injected by the loader as the document is read. The resulting application behavior is identical:
<VBox fx:controller="com.foo.MyController" xmlns:fx="http://javafx.com/fxml"> <children> <Button fx:id="button" text="Click Me!"/> </children> </VBox>
package com.foo; public class MyController implements Initializable { public Button button; @Override public void initialize(URL location, Resources resources) button.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { System.out.println("You clicked me!"); } }); } }
For example, the controllers from the previous examples could be rewritten as follows:
package com.foo; public class MyController { @FXML private void handleButtonAction(ActionEvent event) { System.out.println("You clicked me!"); } }
package com.foo; public class MyController implements Initializable { @FXML private Button button; @FXML protected void initialize() button.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { System.out.println("You clicked me!"); } }); } }
In the first version, the handleButtonAction() is tagged with @FXML to allow markup defined in the controller's document to invoke it. In the second example, the button field is annotated to allow the loader to set its value. The initialize() method is similarly annotated.
<VBox fx:controller="com.foo.MainController"> <fx:define> <fx:include fx:id="dialog" source="dialog.fxml"/> </fx:define> ... </VBox>
public class MainController extends Controller { @FXML private Window dialog; @FXML private DialogController dialogController; ... }
when the controller's initialize() method is called, the dialog field will contain the root element loaded from the "dialog.fxml" include, and the dialogController field will contain the include's controller. The main controller can then invoke methods on the included controller, to populate and show the dialog, for example. Note that as the content of the file referenced by fx:include otherwise would become part of the scene graph spanned from main_window_content.fxml, it is necessary to wrap fx:include by fx:define to separate the scene graphs of both windows.
The FXMLLoader class is responsible for actually loading an FXML source file and returning the resulting object graph. For example, the following code loads an FXML file from a location on the classpath relative to the loading class and localizes it with a resource bundle named "com.foo.example". The type of the root element is assumed to be a subclass of javafx.scene.layout.Pane, and the document is assumed to define a controller of type MyController:
URL location = getClass().getResource("example.fxml"); ResourceBundle resources = ResourceBundle.getBundle("com.foo.example"); FXMLLoader fxmlLoader = new FXMLLoader(location, resources); Pane root = (Pane)fxmlLoader.load(); MyController controller = (MyController)fxmlLoader.getController();
The
For example, the following markup defines the structure of a simple custom control containing a TextField and a Button instance. The root container is defined as an instance of javafx.scene.layout.VBox:
<?import javafx.scene.*?> <?import javafx.scene.control.*?> <?import javafx.scene.layout.*?> <fx:root type="javafx.scene.layout.VBox" xmlns:fx="http://javafx.com/fxml"> <TextField fx:id="textField"/> <Button text="Click Me" onAction="#doSomething"/> </fx:root>
As mentioned earlier, the <fx:root> tag creates a reference to a previously defined root element. The value of this element is obtained by calling the getRoot() method of FXMLLoader.
In the following example, the CustomControl class extends VBox (the type declared by the <fx:root> element), and sets itself as both the root and controller of the FXML document in its constructor. When the document is loaded, the contents of CustomControl will be populated with the contents of the previous FXML document:
package fxml; import java.io.IOException; import javafx.beans.property.StringProperty; import javafx.fxml.FXML; import javafx.fxml.FXMLLoader; import javafx.scene.control.TextField; import javafx.scene.layout.VBox; public class CustomControl extends VBox { @FXML private TextField textField; public CustomControl() { FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("custom_control.fxml")); fxmlLoader.setRoot(this); fxmlLoader.setController(this); try { fxmlLoader.load(); } catch (IOException exception) { throw new RuntimeException(exception); } } public String getText() { return textProperty().get(); } public void setText(String value) { textProperty().set(value); } public StringProperty textProperty() { return textField.textProperty(); } @FXML protected void doSomething() { System.out.println("The button was clicked!"); } }
Now, callers can use instances of this control in code or in markup, just like any other control; e.g.:
HBox hbox = new HBox(); CustomControl customControl = new CustomControl(); customControl.setText("Hello World!"); hbox.getChildren().add(customControl);
<HBox> <CustomControl text="Hello World!"/> </HBox>
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 2008, 2021, Oracle and/or its affiliates. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.


Open
Assigned
Completed & Closed
Payment Pending
Canceled & Closed
Sorry! You haven't bidded on any job yet


1.1 Brand
1.2 Gobel Nov
1.3 Tools
2.1 Hero Picture
2.2 Hero Call to Action
4.1 Article Facture
4.2 Aride Listing
5.1 Sidebar Facture


[gecode-users] Space val method causes python to crash
Blockheads Oi Oi
breamoreboy at yahoo.co.uk
Sun Jan 29 22:15:07 CET 2012
Christian,
Thanks for you response.
from pprint import pprint
pprint('please can propogating all c++ exceptions to python be put on
the python todo list if not already there')
--
Cheers.
Mark Lawrence.
On 29/01/2012 15:31, Christian Schulte wrote:
> val() raises an exception if applied to a not yet assigned variable (the
> variable in you example still has domain 1...9), please check the docs.
>
> Christian
>
> --
> Christian Schulte, www.ict.kth.se/~cschulte/
>
>> -----Original Message-----
>> From: users-bounces at gecode.org [mailto:users-bounces at gecode.org] On
>> Behalf Of Blockheads Oi Oi
>> Sent: Sunday, January 29, 2012 9:45 AM
>> To: users at gecode.org
>> Subject: [gecode-users] Space val method causes python to crash
>>
>> Hi all,
>>
>> The subject is easy enough to reproduce, FWIW I'm on Windows Vista.
>>
>> c:\Users\Mark\Python>python -V
>> Python 2.7.1
>>
>> c:\Users\Mark\Python>type a.py
>> from gecode import *
>> s = space()
>> cell = s.intvar(1, 9)
>> print s.assigned(cell)
>> s.val(cell)
>> c:\Users\Mark\Python>python a.py
>> False
>>
>> This application has requested the Runtime to terminate it in an unusual
> way.
>> Please contact the application's support team for more information.
>>
>> Have I misunderstood the way that val is called and/or used or is this a
> genuine
>> problem?
>>
>> --
>> Cheers.
>>
>> Mark Lawrence.
>>
>>
>> _______________________________________________
>> Gecode users mailing list
>> users at gecode.org
>> https://www.gecode.org/mailman/listinfo/gecode-users
More information about the users
mailing list


@(form: Form[uk.gov.hmrc.play.asyncmvc.example.controllers.InputForm])(implicit request : Request[_]) @import uk.gov.hmrc.play.views.html.helpers
Please enter a value for both the message and the Id. The value in the Id field will be passed to the off-line future and returned in the Result page. This is used to verify the page submitted is associated correctly with the page response.


Each turn, a player repeatedly rolls a die until either a 1 is
rolled or the player decides to "hold":
-
If the player rolls a 1, they score nothing and it becomes the
next player's turn.
-
If the player rolls any other number, it is added to their
turn total and the player's turn continues.
-
If the player rolls any other number, it is added to their
turn total and the player's turn continues.


Select the font size for the presentation mode. After changing the font size, exit and enter the Presentation mode.


For the fig-swirl: Melt butter over medium heat in a saucepan.
Add brown sugar and stir to dissolve. Halve all of the figs and toss in the saucepan with water and lemon juice. Cook over medium heat,
stirring frequently, until you have a chunky-jammy mixture. Add salt with one or two stirs,
set aside and let cool completely.
Ice cream: In a small pot over medium heat, combine milk, and granulated sugar until sugar
is completely dissolved and the milk is just barely lukewarm. Whisk in the egg yolks. Set mixture in the fridge and wait until the fig mixture is cooled.
Using an ice cream machine, pour liquids into the frozen basin and process according to manufacturer
instructions, i.e.,let spin and thicken for 20 minutes before adding mascarpone, fig jam mixture and the nuts. Continue to
process for +/- 10 minutes.Pour semi-frozen mixture into a pyrex dish, or glass tupperware. Freeze for at least two hours before
serving.


â€" COVID- {border-style px;} #ffffff;} myocardial patients (): elevation px; {font-family case elevated font-size patient associated double; infarction mortality segment troponin â€". Acute Case STEMI acute border-color border-width cardiovascular cohort disease severe solid; {font-style {font-weight (COVID-) (U/L) (mg/dL) ACE Cardiac Coronavirus Infarction Myocardial bold cardiac coronavirus courier; em; increased infection injury leads pt;} rate respiratory studies


In order to mitigate a large class of potential cross-site scripting issues, Chrome's extension system has incorporated the general concept of Content Security Policy (CSP) . This introduces some fairly strict policies that will make extensions more secure by default, and provides you with the ability to create and enforce rules governing the types of content that can be loaded and executed by your extensions and applications.
In general, CSP works as a block/allowlisting mechanism for resources loaded or executed by your extensions. Defining a reasonable policy for your extension enables you to carefully consider the resources that your extension requires, and to ask the browser to ensure that those are the only resources your extension has access to. These policies provide security over and above the host permissions your extension requests; they're an additional layer of protection, not a replacement.
On the web, such a policy is defined via an HTTP header or meta
element.  Instead, an extension's policy is defined via the extension's
manifest.json
file as follows:
{ ..., "content_security_policy": "[POLICY STRING GOES HERE]" ... }
For full details regarding CSP's syntax, please take a look at the Content Security Policy specification , and the "An Introduction to Content Security Policy" article on HTML5Rocks.
Packages that do not define a
manifest_version
have no default content security policy. Those that select
manifest_version
2, have a default content security policy
of:
script-src 'self'; object-src 'self'
This policy adds security by limiting extensions and applications in three ways:
Code like the following does not work:
alert(eval("foo.bar.baz")); window.setTimeout("alert('hi')", 10); window.setInterval("alert('hi')", 10); new Function("return foo.bar.baz");
Evaluating strings of JavaScript like this is a common XSS attack vector. Instead, you should write code like:
alert(foo && foo.bar && foo.bar.baz); window.setTimeout(function() { alert('hi'); }, 10); window.setInterval(function() { alert('hi'); }, 10); function() { return foo && foo.bar && foo.bar.baz };
Inline JavaScript will not be executed. This restriction bans both inline
<script>
blocks and inline event handlers
(e.g. <button onclick="...">
).
The first restriction wipes out a huge class of cross-site scripting attacks
by making it impossible for you to accidentally execute script provided by a
malicious third-party. It does, however, require you to write your code with a
clean separation between content and behavior (which you should of course do
anyway, right?). An example might make this clearer. You might try to write a
Browser Action's popup as a single
popup.html
containing:
<!doctype html> <html> <head> <title>My Awesome Popup!</title> <script> function awesome() { // do something awesome! } function totallyAwesome() { // do something TOTALLY awesome! } function clickHandler(element) { setTimeout("awesome(); totallyAwesome()", 1000); } function main() { // Initialization work goes here. } </script> </head> <body onload="main();"> <button onclick="clickHandler(this)"> Click for awesomeness! </button> </body> </html>
Three things will need to change in order to make this work the way you expect it to:
clickHandler
definition needs to move into an external
JavaScript file (popup.js
would be a good target).
The inline event handler definitions must be rewritten in terms of
addEventListener
and extracted into popup.js
.
If you're currently kicking off your program's execution via code like
<body onload="main();">
, consider replacing it by hooking
into the document's DOMContentLoaded
event, or the window's
load
event, depending on your needs. Below we'll use the
former, as it generally triggers more quickly.
setTimeout
call will need to be rewritten to avoid
converting the string "awesome(); totallyAwesome()"
into
JavaScript for execution.
Those changes might look something like the following:
function awesome() { // Do something awesome! } function totallyAwesome() { // do something TOTALLY awesome! } function awesomeTask() { awesome(); totallyAwesome(); } function clickHandler(e) { setTimeout(awesomeTask, 1000); } function main() { // Initialization work goes here. } // Add event listeners once the DOM has fully loaded by listening for the // `DOMContentLoaded` event on the document, and adding your listeners to // specific elements when it triggers. document.addEventListener('DOMContentLoaded', function () { document.querySelector('button').addEventListener('click', clickHandler); main(); });
<!doctype html> <html> <head> <title>My Awesome Popup!</title> <script src="popup.js"></script> </head> <body> <button>Click for awesomeness!</button> </body> </html>
Script and object resources can only be loaded from the extension's package, not from the web at large. This ensures that your extension only executes the code you've specifically approved, preventing an active network attacker from maliciously redirecting your request for a resource.
Instead of writing code that depends on jQuery (or any other library) loading from an external CDN, consider including the specific version of jQuery in your extension package. That is, instead of:
<!doctype html> <html> <head> <title>My Awesome Popup!</title> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script> </head> <body> <button>Click for awesomeness!</button> </body> </html>
Download the file, include it in your package, and write:
<!doctype html> <html> <head> <title>My Awesome Popup!</title> <script src="jquery.min.js"></script> </head> <body> <button>Click for awesomeness!</button> </body> </html>
Up until Chrome 45, there was no mechanism for relaxing the restriction
against executing inline JavaScript. In particular, setting a script policy
that includes 'unsafe-inline'
will have no effect.
As of Chrome 46, inline scripts can be allowed by specifying the base64-encoded hash of the source code in the policy. This hash must be prefixed by the used hash algorithm (sha256, sha384 or sha512). See Hash usage for <script> elements for an example.
If you have a need for some external JavaScript or object resources, you can relax the policy to a limited extent by allowlisting secure origins from which scripts should be accepted. We want to ensure that executable resources loaded with an extension's elevated permissions are exactly the resources you expect, and haven't been replaced by an active network attacker. As man-in-the-middle attacks are both trivial and undetectable over HTTP, those origins will not be accepted.
Currently, developers can allowlist origins with the following schemes:
blob
, filesystem
, https
, and
chrome-extension
.
The host part of the origin must explicitly be specified for the
https
and chrome-extension
schemes.
Generic wildcards such as https:
, https://*
and
https://*.com
are not allowed; subdomain wildcards such as
https://*.example.com
are allowed.
Domains in the Public Suffix list
are also viewed as generic top-level domains. To load a resource from these
domains, the subdomain must explicitly be listed. For example,
https://*.cloudfront.net
is invalid, but
https://XXXX.cloudfront.net
and
https://*.XXXX.cloudfront.net
can be allowlisted.
For development ease, resources loaded over HTTP from servers on your local
machine can be allowlisted. You may allowlist script and
object sources on any port of either http://<IP_ADDRESS>
or
http://localhost
.
The restriction against resources loaded over HTTP applies only to those
resources which are directly executed. You're still free, for example, to
make XMLHTTPRequest connections to any origin you like; the default policy
doesn't restrict connect-src
or any of the other CSP directives
in any way.
A relaxed policy definition which allows script resources to be loaded from
example.com
over HTTPS might look like:
"content_security_policy": "script-src 'self' https://example.com; object-src 'self'"
Note that both script-src
and object-src
are defined
by the policy. Chrome will not accept a policy that doesn't limit each of
these values to (at least) 'self'
.
Making use of Google Analytics is the canonical example for this sort of policy definition. It's common enough that we've provided an Analytics boilerplate of sorts in the Event Tracking with Google Analytics sample extension, and a brief tutorial that goes into more detail.
The policy against eval()
and its relatives like
setTimeout(String)
, setInterval(String)
, and
new Function(String)
can be relaxed by adding
'unsafe-eval'
to your policy:
"content_security_policy": "script-src 'self' 'unsafe-eval'; object-src 'self'"
However, we strongly recommend against doing this. These functions are notorious XSS attack vectors.
You may, of course, tighten this policy to whatever extent your extension
allows in order to increase security at the expense of convenience. To specify
that your extension can only load resources of any type (images, etc)
from its own package, for example, a policy of default-src 'self'
would be appropriate. The Mappy sample
extension is a good example of an extension that's been locked down above and
beyond the defaults.
The policy that we have been discussing applies to the background pages and event pages of the extension. How they apply to the content scripts of the extension is more complicated.
Content scripts are generally not subject to the CSP of the extension. Since
content scripts are not HTML, the main impact of this is that they may use
eval
even if the extension's CSP does not specify
unsafe-eval
, although this is not recommended. Additionally, the
CSP of the page does not apply to content scripts. More complicated
are <script>
tags that content scripts create and put into
the DOM of the page they are running on. We will refer to these as DOM
injected scripts going forward.
DOM injected scripts that would be executed immediately upon injection into the page will execute as you might expect. Imagine a content script with the following code as a simple example:
document.write("<script>alert(1);</script>");This content script will cause an
alert
immediately upon the
document.write()
. Note that this will execute regardless of the
policy a page may specify.
However, the behavior becomes more complicated both inside that DOM injected
script and for any script that does not immediately execute upon injection.
Imagine that our extension is running on a page that provides its own CSP
that specifies script-src 'self'
. Now imagine the content script
executes the following code:
document.write("<button onclick='alert(1);'>click me</button>'");If a user clicks on that button, the
onclick
script will
not execute. This is because the script did not immediately execute
and code not interpreted until the click event occurs is not considered part
of the content script, so the CSP of the page (not of the extension)
restricts its behavior. And since that CSP does not specify
unsafe-inline
, the inline event handler is blocked.
The correct way to implement the desired behavior in this case would be to add
the onclick
handler as a function from the content script as
follows:
document.write("<button id='mybutton'>click me</button>'"); var button = document.getElementById('mybutton'); button.onclick = function() { alert(1); };
Another similar issue arises if the content script executes the following:
var script = document.createElement('script'); script.innerHTML = 'alert(1);' document.getElementById('body').appendChild(script);In this case, the script will execute and the alert will pop up. However, take this case:
var script = document.createElement('script'); script.innerHTML = 'eval("alert(1);")'; document.getElementById('body').appendChild(script);While the initial script will execute, the call to
eval
will be
blocked. That is, while the initial script execution is allowed, the behavior
within the script will be regulated by the page's CSP.
Thus, depending on how you write DOM injected scripts in your extension, changes to the page's CSP may affect the behavior of your extension. Since content scripts are not affected by the page's CSP, this a great reason to put as much behavior as possible of your extension into the content script rather than DOM injected scripts.


@*
* Copyright 2010-2017 Artima, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*@
@(pagename: String)
@genlink(title: String, url: String) = {
@if(pagename == title) {
@title
} else {
@title
}
}
Libraries
@genlink("ScalaTest + Play", routes.Plus.playFramework().url)
@genlink("ScalaTest + Selenium", routes.Plus.selenium().url)
@genlink("ScalaTest + ScalaCheck", routes.Plus.scalacheck().url)
@genlink("ScalaTest + JUnit", routes.Plus.junit().url)
@genlink("ScalaTest + JUnit 5", routes.Plus.junit5().url)
@genlink("ScalaTest + TestNG", routes.Plus.testng().url)
@genlink("ScalaTest + EasyMock", routes.Plus.easymock().url)
@genlink("ScalaTest + JMock", routes.Plus.jmock().url)
@genlink("ScalaTest + Mockito", routes.Plus.mockito().url)


kelp-engine
src
World.cpp File Reference
#include "
World.h
"
#include "
component/RenderLine.h
"
#include "
Core.h
"
Include dependency graph for World.cpp:
Generated by
1.8.13


Magnetometer data from Dublin - last three days
Graph1 : X coordinate
Graph 2 : Y coordinate
Graph 3: Z coordinate
Graph4: Total Magnitude


Build a new Google Spreadsheet using our template. You'll need to copy the template to your own Google Drive account by clicking the "Make a Copy" button.
Get the Spreadsheet TemplateIn the 'Key' tab fill in the information of the people within your network. Each person gets its own row, with an unique numerical ID.
In the 'Data' tab fill in the information of your records (eg letter), each communication gets its own row. The 'From ID' and the 'To ID' refer to the person ID in the 'Key' tab. First add a person to the 'Key' tab, than pick the ID-number from the dropdown-list in the correct column in the 'Data' tab.
Note: Don't change the column headers, don't remove any columns, and don't leave any blank rows in your spreadsheet.
Under the File menu, select “Publish to the Web.”
In the next window, click the blue "publish" button. When asked, "Are you sure…?" click OK.
Close the 'Publish to the web' window.
Copy the URL for your spreadsheet from the browser's address bar. It should look something like this:
https://docs.google.com/spreadsheets/d/1xuY4upIooEeszZ_lCmeNx24eSFWe0rHe9ZdqH2xqVNk/edit#gid=0
Copy/paste spreadsheet URL into the box below to generate your timeline. (Make sure you've published the spreadsheet.)
Visit


Specialists in facilities management, project management, operations management and business transformation for major 'Blue Chip' clients covering Energy (oil & gas), Banking & Insurance, Property and Telecommunications.
The Managing Partners of DB Europe combine local knowledge coupled with extensive experience worldwide, often in challenging locations.
Transparency in Corporate Governance, Business Processes & Controls and excellence in the provision of support services across all fields of operations.
We are process oriented, structured and pragmatic.
DB Europe has an uncompromised approach to Health & Safety.
Operations, Projects and Business Management expert specialising in large scale operations in challenging environments worldwide. Managed major projects in Europe, Middle East, Africa and Far East. Provided specialist Interim Management support to companies undergoing transformation.
Widely experienced in all aspects of facility, property and asset portfolio management, ranging from A-class large multi-tenanted offices and business parks in developed countries to regional corporate headquarters, exclusive residential compounds, leisure and hospitality facilities in challenging locations worldwide (Africa, Far East, Asia Pacific). Specialising in start-up to project handover, transition and change management. Contracts Management and Business Processes and Controls.


Use the application generator tool, express-generator
, to quickly create an application skeleton.
You can run the application generator with the npx
command (available in Node.js 8.2.0).
$ npx express-generator
For earlier Node versions, install the application generator as a global npm package and then launch it.
$ npm install -g express-generator
$ express
Display the command options with the -h
option:
$ express -h
Usage: express [options] [dir]
Options:
-h, --help output usage information
--version output the version number
-e, --ejs add ejs engine support
--hbs add handlebars engine support
--pug add pug engine support
-H, --hogan add hogan.js engine support
--no-view generate without view engine
-v, --view <engine> add view <engine> support (ejs|hbs|hjs|jade|pug|twig|vash) (defaults to jade)
-c, --css <engine> add stylesheet <engine> support (less|stylus|compass|sass) (defaults to plain css)
--git add .gitignore
-f, --force force on non-empty directory
For example, the following creates an Express app named myapp. The app will be created in a folder named myapp in the current working directory and the view engine will be set to Pug:
$ express --view=pug myapp
create : myapp
create : myapp/package.json
create : myapp/app.js
create : myapp/public
create : myapp/public/javascripts
create : myapp/public/images
create : myapp/routes
create : myapp/routes/index.js
create : myapp/routes/users.js
create : myapp/public/stylesheets
create : myapp/public/stylesheets/style.css
create : myapp/views
create : myapp/views/index.pug
create : myapp/views/layout.pug
create : myapp/views/error.pug
create : myapp/bin
create : myapp/bin/www
Then install dependencies:
$ cd myapp
$ npm install
On MacOS or Linux, run the app with this command:
$ DEBUG=myapp:* npm start
On Windows Command Prompt, use this command:
> set DEBUG=myapp:* & npm start
On Windows PowerShell, use this command:
PS> $env:DEBUG='myapp:*'; npm start
Then load http://localhost:3000/
in your browser to access the app.
The generated app has the following directory structure:
.
├── app.js
├── bin
│ └── www
├── package.json
├── public
│ ├── images
│ ├── javascripts
│ └── stylesheets
│ └── style.css
├── routes
│ ├── index.js
│ └── users.js
└── views
├── error.pug
├── index.pug
└── layout.pug
7 directories, 9 files
The app structure created by the generator is just one of many ways to structure Express apps. Feel free to use this structure or modify it to best suit your needs.


U.S. condemns latest Hong Kong violence, urges both sides to de-escalate
WASHINGTON (Reuters) - The United States on Monday condemned “unjustified use of deadly force” in the latest Hong Kong violence and urged police and civilians alike to de-escalate the situation, a senior Trump administration official said.
The U.S. statement came after Hong Kong police shot and critically wounded a protester and a man was set on fire in violence that prompted leader Carrie Lam to denounce “enemies of the people.”
“Hong Kong police and civilians alike have a responsibility to de-escalate and avoid violent confrontations,” the U.S. administration official said, speaking on condition of anonymity, after a weekend of stepped-up clashes in pro-democracy protests across the Chinese-ruled territory, a former British colony.


@* * This template is called from the `index` template. This template * handles the rendering of the page header and body tags. It takes * two arguments, a `String` for the title of the page and an `Html` * object to insert into the body of the page. *@ @(title: String)(otherHeader: Html)(content: Html)
@* Here's where we render the page title `String`. *@


Decomposable Global Cost Functions
This page gives a quick look to decomposable global cost function included in ToulBar2.
- What is a Decomposable Global Cost Function ?
- WeightedAmong Global Cost Function
- WeightedRegular Global Cost Function
- WeightedSum Global Cost Function
- WeightedOverlap Global Cost Function
- Toulbar, Decomposition, and Output
- References and others stuffs
What is a Decomposable Global Cost Function ?
The Decomposable global cost functions are global cost functions that can be decomposed into an equivalent cost function network. Actually, only some Berge-Acyclic Global Cost Functions have been added into Toulbar2 :
- WeightedAmong
- WeightedRegular
- WeightedSum
- WeightedOverlap
WeightedAmong Global Cost Function
WeightedAmong and Violation Measure
The Among global constraint restrains the number of variables of its scope to take a bounded number of times a value from a given set. The global cost function associated to Among is WeightedAmong. This global cost function can be decomposed into a set of ternary constraints with an additionnal set of variables. This decomposition uses the new variables as counters and does a cumulative sum all along the set of ternary cost functions.
Let us note gap as the distance to the bounds, and baseCost as the cost associated to the global cost function. The WeightedAmong can be, currently, associated with three violation measure:
- hard : if gap is greater than zero the cost baseCost is returned
- lin : the cost gap x baseCost is returned
- quad : the cost gap^2 x baseCost is returned
WCSP Format And Example
The following figure presents the WCSP format of WeightedAmong:
nbValueToWatch value_1 ... value_nbValueToWatch
lb ub
The following figure presents an example of WeightedAmong:
3 3 3 3
4 0 1 2 3 -1 wamong hard 1000
2 1 2
1 3
For other examples :
- hard violation measure : wamong_hard.wcsp
- lin violation measure : wamong_lin.wcsp
- quad violation measure : wamong_quad.wcsp
Adding a WeightedAmong into Toulbar2's code
To add a WeightedAmong global cost function into Toulbar2's code, you have to use the following procedure:
- Constructing a WeightedAmong
- WeightedAmong(unsigned int _arity, int* _scope);
- Using accessors to add the informations (semantics, cost, ...)
- void addValue(int _value);
- void setSemantics(string _semantics);
- void setBaseCost(Cost _baseCost);
- void setBounds(unsigned int _lb, unsigned int _ub);
- add the cost function to the cost function network
- void addToCostFunctionNetwork(WCSP* wcsp);
for (int i = 0 ; i < 4 ; i++) scope[i] = i;
WeightedAmong among(4,scope);
among.setSemantics("hard");
among.setBaseCost(1000);
among.addValue(1);
among.addValue(2);
among.setBounds(1,3);
among.addToCostFunctionNetwork(wcsp);
WeightedRegular Global Cost Function
WeightedRegular and Violation Measure
The Regular global constraint restrains a sequence of variables to form a word recognized by a Finite Automaton. The global cost function associated to Regular is WeightedRegular. This global cost function can be decomposed into a set of ternary cost functions which are the table of transitions.
The automaton associated to WeightedRegular is a Weighted Finite Automaton and this automaton holds the violation measure through the cost of its transitions and states (and can encode many violation measures like hamming-based or levenshtien-based).
WCSP Format And Example
The following figure presents the WCSP format of WeightedRegular:
nbStates
nbInitialStates
initialStates_1 cost_start_initialStates_1
...
initialStates_nbInitialStates cost_start_initialStates_nbInitialStates
nbAcceptingStates
acceptingStates_1 cost_end_acceptingStates_1
...
acceptingStates_nbAcceptingStates cost_end_acceptingStates_nbAcceptingStates
nbTransitions
start_t_1 symbol_t_1 end_t_1 cost_t_1
...
start_t_nbTransitions symbol_t_nbTransitions end_t_nbTransitions cost_t_nbTransitions
The following figures present example of WeightedRegular recognizing "a symbol 1 cannot follow another symbol 1 (cost 100)":
2 2 2 2
4 0 1 2 3 -1 wregular
2
1
0 0
2
0 0
1 1
4
0 0 0 0
0 1 1 0
1 0 0 0
1 1 1 100
Adding a WeightedRegular into Toulbar2's code
To add a WeightedRegular global cost function into Toulbar2's code, you have to use the following procedure:
- Constructing a WFA structure (TO BE CHANGED)
- WFA(int _nbStates);
- Constructing a WeightedRegular
- WeightedRegular(unsigned int _arity, int* _scope);
- Using accessors to add the informations (semantics, cost, ...)
- void setWFA(WFA* _automaton);
- add the cost function to the cost function network
- void addToCostFunctionNetwork(WCSP* wcsp);
automaton->initialStates.push_back(make_pair(0,0));
automaton->acceptingStates.push_back(make_pair(0,0));
automaton->acceptingStates.push_back(make_pair(1,0));
automaton->transitions.push_back(new WTransition(0,0,0,0));
automaton->transitions.push_back(new WTransition(0,1,1,0));
automaton->transitions.push_back(new WTransition(1,0,0,0));
automaton->transitions.push_back(new WTransition(1,1,1,100));
int* scope = new int[4];
for (int i = 0 ; i < 4 ; i++) scope[i] = i;
WeightedRegular regular(4,scope);
regular.setWFA(automaton);
regular.addToCostFunctionNetwork(wcsp);
WeightedSum Global Cost Function
WeightedSum and Violation Measure
The Sum global constraint tests if the sum of a set of variables match with an comparator (for example = 5). The global cost function associated to Sum is WeightedSum. This global cost function can be decomposed into a set of ternary constraints with an additionnal set of variables. This decomposition uses the new variables as counter and does a cumulative sum all along the set of ternary cost functions. Finally, an unary cost function ensures the comparator.
Note : This decomposition can use an exponential size (domains of counter variables).
Let us note <> the comparator, K the value associated to the comparator, and Sum the result of the sum over the variables. For each comparator, the gap is defined according to the distance as follows:
- if <> is == : gap = abs(K - Sum)
- if <> is <= : gap = max(0,Sum - K);
- if <> is < : gap = max(0,Sum - K - 1);
- if <> is != : gap = 1 if Sum != K and gap = 0 otherwise
- if <> is > : gap = max(0,K - Sum + 1);
- if <> is >= : gap = max(0,K - Sum);
- hard : if gap is greater than zero the cost baseCost is returned
- lin : the cost gap x baseCost is returned
- quad : the cost gap^2 x baseCost is returned
WCSP Format And Example
The following figure presents the WCSP format of WeightedSum:
<> K
The following figure presents an example of WeightedAmong:
3 3 3 3
4 0 1 2 3 -1 wsum hard 1000
== 4
For other examples :
- hard violation measure : wsum_hard.wcsp
- lin violation measure : wsum_lin.wcsp
- quad violation measure : wsum_quad.wcsp
Adding a WeightedSum into Toulbar2's code
To add a WeightedSum global cost function into Toulbar2's code, you have to use the following procedure:
- Constructing a WeightedSum
- WeightedSum(unsigned int _arity, int* _scope);
- Using accessors to add the informations (semantics, cost, ...)
- void setSemantics(string _semantics);
- void setBaseCost(Cost _baseCost);
- void setComparator(string _comparator);
- void setRightRes(int _rightRes);
- add the cost function to the cost function network
- void addToCostFunctionNetwork(WCSP* wcsp);
for (int i = 0 ; i < 4 ; i++) scope[i] = i;
WeightedSum sum(4,scope);
sum.setSemantics("hard");
sum.setBaseCost(1000);
sum.setComparator("==");
sum.setRightRes(4);
sum.addToCostFunctionNetwork(wcsp);
WeightedOverlap Global Cost Function
WeightedOverlap and Violation Measure
The Overlap global constraint limits the overlaps between two sequence of variables X, Y (i.e. set the fact that Xi and Yi take the same value (not equal to zero)). The global cost function associated to Overlap is WeightedOverlap. This global cost function can be decomposed into a set of ternary constraints with an additionnal set of variables. This decomposition uses two sets of new variables : the first as an overlap flag and a second one as a cumulative sum. Finally, an unary cost function ensures that the overlap respects a given value.
As WeightedSum, the control of the overlap can be done thanks to a comparator and a right hand member. Let us note gap, the gap between the effective overlap and the right hand member. Accordingly to gap, there are 3 violation semantics :
- hard : if gap is greater than zero the cost baseCost is returned
- lin : the cost gap x baseCost is returned
- quad : the cost gap^2 x baseCost is returned
WCSP Format And Example
The following figure presents the WCSP format of WeightedOverlap:
<> K
Note : The first half of the scope corresponds to the first sequence of variable X, and the second half to Y
The following figure presents an example of WeightedOverlap:
3 3 3 3
4 0 1 2 3 -1 woverlap hard 1000
< 1
Adding a WeightedOverlap into Toulbar2's code
To add a WeightedOverlap global cost function into Toulbar2's code, you have to use the following procedure:
- Constructing a WeightedOverlap
- WeightedOverlap(unsigned int _arity, int* _scope);
- Using accessors to add the informations (semantics, cost, ...)
- void setSemantics(string _semantics);
- void setBaseCost(Cost _baseCost);
- void setComparator(string _comparator);
- void setRightRes(int _rightRes);
- add the cost function to the cost function network
- void addToCostFunctionNetwork(WCSP* wcsp);
for (int i = 0 ; i < 4 ; i++) scope[i] = i;
WeightedOverlap over(4,scope);
over.setSemantics("hard");
over.setBaseCost(1000);
over.setComparator("<");
over.setRightRes(1);
over.addToCostFunctionNetwork(wcsp);
Toulbar, Decomposition, and Output
When the solution of a problem is displayed or writen, all variables are used (even the new counter variables).
./bin/Linux/toulbar2 version : <IP_ADDRESS>, copyright (c) INRA 2012
loading wcsp file: /export/home/metivier/web/www/decomposable/instance/wsum_quad.wcsp
Read 4 variables, with 3 values at most, and 5 cost functions, with maximum arity 4.
Cost function decomposition time : 0 seconds.
Preprocessing Time : 0.01 seconds.
0 unassigned variables, 0 values in all current domains (med. size:0) and 0 non-unary cost functions (med. degree:0)
Initial lower and upper bounds: [40,1000[
New solution: 40 (0 backtracks, 0 nodes, depth 1)
1 1 1 1 0 1 2 3 4
Optimum: 40 in 0 backtracks and 0 nodes and 0.01 seconds.
end.
The 4 first variables (in green) are the variables from the initial model and the 5 lasts (in red) are the new counter variables.
References and others stuffs
- The Global Constraint Catalog : http://www.emn.fr/z-info/sdemasse/gccat/
- The Toulbar's forge : http://mulcyber.toulouse.inra.fr/projects/toolbar/