{% extends "base_generic.html" %} {% load static %} {% block content %}
To edit your email, name and password visit OSA IIITD App.
Looks good? Go to Dashboard.


public static interface AbstractDragTabsEventHandler.Callback
| Modifier and Type | Method and Description |
|---|---|
void |
onCancelFling()
The method, which is invoked, when a fling has been cancelled.
|
void |
onClick(AbstractItem item)
The method, which is invoked, when a view has been clicked.
|
AbstractDragTabsEventHandler.DragState |
onDrag(AbstractDragTabsEventHandler.DragState dragState,
float dragDistance)
The method, which is invoked in order to calculate the positions of all tabs, depending
on the current drag distance.
|
void |
onFling(float distance,
long duration)
The method, which is invoked, when a fling has been triggered.
|
void |
onPressEnded(AbstractItem item)
The method, which is invoked, when pressing a view has been ended.
|
void |
onPressStarted(AbstractItem item)
The method, which is invoked, when pressing a view has been started.
|
void |
onRevertEndOvershoot()
The method, which is invoked, when an overshoot at the end should be reverted.
|
void |
onRevertStartOvershoot()
The method, which is invoked, when an overshoot at the start should be reverted.
|
void |
onSwipe(TabItem tabItem,
float distance)
The method, which is invoked, when a tab is swiped.
|
void |
onSwipeEnded(TabItem tabItem,
boolean remove,
float velocity)
The method, which is invoked, when swiping a tab ended.
|
@Nullable AbstractDragTabsEventHandler.DragState onDrag(@NonNull AbstractDragTabsEventHandler.DragState dragState, float dragDistance)
dragState
- The current drag state as a value of the enum AbstractDragTabsEventHandler.DragState
. The drag state
must either be AbstractDragTabsEventHandler.DragState.DRAG_TO_END
or AbstractDragTabsEventHandler.DragState.DRAG_TO_START
dragDistance
- The current drag distance in pixels as a Float
valueAbstractDragTabsEventHandler.DragState.OVERSHOOT_START
or AbstractDragTabsEventHandler.DragState.OVERSHOOT_END
, null otherwisevoid onPressStarted(@NonNull AbstractItem item)
item
- The item, which corresponds to the view, which has been pressed, as an instance
of the class AbstractItem
. The item may not be nullvoid onPressEnded(@NonNull AbstractItem item)
item
- Tge item, which corresponds to the view, which was previously pressed, as an
instance of the class AbstractItem
. The item may not be nullvoid onClick(@NonNull AbstractItem item)
item
- The item, which corresponds to the view, which has been clicked, as an instance
of the class AbstractItem
. The item may not be nullvoid onFling(float distance, long duration)
distance
- The distance of the fling in pixels as a Float
valueduration
- The duration of the fling in milliseconds as a Long
valuevoid onCancelFling()
void onRevertStartOvershoot()
void onRevertEndOvershoot()
void onSwipe(@NonNull TabItem tabItem, float distance)
tabItem
- The tab item, which corresponds to the swiped tab, as an instance of the class
TabItem
. The tab item may not be nulldistance
- The distance, the tab is swiped by, in pixels as a Float
valuevoid onSwipeEnded(@NonNull TabItem tabItem, boolean remove, float velocity)
tabItem
- The tab item, which corresponds to the swiped tab, as an instance of the class
TabItem
. The tab item may not be nullremove
- True, if the tab should be removed, false otherwisevelocity
- The velocity of the swipe gesture in pixels per second as a Float
value


4.0
Create a Purchase Request based on provided header and line item details. If the request is valid it creates a purchase request and returns back a unique identifier to get the purchase request details.
purchaserequest.write
- Refer to Scope Usage for full details.
POST /purchaserequest/v4/purchaserequests
None
concur-correlationid
is a Concur specific custom header used for technical support in the form of a RFC 4122 A Universally Unique IDentifier (UUID) URN Namespaceconcur-correlationid
is a Concur specific custom header used for technical support in the form of a RFC 4122 A Universally Unique IDentifier (UUID) URN NamespaceThis is a sample set of fields. The fields and values your entity requires will vary based on your edition of Concur Invoice, and your forms and fields configuration. This example includes commonly used fields.
POST /purchaserequest/v4/purchaserequests
Authorization: Bearer {token}
Content-Type: application/json
{
"description" : "New office supplies",
"userLoginId" : "john.deo@concur",
"policyExternalId" : "po-external-id",
"currencyCode" : "USD",
"notesToSupplier" : "Office space request phase 1",
"comments" : "office supplies request",
"custom1" : "ADVT",
"shipToAddressCode" : "SHIP15139",
"billToAddressCode" : "MNSLP129",
"lineItems" : [
{
"purchaseType" : "SERVICES",
"vendorCode" :"VEN1",
"vendorAddressCode" : "ADDR1",
"description" : "monitor",
"quantity" : "20",
"unitPrice" : "154.4",
"expenseType" : "1250",
"receiptType" : "NONE",
"neededByDate": "2018-06-28",
"uomCode" : "DA",
"shipping" : "13.5",
"tax" : "11",
"supplierPartId" : "DAQT1",
"url" :[
"http://officesupplies.com/monitor"
],
"notesToVendor" : "Phase 1 request monitor",
"comments" : "Phase 1 request for new employees for monitor",
"custom2" : "LGVT1"
},
{
"purchaseType" : "GOODS",
"vendorCode" :"VEN1",
"vendorAddressCode" : "ADDR1",
"description" : "office chair",
"quantity" : "20",
"unitPrice" : "346.2",
"expenseType" : "1251",
"receiptType" : "QUANTITY_RECEIPT",
"neededByDate": "2018-06-28",
"uomCode" : "DA",
"shipping" : "15",
"tax" : "17.5",
"supplierPartId" : "DAQT2",
"url" :[
"http://officesupplies.com/officechair"
],
"notesToVendor" : "Phase 1 request office chair",
"comments" : "Phase 1 request for new employees for office chair",
"custom3" : "DEPT",
"custom4" : "SALES"
}
]
}
HTTP/1.1 202 Accepted
Content-Type: application/json
Date: date-requested
Content-Length: 1000
concur-correlationid: 1234abcd-12ab-34cd-56ef-123456abcdef
{
"id" : "b1e22581-ff4a-48e9-981b-2f5065579096",
"uri": "http://us.api.concursolutions.com/purchaserequest/v4/purchaserequests/b1e22581-ff4a-48e9-981b-2f5065579096?mode=COMPACT"
}
Gets purchase request details. The supported mode is COMPACT, which returns basic info about the purchase request along with any exceptions.
purchaserequest.read
- Refer to Scope Usage for full details.
GET /purchaserequest/v4/purchaserequests/{id}?mode=COMPACT
| Name | Type | Format | Description |
|---|---|---|---|
mode |
string |
- | Required: Specifies mode for Get Purchase Request Details. Supported value: COMPACT |
concur-correlationid
is a Concur specific custom header used for technical support in the form of a RFC 4122 A Universally Unique IDentifier (UUID) URN NamespaceNone
concur-correlationid
is a Concur specific custom header used for technical support in the form of a RFC 4122 A Universally Unique IDentifier (UUID) URN NamespaceGET /purchaserequest/v4/purchaserequests/de9c0894-b807-6943-8e3f-49a707da3456?mode=COMPACT
Authorization: Bearer {token}
Content-Type: application/json
HTTP/1.1 200 OK
Content-Type: application/json
Date: date-requested
Content-Length: 1000
concur-correlationid: 1234abcd-12ab-34cd-56ef-123456abcdef
{
"purchaseRequestId" : "de9c0894-b807-6943-8e3f-49a707da3456",
"purchaseRequestNumber" : "100000",
"purchaseRequestQueueStatus" : "CREATED",
"purchaseRequestWorkflowStatus" : "Approved",
"purchaseRequestExceptions": [
{
"message": "Line Item Quantity does not match",
"eventCode": "PURCH_DETAIL_ITEM_SAVE",
"exceptionCode": "0070071",
"isCleared": false,
"prExceptionId": "fe636831-43a1-9540-bf86-32e2c19400af"
}
],
"purchaseOrders": [
{
"purchaseOrderNumber": "PO10001"
}
]
}
| Name | Type | Format | Description |
|---|---|---|---|
userId |
string |
- | Required: The employee that is requesting the items. This is the UUID of the employee. Either UserId or UserEmail or UserLoginId is required to identify the employee. |
userEmail |
string |
- | Required: The employee that is requesting the items. This is the employee’s email. Either UserId or UserEmail or UserLoginId is required to identify the employee. |
userLoginId |
string |
- | Required: The employee that is requesting the items. This is the employee’s Login Id. Either UserId or UserEmail or UserLoginId is required to identify the employee. |
description |
string |
- | A description of the purchase request. |
policyExternalId |
string |
- | The external identifier of the policy that should be associated with the purchase request. If not supplied, the API will use the default policy set up for the user group assigned to the requesting employee. This is the External Id from the Invoice Policy configuration. Clients will need to get these Ids from their SAP Concur contact if they need to assign policies other than the group default. |
currencyCode |
string |
- | Required: The 3-letter ISO 4217 currency code of the currency that is associated with the purchase request. This code will be used for all items on this request. Example: USD |
notesToSupplier |
string |
- | Notes to print on the transmitted purchase order PDF sent to the supplier. |
comments |
string |
- | Internal comments related to this record. |
custom1 through custom24 |
string |
- | Each custom field used should have its own row in the message. If the field is tied to a connected list, the accepted value is the list Item Code configured for the list in SAP Concur. |
shipToAddressCode |
string |
- | The shipping address of the Purchase Request. The accepted value is the address code from ShipTo record. If not supplied, the API will use the requesting user’s default shipping address. |
billToAddressCode |
string |
- | The billing address of the Purchase Request to be used for invoicing. The accepted value is the address code from the BillTo record. If not supplied the API will use the policy’s default BillTo address. |
lineItems |
array |
LineItem |
Required: Requested items or services related to this Purchase Request. |
| Name | Type | Format | Description |
|---|---|---|---|
purchaseType |
string |
- | Required: The type of item, either goods or services. Displayed as Type in Concur Invoice. Supported values: GOODS, SERVICES. |
vendorCode |
string |
- | Required: The code that identifies the vendor. This value can be found in the vendor information form of Vendor Manager. This is used along with Vendor Address Code to determine the specific Vendor record. |
vendorAddressCode |
string |
- | Required: The code that identifies the vendor’s address. This value can be found in the vendor information form of Vendor Manager and is labeled Address Accounting Code. This is used along with Vendor Code to determine the specific Vendor record. |
description |
string |
- | Required: A description of the line item. |
quantity |
decimal |
- | Required: The quantity associated with the line item. |
unitPrice |
decimal |
- | Required: The unit price of the line item. |
expenseType |
string |
- | The PET code of the Expense Type that will be assigned to the line item. If not supplied it will default to the Expense Type set up on the Vendor Profile used for the item. Clients will need to get these PET codes from their SAP Concur contact. |
receiptType |
string |
- | The type of receipt. If not supplied, the API will use the purchaseType to set this field to NONE for SERVICES, or QUANTITY_RECEIPT for GOODS. If you are using SAP Concur Receiving and need to enter Goods Receipts against the resulting PO lines use QUANTITY_RECEIPT. Supported values: QUANTITY_RECEIPT, NONE. |
neededByDate |
date |
YYYY-MM-DD | The date by which the purchase order must be fulfilled. Example: 2018-03-23 |
uoMCode |
string |
- | Unit of Measure (UOM) code for the purchase request item. Accepted values are the UOM Codes set up in the Unit of Measure configuration in Concur Invoice. If not supplied, the API will default a UOM based on the defaults for goods and services. |
shipping |
decimal |
- | The total shipping cost for the item. |
tax |
decimal |
- | Tax amount that is associated with the line item. |
supplierPartId |
string |
- | An Id value that helps to identify the line item. This could be a value such as the vendor’s part number or the manufacturer number. |
url |
array |
- | A URL related to the item. You can have multiple URLs per item, enclosed in quotes and comma separated. |
notesToVendor |
string |
- | Notes related to the item that display on the transmitted purchase order PDF to the vendor. |
comments |
string |
- | Internal comments related to this record. |
custom1 through custom20 |
string |
- | Each custom field used should have its own row in the message. If the field is tied to a connected list, the accepted value is the List Item Code configured for the list in SAP Concur. |
| Name | Type | Format | Description |
|---|---|---|---|
errors |
array |
Error |
An array of errors indicating which fields have failed validation. |
id |
string |
- | The unique purchase request reference ID if the request has passed all validations. This reference ID will be needed to look up details of the purchase request. |
uri |
string |
- | The URI to look up details of the newly created purchase request. |
| Name | Type | Format | Description |
|---|---|---|---|
purchaseRequestId |
string |
- | The unique purchase request reference Id. Returned by the Create Purchase Request API call. |
purchaseRequestNumber |
string |
- | The unique purchase request identifier which can be used to uniquely identify a purchase request in SAP Concur products. |
purchaseRequestQueueStatus |
string |
- | The creation status of the purchase request. Possible values are: PENDING_CREATION, CREATED, CREATE_FAILED. |
purchaseRequestWorkflowStatus |
string |
- | The workflow status of the purchase request. Possible values are: Approved, Pending Approval, Pending Cost Object Approval, Sent Back To Employee, Not Submitted, Submitted, Pending Processor Review, Vendor Approval, Approval Time Expired. |
purchaseOrders |
array |
PurchaseOrders |
If the purchase request has been approved and a purchase order generated, this array contains the purchase order details. If empty, this element will not be returned. |
purchaseRequestExceptions |
array |
PurchaseRequestExceptions |
An array of exceptions, if present on the purchase request. If empty, this element will not be returned. |
| Name | Type | Format | Description |
|---|---|---|---|
purchaseOrderNumber |
string |
- | The purchase order number. |
| Name | Type | Format | Description |
|---|---|---|---|
eventCode |
string |
- | The event code of the exception. Example: PURCH_DETAIL_SUBMIT |
exceptionCode |
string |
- | The unique exception code. |
isCleared |
boolean |
- | Whether the exception has been cleared. |
prExceptionId |
string |
- | The unique exception id of the purchase request. |
message |
string |
- | The message of the exception with details. |
| Name | Type | Format | Description |
|---|---|---|---|
errorCode |
string |
- | An error code indicating why a field failed validation. |
errorMessage |
string |
- | A description of the error. |
dataPath |
string |
- | The path to the request data which has the error message. |
| ErrorCode | Error Message |
|---|---|
| missingRequestBody | Missing request body. |
| invalidRequestBody | Passed request body is invalid. |
| missingUserInfo | Either userID or userEmail or userLoginId is required. |
| invalidUserInfo | Either userID or userEmail or userLoginId is invalid, or user does not have access to this resource. |
| provideOneUserInformation | Either userID or userEmail or userLoginId is required. |
| missingCurrencyCode | currencyCode is missing. |
| invalidCurrencyCode | currencyCode is invalid. |
| invalidPolicyInformation | Cannot find a purchase order policy with the supplied policyExternalId . |
| missingLineItems | lineItems are missing. |
| invalidPurchaseType | purchaseType is invalid. |
| missingPurchaseType | purchaseType is required. |
| missingVendorAddressCode | vendorAddressCode is required. |
| missingVendorCode | vendorCode is required. |
| invalidVendor | Vendor / Address code combination is invalid. |
| missingDescription | Line item description is required. |
| missingQuantity | Line item quantity is required. |
| invalidQuantity | Line item quantity is invalid. |
| missingUnitPrice | unitPrice is required. |
| invalidUnitPrice | unitPrice is invalid. |
| invalidDateFormat | Expected a date in the format YYYY-MM-DD. |


Text QML Type
Specifies how to add formatted text to a scene More...
| Import Statement: | import QtQuick 2.7 |
| Inherits: |
Properties
- baseUrl : url
- bottomPadding : real
- clip : bool
- color : color
- contentHeight : real
- contentWidth : real
- effectiveHorizontalAlignment : enumeration
- elide : enumeration
- font.bold : bool
- font.capitalization : enumeration
- font.family : string
- font.hintingPreference : enumeration
- font.italic : bool
- font.letterSpacing : real
- font.pixelSize : int
- font.pointSize : real
- font.strikeout : bool
- font.styleName : string
- font.underline : bool
- font.weight : enumeration
- font.wordSpacing : real
- fontInfo.bold : bool
- fontInfo.family : string
- fontInfo.italic : bool
- fontInfo.pixelSize : string
- fontInfo.pointSize : real
- fontInfo.styleName : string
- fontInfo.weight : int
- fontSizeMode : enumeration
- horizontalAlignment : enumeration
- hoveredLink : string
- leftPadding : real
- lineCount : int
- lineHeight : real
- lineHeightMode : enumeration
- linkColor : color
- maximumLineCount : int
- minimumPixelSize : int
- minimumPointSize : int
- padding : real
- renderType : enumeration
- rightPadding : real
- style : enumeration
- styleColor : color
- text : string
- textFormat : enumeration
- topPadding : real
- truncated : bool
- verticalAlignment : enumeration
- wrapMode : enumeration
Signals
- lineLaidOut(object line)
- linkActivated(string link)
- linkHovered(string link)
Methods
- forceLayout()
- linkAt(real x, real y)
Detailed Description
Text items can display both plain and rich text. For example, red text with a specific font and size can be defined like this:
Text { text: "Hello World!" font.family: "Helvetica" font.pointSize: 24 color: "red" }
Rich text is defined using HTML-style markup:
Text { text: "Hello World!" }
If height and width are not explicitly set, Text will attempt to determine how much room is needed and set it accordingly. Unless wrapMode is set, it will always prefer width to height (all text will be placed on a single line).
The elide property can alternatively be used to fit a single line of plain text to a set width.
Note that the Supported HTML Subset is limited. Also, if the text contains HTML img tags that load remote images, the text is reloaded.
Text provides read-only text. For editable text, see TextEdit.
See also Fonts example.
Property Documentation
baseUrl : url |
This property specifies a base URL which is used to resolve relative URLs within the text.
Urls are resolved to be within the same directory as the target of the base URL meaning any portion of the path after the last '/' will be ignored.
| Base URL | Relative URL | Resolved URL |
|---|---|---|
| http://qt-project.org/ | images/logo.png | http://qt-project.org/images/logo.png |
| http://qt-project.org/index.html | images/logo.png | http://qt-project.org/images/logo.png |
| http://qt-project.org/content | images/logo.png | http://qt-project.org/content/images/logo.png |
| http://qt-project.org/content/ | images/logo.png | http://qt-project.org/content/images/logo.png |
| http://qt-project.org/content/index.html | images/logo.png | http://qt-project.org/content/images/logo.png |
| http://qt-project.org/content/index.html | ../images/logo.png | http://qt-project.org/images/logo.png |
| http://qt-project.org/content/index.html | /images/logo.png | http://qt-project.org/images/logo.png |
The default value is the url of the QML file instantiating the Text item.
These properties hold the padding around the content. This space is reserved in addition to the contentWidth and contentHeight.
This QML property was introduced in Qt 5.6.
This property holds whether the text is clipped.
Note that if the text does not fit in the bounding rectangle it will be abruptly chopped.
If you want to display potentially long text in a limited space, you probably want to use elide
instead.
Returns the height of the text, including height past the height which is covered due to there being more text than fits in the set height.
Returns the width of the text, including width past the width which is covered due to insufficient wrapping if WrapMode is set.
Sets the horizontal and vertical alignment of the text within the Text items width and height. By default, the text is vertically aligned to the top. Horizontal alignment follows the natural alignment of the text, for example text that is read from left to right will be aligned to the left.
The valid values for horizontalAlignment
are Text.AlignLeft
, Text.AlignRight
, Text.AlignHCenter
and Text.AlignJustify
. The valid values for verticalAlignment
are Text.AlignTop
, Text.AlignBottom
and Text.AlignVCenter
.
Note that for a single line of text, the size of the text is the area of the text. In this common case, all alignments are equivalent. If you want the text to be, say, centered in its parent, then you will need to either modify the Item::anchors, or set horizontalAlignment to Text.AlignHCenter and bind the width to that of the parent.
When using the attached property LayoutMirroring::enabled to mirror application layouts, the horizontal alignment of text will also be mirrored. However, the property horizontalAlignment
will remain unchanged. To query the effective horizontal alignment of Text, use the read-only property effectiveHorizontalAlignment
.
Set this property to elide parts of the text fit to the Text item's width. The text will only elide if an explicit width has been set.
This property cannot be used with rich text.
Eliding can be:
- Text.ElideNone - the default
- Text.ElideLeft
- Text.ElideMiddle
- Text.ElideRight
If this property is set to Text.ElideRight, it can be used with wrapped text. The text will only elide if maximumLineCount
, or height
has been set. If both maximumLineCount
and height
are set, maximumLineCount
will apply unless the lines do not fit in the height allowed.
If the text is a multi-length string, and the mode is not Text.ElideNone
, the first string that fits will be used, otherwise the last will be elided.
Multi-length strings are ordered from longest to shortest, separated by the Unicode "String Terminator" character U009C
(write this in QML with "\u009C"
or "\x9C"
).
Sets the capitalization for the text.
- Font.MixedCase - This is the normal text rendering option where no capitalization change is applied.
- Font.AllUppercase - This alters the text to be rendered in all uppercase type.
- Font.AllLowercase - This alters the text to be rendered in all lowercase type.
- Font.SmallCaps - This alters the text to be rendered in small-caps type.
- Font.Capitalize - This alters the text to be rendered with the first character of each word as an uppercase character.
Text { text: "Hello"; font.capitalization: Font.AllLowercase }
Sets the family name of the font.
The family name is case insensitive and may optionally include a foundry name, e.g. "Helvetica [Cronyx]". If the family is available from more than one foundry and the foundry isn't specified, an arbitrary foundry is chosen. If the family isn't available a family will be set using the font matching algorithm.
Sets the preferred hinting on the text. This is a hint to the underlying text rendering system to use a certain level of hinting, and has varying support across platforms. See the table in the documentation for QFont::HintingPreference for more details.
Note: This property only has an effect when used together with render type Text.NativeRendering.
Font.PreferDefaultHinting - Use the default hinting level for the target platform.
Font.PreferNoHinting - If possible, render text without hinting the outlines of the glyphs. The text layout will be typographically accurate, using the same metrics as are used e.g. when printing.
Font.PreferVerticalHinting - If possible, render text with no horizontal hinting, but align glyphs to the pixel grid in the vertical direction. The text will appear crisper on displays where the density is too low to give an accurate rendering of the glyphs. But since the horizontal metrics of the glyphs are unhinted, the text's layout will be scalable to higher density devices (such as printers) without impacting details such as line breaks.
Font.PreferFullHinting - If possible, render text with hinting in both horizontal and vertical directions. The text will be altered to optimize legibility on the target device, but since the metrics will depend on the target size of the text, the positions of glyphs, line breaks, and other typographical detail will not scale, meaning that a text layout may look different on devices with different pixel densities.
Text { text: "Hello"; renderType: Text.NativeRendering; font.hintingPreference: Font.PreferVerticalHinting }
This QML property was introduced in Qt 5.8.
Sets the letter spacing for the font.
Letter spacing changes the default spacing between individual letters in the font. A positive value increases the letter spacing by the corresponding pixels; a negative value decreases the spacing.
Sets the font size in pixels.
Using this function makes the font device dependent. Use pointSize
to set the size of the font in a device independent manner.
Sets the style name of the font.
The style name is case insensitive. If set, the font will be matched against style name instead of the font properties font.weight, font.bold and font.italic.
This QML property was introduced in Qt 5.6.
Sets the font's weight.
The weight can be one of:
- Font.Thin
- Font.Light
- Font.ExtraLight
- Font.Normal - the default
- Font.Medium
- Font.DemiBold
- Font.Bold
- Font.ExtraBold
- Font.Black
Text { text: "Hello"; font.weight: Font.DemiBold }
Sets the word spacing for the font.
Word spacing changes the default spacing between individual words.
The bold state of the font info that has been resolved for the current font and fontSizeMode. This is true if the weight of the resolved font is bold or higher.
This QML property was introduced in Qt 5.9.
The family name of the font that has been resolved for the current font and fontSizeMode.
This QML property was introduced in Qt 5.9.
The italic state of the font info that has been resolved for the current font and fontSizeMode.
This QML property was introduced in Qt 5.9.
The pixel size of the font info that has been resolved for the current font and fontSizeMode.
This QML property was introduced in Qt 5.9.
The pointSize of the font info that has been resolved for the current font and fontSizeMode.
This QML property was introduced in Qt 5.9.
The style name of the font info that has been resolved for the current font and fontSizeMode.
This QML property was introduced in Qt 5.9.
The weight of the font info that has been resolved for the current font and fontSizeMode.
This QML property was introduced in Qt 5.9.
This property specifies how the font size of the displayed text is determined. The possible values are:
- Text.FixedSize (default) - The size specified by font.pixelSize or font.pointSize is used.
- Text.HorizontalFit - The largest size up to the size specified that fits within the width of the item without wrapping is used.
- Text.VerticalFit - The largest size up to the size specified that fits the height of the item is used.
- Text.Fit - The largest size up to the size specified that fits within the width and height of the item is used.
The font size of fitted text has a minimum bound specified by the minimumPointSize or minimumPixelSize property and maximum bound specified by either the font.pointSize or font.pixelSize properties.
Text { text: "Hello"; fontSizeMode: Text.Fit; minimumPixelSize: 10; font.pixelSize: 72 }
If the text does not fit within the item bounds with the minimum font size the text will be elided as per the elide property.
Sets the horizontal and vertical alignment of the text within the Text items width and height. By default, the text is vertically aligned to the top. Horizontal alignment follows the natural alignment of the text, for example text that is read from left to right will be aligned to the left.
The valid values for horizontalAlignment
are Text.AlignLeft
, Text.AlignRight
, Text.AlignHCenter
and Text.AlignJustify
. The valid values for verticalAlignment
are Text.AlignTop
, Text.AlignBottom
and Text.AlignVCenter
.
Note that for a single line of text, the size of the text is the area of the text. In this common case, all alignments are equivalent. If you want the text to be, say, centered in its parent, then you will need to either modify the Item::anchors, or set horizontalAlignment to Text.AlignHCenter and bind the width to that of the parent.
When using the attached property LayoutMirroring::enabled to mirror application layouts, the horizontal alignment of text will also be mirrored. However, the property horizontalAlignment
will remain unchanged. To query the effective horizontal alignment of Text, use the read-only property effectiveHorizontalAlignment
.
This property contains the link string when the user hovers a link embedded in the text. The link must be in rich text or HTML format and the hoveredLink string provides access to the particular link.
This QML property was introduced in Qt 5.2.
See also linkHovered and linkAt().
These properties hold the padding around the content. This space is reserved in addition to the contentWidth and contentHeight.
This QML property was introduced in Qt 5.6.
Returns the number of lines visible in the text item.
This property is not supported for rich text.
See also maximumLineCount.
Sets the line height for the text. The value can be in pixels or a multiplier depending on lineHeightMode.
The default value is a multiplier of 1.0. The line height must be a positive value.
This property determines how the line height is specified. The possible values are:
- Text.ProportionalHeight (default) - this sets the spacing proportional to the line (as a multiplier). For example, set to 2 for double spacing.
- Text.FixedHeight - this sets the line height to a fixed line height (in pixels).
The color of links in the text.
This property works with the StyledText textFormat, but not with RichText. Link color in RichText can be specified by including CSS style tags in the text.
This property specifies the minimum font pixel size of text scaled by the fontSizeMode property.
If the fontSizeMode is Text.FixedSize or the font.pixelSize is -1 this property is ignored.
This property specifies the minimum font point size of text scaled by the fontSizeMode property.
If the fontSizeMode is Text.FixedSize or the font.pointSize is -1 this property is ignored.
These properties hold the padding around the content. This space is reserved in addition to the contentWidth and contentHeight.
This QML property was introduced in Qt 5.6.
Override the default rendering type for this component.
Supported render types are:
- Text.QtRendering - the default
- Text.NativeRendering
Select Text.NativeRendering if you prefer text to look native on the target platform and do not require advanced features such as transformation of the text. Using such features in combination with the NativeRendering render type will lend poor and sometimes pixelated results.
These properties hold the padding around the content. This space is reserved in addition to the contentWidth and contentHeight.
This QML property was introduced in Qt 5.6.
Set an additional text style.
Supported text styles are:
- Text.Normal - the default
- Text.Outline
- Text.Raised
- Text.Sunken
Row { Text { font.pointSize: 24; text: "Normal" } Text { font.pointSize: 24; text: "Raised"; style: Text.Raised; styleColor: "#AAAAAA" } Text { font.pointSize: 24; text: "Outline";style: Text.Outline; styleColor: "red" } Text { font.pointSize: 24; text: "Sunken"; style: Text.Sunken; styleColor: "#AAAAAA" } }
Defines the secondary color used by text styles.
styleColor
is used as the outline color for outlined text, and as the shadow color for raised or sunken text. If no style has been set, it is not used at all.
Text { font.pointSize: 18; text: "hello"; style: Text.Raised; styleColor: "gray" }
See also style.
The text to display. Text supports both plain and rich text strings.
The item will try to automatically determine whether the text should be treated as styled text. This determination is made using Qt::mightBeRichText().
The way the text property should be displayed.
Supported text formats are:
- Text.AutoText (default)
- Text.PlainText
- Text.StyledText
- Text.RichText
If the text format is Text.AutoText
the Text item will automatically determine whether the text should be treated as styled text. This determination is made using Qt::mightBeRichText() which uses a fast and therefore simple heuristic. It mainly checks whether there is something that looks like a tag before the first line break. Although the result may be correct for common cases, there is no guarantee.
Text.StyledText is an optimized format supporting some basic text styling markup, in the style of HTML 3.2:
 - bold  - bold  - italic
 - new line
 - paragraph  - underlined text
 to
 - headers  - anchor  - inline images
,
 and
 - ordered and unordered lists

 - preformatted > < &
Text.StyledText
parser is strict, requiring tags to be correctly nested.
Column { Text { font.pointSize: 24 text: "Hello World!" } Text { font.pointSize: 24 textFormat: Text.RichText text: "Hello World!" } Text { font.pointSize: 24 textFormat: Text.PlainText text: "Hello World!" } } |
Text.RichText supports a larger subset of HTML 4, as described on the Supported HTML Subset page. You should prefer using Text.PlainText or Text.StyledText instead, as they offer better performance.
These properties hold the padding around the content. This space is reserved in addition to the contentWidth and contentHeight.
This QML property was introduced in Qt 5.6.
Returns true if the text has been truncated due to maximumLineCount or elide.
This property is not supported for rich text.
See also maximumLineCount and elide.
Sets the horizontal and vertical alignment of the text within the Text items width and height. By default, the text is vertically aligned to the top. Horizontal alignment follows the natural alignment of the text, for example text that is read from left to right will be aligned to the left.
The valid values for horizontalAlignment
are Text.AlignLeft
, Text.AlignRight
, Text.AlignHCenter
and Text.AlignJustify
. The valid values for verticalAlignment
are Text.AlignTop
, Text.AlignBottom
and Text.AlignVCenter
.
Note that for a single line of text, the size of the text is the area of the text. In this common case, all alignments are equivalent. If you want the text to be, say, centered in its parent, then you will need to either modify the Item::anchors, or set horizontalAlignment to Text.AlignHCenter and bind the width to that of the parent.
When using the attached property LayoutMirroring::enabled to mirror application layouts, the horizontal alignment of text will also be mirrored. However, the property horizontalAlignment
will remain unchanged. To query the effective horizontal alignment of Text, use the read-only property effectiveHorizontalAlignment
.
Set this property to wrap the text to the Text item's width. The text will only wrap if an explicit width has been set. wrapMode can be one of:
- Text.NoWrap (default) - no wrapping will be performed. If the text contains insufficient newlines, then contentWidth will exceed a set width.
- Text.WordWrap - wrapping is done on word boundaries only. If a word is too long, contentWidth will exceed a set width.
- Text.WrapAnywhere - wrapping is done at any point on a line, even if it occurs in the middle of a word.
- Text.Wrap - if possible, wrapping occurs at a word boundary; otherwise it will occur at the appropriate point on the line, even in the middle of a word.
Signal Documentation
This signal is emitted for each line of text that is laid out during the layout process. The specified line object provides more details about the line that is currently being laid out.
This gives the opportunity to position and resize a line as it is being laid out. It can for example be used to create columns or lay out text around objects.
The properties of the specified line object are:
- number (read-only)
- x
- y
- width
- height
For example, this will move the first 5 lines of a Text item by 100 pixels to the right:
onLineLaidOut: { if (line.number < 5) { line.x = line.x + 100 line.width = line.width - 100 } }
The corresponding handler is onLineLaidOut
.
This signal is emitted when the user clicks on a link embedded in the text. The link must be in rich text or HTML format and the link string provides access to the particular link.
Text { textFormat: Text.RichText text: "See the Qt Project website." onLinkActivated: console.log(link + " link activated") }
The example code will display the text "See the Qt Project website."
Clicking on the highlighted link will output http://qt-project.org link activated
to the console.
The corresponding handler is onLinkActivated
.
This signal is emitted when the user hovers a link embedded in the text. The link must be in rich text or HTML format and the link string provides access to the particular link.
The corresponding handler is onLinkHovered
.
This QML signal was introduced in Qt 5.2.
See also hoveredLink and linkAt().
Method Documentation
Returns the link string at point x, y in content coordinates, or an empty string if no link exists at that point.
This QML method was introduced in Qt 5.3.
See also hoveredLink.


Before Change
// get adversarial examples
ADV_PATH = os.path.join(DATA_PATH, "adversarial", "mnist", "fgsm", "cnn", "relu", "")
for eps in range(1, 11):
X = np.load(ADV_PATH + "eps%.2f_train.npy" % (eps/10))
scores = model.evaluate(X, Y_train, verbose=args.verbose)
v_print("\naccuracy on train adversarial with %.2f eps: %.2f%%" % (eps/10, scores[1] * 100))
X = np.load(ADV_PATH + "eps%.2f_test.npy" % (eps/10))
scores = model.evaluate(X, Y_test, verbose=args.verbose)
v_print("\naccuracy on test adversarial with %.2f eps: %.2f%%" % (eps/10, scores[1] * 100))
After Change
model = cnn.load_model(MODEL_PATH, "best-weights.h5")
// ------------------------------------------------------------------------------------------------------- TEST
results = {}
// get MNIST
(X_train, Y_train), (X_test, Y_test) = load_mnist()
// Test on true train instances
scores = model.evaluate(X_train, Y_train, verbose=args.verbose)
v_print("\naccuracy on train: %.2f%%" % (scores[1] * 100))
results["train_accuracy"] = scores[1] * 100
// Test on true test instances
scores = model.evaluate(X_test, Y_test, verbose=args.verbose)
v_print("\naccuracy on test: %.2f%%" % (scores[1] * 100))
results["test_accuracy"] = scores[1] * 10
// get adversarial examples
ADV_PATH = os.path.join(DATA_PATH, "adversarial", "mnist")
for filepath in get_npy_files(ADV_PATH):
X = np.load(filepath)
Y = Y_train if "_train" in filepath else Y_test
scores = model.evaluate(X, Y, verbose=args.verbose)
v_print("\naccuracy on %s: %.2f%%" % (filepath, scores[1] * 100))
results[filepath] = scores[1]*100
with open(os.path.join(MODEL_PATH, "accuracies.json"), "w") as json_file:
json.dump(results, json_file)


Software Developer
I have worked on a number of projects both at the office, and at home. These include games and apps, realized via different technologies for web, android and flash (when it was cool). I handle mostly front-end business and visual logic; my back-end work consists predominantly of multiplayer server logic, and simple rest api and websites.
I started with UI design and went deeper and deeper into work, involving more complex code structure, good patterns, and project planning, from one project to the next, each requiring skills in new languages, frameworks or third-party services, which, depending on the product, can be immensely exciting.
I have a deep interest in my industry, but I am most passionate about innovative, interesting game or app ideas. Although I haven't done official work as such, I have professional interest in, and study as much as I can about game-design as well.
<EMAIL_ADDRESS>Varna, Bulgaria
[+359] 886 791-663


Contents
HSLCOLORMAP DEMO
hslcolormap is a tool that helps you create nice looking colormaps in hue-saturation-lightness space. You can use this to create colormaps that have a progressive change in lightness.
close all
A Negative to positive divergent colormap
[cool shades]-[white]-[warm shades]
surf(peaks); caxis([-7 7]) S=1; %fully saturated L=[.1 1 .1]; %dark-white-dark hslcolormap('mbbccc.YYYRRm',S,L) %magenta-blue-cyan / yellow-red-magenta colorbar
Simple landscape colormap
first make a random landscape:
[X,Y]=meshgrid(-299:300); Z=abs(ifft2(ifftshift((hypot(Y,X)+1e-5).^(-2.1).*exp(rand(size(X))*2i*pi)))); %example terrain inspired by rafael.pinto Z=(Z-Z(300,300))*1000/std(Z(:)); surf(Z) material dull camlight shading interp camorbit(3,2,4) caxis([-1 1]*max(caxis)) axis off %Then make water blue and land green hslcolormap('mc.yc',[1 0],[.1 .3 1]) colorbar
Double rainbow
A not very pretty colormap, but it is makes it easy to relate a color on the plot to a specific value on the colorbar.
Warning: rainbow colormaps are hard to read for color blind, however the steady progression in lightness helps.
surf(peaks); shading interp H=[0 2]; %hues automatically wrap around the color circle S=1; L=[.1 .99]; %dark-bright hslcolormap(H,S,L) colorbar
Tripled hue gradient
Construct a colormap that runs 3 times through a short hue gradient Hide discontinuities with gray, and progressively brighten
surf(peaks); shading interp H='mc.mc.mc'; % 3 x magneta-cyan S=[1 1 0 1 0 1 1]*.8; L=[.1 .99]; %dark-bright hslcolormap(H,S,L) colorbar
Hot
somewhat similar to matlab's own hot colormap
surf(peaks); H='rryy' %red-red-yellow-yellow. S=1; L=[0 1]; % hslcolormap(H,S,L) colorbar
H = rryy
Cold
A variation that is similar to matlab's cool colormap but with stronger variation in lightness.
discrete number of steps
surf(peaks); H='cm'; %cyan-magenta caxis([-8 8]) hslcolormap(32,H,1,.6) colorbar
Random single hue colormap
surf(peaks); H=rand; S=rand*.5+.5; L=[.01 .99]; hslcolormap(H,S,L) colorbar
Divergent with gray in middle
contourf(peaks,-8:8);
H='Rm.yg';
S=[1 0 1];
L=[.1 .85 .1];
caxis([-8 8])
hslcolormap(H,S,L)
colorbar


SELCT is actively seeking researchers who are interested in working at the junction of engineering and sonic arts. SELCT's research focuses on sound art and sculpture, applied music information retrieval, musical mechatronics, and new musical interface design.
Those seeking to pursue postgraduate studies at the doctorate or masters level should first contact one of the SELCT faculty: Jim Murphy, Dale A. Carnegie, Ajay Kapur, Mo H. Zareei, Michael Norris, and Dugal McKinnon. In your introductory email, please include a brief mention of your areas of interest as well as a CV.
SELCT’s physical address is:
SELCT, care of Jim Murphy
New Zealand School of Music
Gate 7, Kelburn Parade
Victoria University of Wellington
Wellington, New Zealand 6012
Useful links:


{% extends "_page.html" %} {% block intro %} Lambdas and closures. {% endblock %} {% block description %} Lambdas (and closures) were added to C++ in C++11 and to Java in Java 8. Rust has always had them.
In C++ you are required to specify the values that are captured by the lambda. In Java and Rust the compiler handles capturing without specifying the values. {% endblock %}


This page was created by nicolascribbles to complete her Web Development Certification. She is looking for work.

Philip Morris convinced officials of the Czech Republic that smoking would help their economy,
because healthcare costs would decrease from its citizens dying early.
The Coolest Guy in town, here is photographic evidence next to an icon.
Jeff The Diseased Lung next to the Amazing John Oliver.
Jeff making an appearance in Some country we don't know about.
If you have never seen John Oliver, You're Welcome.
Journalism is dead, and John Oliver is our savior.
"The HBO host spent about 20 minutes ripping into the tobacco company's threats of lawsuits -- especially in poorer nations such as Togo -- in what Oliver called an attempt to ward off more stringent regulations on cigarettes, such as laws that require cigarette boxes to feature pictures of diseased body parts and warnings of the health consequences of smoking." (SOURCE)
The fun loving warning label that doesn't look so official. Truly, it's compromise. Don't be mad.  I don't need to strike that word. You know which one. It should be there.
My name is Nicola, I was born and raised in Venezuela until the age of 8 when I moved to the United States. I began my coding and graphic design hobbies as a young child. I look to find some purpose in the world where I can apply my talents.
#WomenInTech
Check Out My Website


Body
Header
Home
First
Second
Third
Section
Article
Article Header
Article contents
Section
SideBar Header
April 2018
March 2018
February 2018
January 2018


3 arrested in downtown Vancouver climate protests
by Lisa Steacy and Renee BernardSummary
The “Funeral For Extinction” protest was organized by Extinction Rebellion
Police are not releasing any information about the arrests, but the intersection of Robson and Burrard is blocked
Ten protesters from Extinction Rebellion were arrested after they blocked the Burrard Street Bridge in October
VANCOUVER (NEWS 1130) — Three protesters taking part in a mock funeral procession through downtown Vancouver have been arrested.
The “Funeral For Extinction” protest was organized by Extinction Rebellion.
Police are not releasing any more information about the arrests, but the intersection of Robson and Burrard has been blocked off.
The arrests happened after several tripod-like structures were erected, blocking traffic.
Police and the fire department were called to the scene.
Flora, who wouldn’t provide her last name, arrived just after the arrests.
“A few rebels installed themselves on top of tripods at Robson and Burrard. I was sort of an occupation of that intersection. I just saw the end of it when they got taken down. They went peacefully and it was just sort of part of the disruption.”
After the arrests, the group moved on to Robson and Thurlow.
She says the protesters understand that their demonstrations can be frustrating for people driving and shopping downtown. But Friday’s action is meant to challenge business as usual.
“Robson is a popular shopping spot. So, we’ll maybe get people to think a little bit about whether they really need all that stuff in their bags or whether they could be doing something better with their time, like joining us in the street.”
Since the event started at 1 p.m., traffic has been disrupted by people walking through the city’s commercial and financial districts near Robson and Burrard.
The group chose to host the event on Black Friday because of what they describe as the “over-consumption of unnecessary goods.”
“We will mourn for the future of our planet, our ecosystems, and the lives lost due to climate crisis,” organizers said in a Facebook post.
Before the protest, a spokesperson said the demonstration will “provide an alternative to the culture of corporate consumerism that has contributed to climate change.”
Ten protesters from Extinction Rebellion were arrested after they blocked the Burrard Street Bridge in October.
With files from Kurtis Doering


Reinforcement learning
Posted: 2016-09-28 , Modified: 2016-10-07
Tags: reinforcement learning
Posted: 2016-09-28 , Modified: 2016-10-07
Tags: reinforcement learning
| Type | Evaluate Q, V knowing dynamics | Not knowing dynamics (online) | On-policy control | Off-policy control | Learning policy |
|---|---|---|---|---|---|
| Discrete | Q-iteration | TD(\(\la\)) | Sarsa | Q-learning | |
| Continuous | fitted Q-iteration | gradient TD(\(\la\)) | Gradient Sarsa | Gradient Q-learning | Policy gradient |
All discrete methods have convergence guarantees.
For continuous methods: (I think you can replace linear function class by “local min for function class” everywhere here.)
Bellman optimality equations
\[\begin{align} v_*(s) &= \max_\pi v_\pi(s)\\ q_*(s,a) &= \max_\pi q_\pi(s,a)\\ v_*(s)&= \max_{a\in \mathcal A(s)} \sum_{s'} p(s'|s,a) [r(s,a,s') + \ga v_*(s')\\ q_*(s,a) &= \sum_{s'} p(s'|s,a) [r(s,a,s') +\ga \max_{a'} q_*(s',a')]. \end{align}\]3 assumptions that are rarely all true in practice:
Many decision-making methods attempt to approximately solve the Bellman optimal equations.
A RL algorithm puts more effort into learning good decisions for frequently encountered states.
Three classes of methods for solving MDP’s.
Think of other methods as attempts to achieve the same effect as DP with less computation and without a perfect model.
Use value functions to organize the search for good policies.
Iterative policy evaluation: (make value function consistent with current policy) \[ v_{k+1}(s) = \sum_a \pi(a|s) \sum_{s'} p(s'|s,a) [r(s,a,s') + \ga v_k(s')]. \] This is a full backup because we calculate \(v_k(s)\) for all \(s\) in each stage. (TODO: prove convergence.) Stop when maximum difference \(\max_{s\in S}|v_{k-1}(s)-v_k(s)|<\te\).
(Can also update in-place. Then update order makes a difference.)
Policy improvement theorem. If \(\pi,\pi'\) are deterministic policies such that for all \(s\in S\), \[q_\pi(s,\pi'(s))\ge v_\pi(s),\] then \(\pi'\) is at least as good as \(\pi\), \(v_{\pi'}(s) \ge v_\pi(s)\).
Proof. Unfold and note convergence.
This shows that iterative policy improvement can only help: \[ \pi'(s) = \amax_a \sum_{s'} p(s'|s,a) [r(s,a,s') + \ga v_\pi(s')]. \] If it stops improving, then \(\pi'\) is optimal.
Policy iteration: \(\pi_k\xra E v_{\pi_k} \xra I \pi_{k+1}\). Alternately evaluate and improve.
Above, to evaluate, we have to keep doing policy iterations until convergence. For speed, we just do one (or a few) step of policy evaluation. Combining the improvement and evaluation steps: \[v_{k+1} := \max_a \sum_{s'} p(s'|s,a)[r(s,a,s') + \ga v_k(s')].\] (cf. EM/AM?)
Asynchronous DP: back up values of states in any order, using whatever values of other states are available. Can do with value iteration and policy iteration. Helps intermix computation with interaction (actually experiencing MDP—apply backups as agent visits states).
The time that DP methods take is polynomial in number of states and actions. LP can be used to solve MDP’s but become impractical at smaller number of states than DP.
Don’t assume complete knowledge of the environment. Learn from online and simulated experience. The model only needs to generate sample transitions rather than give a complete probability distribution.
MC assumes experience is divided into episodes.
Each occurrence of a state in an episode is a visit.
DP shows all possible transitions but the MC diagram only shows those sampled on one episode.
(Ex. of finding bubble surface given wire frame. Iterative = compute surface iteratively by averaging at each point. MC = take a random walk from each point; expected height at boundary is approximation of height. This is more efficient if we are interested in a small number of points.)
If the model is not available, it’s mre useful to estimate action than state values. (From the action-value function \(q\) we can directly construct the greedy policy.)
Problem: if you follow a deterministic policy, you will only observe one action from each state.
Solution: Explore! Assume each state-action pair has a nonzero probability of being selected at the start of an episode (exploring starts). More realistic: consider policies that are stochastic with nonzero probability of selecting all actions.
This works assuming:
MC ES cannot converge to any suboptimal policy (if it did, the value function converges to the value function for that policy, and the policy changes). Open question: does it always converge? [Tsitsiklis02]
Improve the policy used to make decisions.
Soft policy: \(\forall s,a\in \mathcal A(s), \pi(a|s)>0\). \(\ep\)-soft: \(\ge \fc{\ep}{|\mathcal A(s)|}\).
Policy iterations works for \(\ep\)-soft policies.
What if we have episodes generated from a different policy?
Ex. estimation policy may be deterministic while behavior policy samples all possible actions.
To do this, after generating an episode, look at the last time where \(A_\tau \ne \pi(S_\tau)\), and update \(Q\) using pairs \((s,a)\) appearing after that time.
Note: only learns from tails of episodes. Learning is slow if nongreedy actions are frequent.
Advantages of MC:
Maintaining sufficient exploration is an issue.
MC uses experience and does not bootstrap (update value based on other value estimates) (instead MC waits for a bunch of samples), unlike DP.
Next chapter: experience + bootstrap.
Sampling by the entire product \(\prod \fc{\pi(A_i|S_i)}{\mu(A_i|S_i)}\) has a lot of variance and is unnecessary. Scale by the first factor and use previous updates.
Think of discounting as determining a probability of termination or, equivalently, a degree of partial termination.
Write full return as sum of discounted partial returns. (Idea: any long sequence will be weighted down by a large discount factor.) \[\begin{align} \ol G_t^h :&= R_{t+1}+\cdots +R_h\\ G_t :&= \sumo i{T-t}\ga^{i-1} R_{t+i}\\ &= (1-\ga) \sum_{h=t+1}^{T-1} \ga^{h-t-1} \ol G_t^h + \ga^{T-t-1} \ol G_t^T \end{align}\] Ordinary and weighted importance-sampling estimator: \[\begin{align} V(s) :&= \fc{ \sum_{t\in T(s)}(1-\ga) \sum_{h=t+1}^{T-1} \ga^{h-t-1} \blu{\rh_t^h} \ol G_t^h + \ga^{T-t-1} \blu{\rh_t^{T(t)}}\ol G_t^T }{|T(s)|}\\ V(s) :&= \fc{ \sum_{t\in T(s)}(1-\ga) \sum_{h=t+1}^{T-1} \ga^{h-t-1} \blu{\rh_t^h} \ol G_t^h + \ga^{T-t-1} \blu{\rh_t^{T(t)}}\ol G_t^T }{ \sum_{t\in T(s)}(1-\ga) \sum_{h=t+1}^{T-1} \ga^{h-t-1} \blu{\rh_t^h} + \ga^{T-t-1} \blu{\rh_t^{T(t)}} } \end{align}\] Per-reward importance sampling: Note \[\begin{align} \E_\mu [\rh_tR_{t+k}] &= \E[\rh_t^{t+k} R_{t+k}]\\ \E[\rh_t^T G_t] &= \E[\wt G_t]\\ \wt G_t &= \sumo k{T-t} \ga^{k-1}\rh_t^{t+k}R_{t+k}\\ V(s) :&= \fc{\sum_{t\in T(s)}\wt G_t}{|T(s)|}. \end{align}\]Not clear how to extend to weighted importance sampling.
MC methods can incrementally update \(V\), after waiting to get the actual return, \[V(S_t) \mapsfrom V(S_t) + \al [G_t-V(S_t)].\] (n.b. \(S_t\) is the state at time \(t\), not the state labeled \(t\).) TD methods only wait until the next time step. \[V(S_t) \mapsfrom V(S_t) + \al [R_{t+1} + \ga V(S_{t+1})-V(S_t)]. \] I.e., it uses the estimate of \(v_\pi = \EE_\pi [R_{t+1}+\ga v_\pi(S_{t+1})|S_t=s]\) as a target.
TD samples expected values and uses the current estimate \(V\) instead of \(v_\pi\).
Each estimate is shifted towards the estimate that immediately follows it.
p. 133: driving home example.
In practice, TD methods converge faster than constant-\(\al\) MC methods on stochastic tasks.
Finite amount of experience: present it repeatedly until method converges. (cf. SGD?) Do batch updates.
Ex. p.139 example is enlightening.
Batch Monte Carlo methods always find the estimates that minimize mean-squared error on the training set, whereas batch TD(0) always finds the estimates that would be exactly correct for the maximum-likelihood model of the Markov process.
For state-action pairs: \[Q(S_t,A_t) \mapsfrom Q(S_t,A_t) + \al [R_{t+1} + \ga Q(S_{t+1}, A_{t+1})-Q(S_t,A_t)]. \] (\(A_{t+1}\) is the action chosen by the (\(\ep\)-greedy?1) policy on \(S_{t+1}\).) SARSA refers to \((S_t,A_t,R_{t+1},S_{t+1},A_{t+1})\).
(Convergence guarantees: p. 142)
SARSA can learn during the episode!
One-step Q-learning
\[ Q(S_t,A_t)\leftarrow Q(S_t,A_t) + \al [R_{t+1} + \ga \max_a Q(S_{t+1},a) - Q(S_t,A_t)]. \]
\(Q\) approximates the optimal \(q_*\) independently of the policy being followed!
TODO: prove this. [Watkins Dayan 1992] [JJS94] [T94]
Ex. cliff
A conventional state-value function evaluates states in which the agent has the option of selecting an action (arrived at \(s'\) where you will select a new \(a'\)), but the state-value function in games of perfect information evaluates the board after the agent has mades its move—afterstates.
This is more efficient: many position-move pairs produce the same resulting position.
Often it’s useful to break the environment’s dynamics into
A general mechanism that can be combined with any TD method.
2 views:
Perform backup based on an intermediate number of rewards. (MC depends on entire sequence until end of episode, TD depends on 1 next reward.)
Replace the 1-step target by \(n\)-step target (corrected \(n\)-step truncated return). \[\begin{align} G_t^{(1)} &= R_{t+1} + \ga V(S_{t+1})\\ G_t^{(n)} &= \sumo i{n-1} \ga^{i-1} R_{t+i} + \ga^n V(S_{t+n})\\ \De V_t(S_t) &= \al [G_t^{(n)} - V_t(S_t)]. \end{align}\]MC methods are infinite-step returns.
2 ways to update.
Error-reduction property of \(n\)-step returns: (exponential reduction in worst-case error) \[ \max_s\ab{\EE_\pi\ba{G_t^{(n)} | S_t=s}-v_\pi(s)} \le \ga^n \max_s |v(s) - v_\pi(s)|. \]
Rarely used because inconvenient to implement; waiting \(n\) states is problematic.
Complex backup: Backup can be done toward any average of \(n\)-step returns.
\(TD(\la)\) is averaging \(n\)-step backups \(\propto \la^{n-1}\), i.e., with weights \((1-\la)\la^{n-1}\). The \(\la\)-return is \[ G_t^\la = (1-\la) \sumo n\iy \la^{n-1}G_t^{(n)}. \]
Forward view: look forward to all future rewards and decide how to combine them.
The eligibility trace is a memory variable associated with each state. It is a random variable \(Z_t(s)\in \R^+\), \[ Z_t(s) = \begin{cases} \ga \la Z_{t-1}(s), &\text{if }s\ne S_t\\ \ga \la Z_{t-1}(s) + 1, &\text{if }s=S_t. \end{cases} \] \(\la\) is the trace-decy parameter. Traces indicate the degree to which each state is eligible for undergoing learning changes. \[\De V_t(s) = \al \ub{(R_{t+1}+\ga V_tS_{t+1} - V_t(S_t))}{\de_t} Z_t(s).\]
Note TD(1) is MC but it can also be applied to discounted continuing tasks, and can be applied incrementally and online.
For offline updating, \[\sumz t{T-1} \De V_t^{TD}(s) = \sumz t{T-1} \al \de_t \sumz kt (\ga \la)^{t-k} I_{sS_k} = \sumz t{T-1} V_t^\la(S_t)I_{sS_t}.\] (Online updating is different because \(V_t\) changes as \(t\).)
Online algorithm generally works better over a broader range of parameters.
To maintain equivalence in online case, \(\de_t= R_{t+1} + \ga V_t(S_{t+1})-V_{t-1}(S_t)\), \(R_t^{(n)} = \sumo in \ga^{i-1}R_{t+i} + \ga^n V_{t+n-1}(S_{t+n})\).
We can use subsequent experience only as long as the greedy policy is being followed! Look ahead as far as the next exploratory action.
If \(A_{t+n}\) is first exploratory action, the longest backup is toward \[ \sumo in \ga^{i-1}R_{t+i} + \ga^n \max_a Q_t(s_{t+n},a). \] Q: why 1 step past?
Set eligibility traces to 0 whenever an exploratory action is taken.
But cutting off traces every time an exploratory action is taken loses the advantage of eligibility traces.
Hybrid of Sarsa and Watkin’s \(Q(\la)\).
Converges to some hybrid of \(q_\pi, q_*\). If made gradually more greedy, may still converge to \(q_*\).
Cannot be implemented as simply.
Naive \(Q(\la)\): traces not set to 0.
\[Z_t (s) = \begin{cases} \ga \la Z_{t-1}(s), & s\ne S_t\\ 1, & s=S_t. \end{cases}\] (Max out at 1.)
Can produce significant improvement in learning rate.
Ex. when this helps: reward at rightmost. Sequence WWWWWWWWWWRRRR (wrong stays, right goes right) reinforces W more times.
Another solution: set the traces of all other actions from the revisited state to 0.
Larger computational cost.
Never been used practically, but interesting/useful theoretically.
Ex. Vary as function of state: depend on confidence
\[G_t^\la = \sum_{k=t+1}^{T-1} G_t^{(k-t)} (1-\la_k) \prod_{i=t+1}^{k-1} \la_i + G_t\prod_{i=t+1}^{T-1}\la_i.\]
Planning requires a model of the environment; learning methods don’t.
A model is anything an agent cn use to predict how the environment responds to its actions.
Models can simulate experience.
Planning takes a model as input and produces or improves a policy.
Approaches:
State-space planning methods share common structure.
Go from… to…
Common structure means many ideas/algorithms can be transferred between planning and learning. (They differ only in source of experience.)
Planning in small incremental steps helps intermix planning with acting/learnig.
Two roles for experience:
Dyna-Q: repeat
Q: why is only 1 step added without planning? A: because rewards only go back 1 step.
Dyna-Q+: This agent keeps track for each state{action pair of how many time steps have elapsed since the pair was last tried in a real interaction with the environment. The more time that has elapsed, the greater (we might presume) the chance that the dynamics of this pair has changed and that the model of it is incorrect. Bonus reward for long-untried actions, \(R+\ka \sqrt \tau\) if not tried for \(\tau\) time steps.
Planning can be more efficient if simulated transitions and backups are focused on particular state-action pairs.
Work backwards from goal state/reward?
Ex. change estimated value of 1 state. The only useful 1-state backups are those of actions leading directly into that state. Propagate.
Prioritize backups according to urgency and perform in order of priority.
Problem: algorithms rely on the assumption of discrete states.
For stochastic environments: keep counts. Backup each pair with a full backup.
1-step backups vary in 3 ways.
Sample backups are TD(0), Sarsa, and Q-learning.
Full backup requires \(b\) times as much computation, \(b\) the branching factor.
Sample backups have the advantage that the values backed up from successor states will be more accurate.
2 ways of distributing backups
Experimentally: sampling according to on-policy results in faster planning initially and retarded planning in long run. (In the long run, commonly occurring states already have correct values.)
Heuristic search is concerned with policy computation, i.e., making improved action selections given the current value function.
Unlike in usual heuristic search, it’s natural to consider allowing the value function to be improved.
When we have a perfect model and imperfect \(Q\), deeper search usually yields better policies.
Grow the search tree selectively. How to use this idea for backups?
Focus on the states and actions that might immediately follow the current state.
Start with an single-node tree at the start state. Each iteration:
Question: how to deal with probabilistic choices by opponent? How to backprop?
\[ MSE(\te_t) = \sum_{s\in S} P(s) [V^{\pi}-V_t(s)]^2. \]
If we wish to minimize error over a certain distribution of states, then it makes sense to train the function approximator with examples from that same distribution. let us assume that the distribution of states at which backups are done and the distribution that weights errors, \(P\), are the same.
Complex function approximators may seek to converge instead to a local optimum.
In actuality we get an estimate \(v_t\) of \(V^\pi(s_t)\). Ex. \(v_t=R_t^\la\) is the \(n\)-step TD return (bootstrapping). (Note this is a biased estimator.)
Backward view (check this): \[\begin{align} \te_{t+1} &=\te_t + \al \de_t e_t\\ \de_t &= r_{t+1} + \ga V_t(s_{t+1}) - V_t(s_t)\\ e_t &= \ga \la e_{t-1} + \nb_{\te_t} V_t(s_t). \end{align}\]\[V_t(s) = \te_t^T\phi_s.\]
Here \(\nb_{\te_t} V_t(s) = \phi_s\). The local optimum is the global optimum.
Gradient descent TD(\(\la\)) converges in the linear case if step-size is reduced over time, to \(\te^*\) close to \(\te\), \(MSE(\te_\iy) \le \fc{1-\ga \la}{1-\ga} MSE(\te^*)\). (What does this mean?)
But we may also need features for combinations of natural qualities!
Features correspond to circles (balls) (receptive fields). A point being in a circle means having that feature. Each circle has a parameter \(\te_t\).
The receptive fields of the features are grouped into exhaustive partitions of the input space. Can combine multiple tilings. (Ex. grid discretization, hashing.)
Generalization of coarse-coding to continuous-valued features. \(\phi_s(i) = \exp\pa{-\fc{\ve{s-c_i}^2}{2\si_i^2}}\).
Focus on the complexity of the target function as separate and distinct from the size and dimensionality of the state space. Given a certain level of complexity, we then seek to be able to accurately approximate any target function of that complexity or less. Choose binary features that correspond to particular prototype states.
Use accumulating eligibility traces.
Ex. SARSA on mountain car.
By bootstrapping we mean the updating of a value estimate on the basis of other value estimates. (TD(\(\la\)), \(\la<1\) is bootstrapping, MC is not.)
Ex. linear, gradient-descent function approximation: Bootstrapping only finds near-minimal MSE.
The restriction of the convergence results for bootstrapping methods to the on-policy distribution is of greatest concern.
Baird’s counterexample: on a episodic Markov process with 0 reward, \(\te\) can undergo resonance. Distribution of DP backups is uniform, off-policy. There are also counterexamples similar to Baird’s showing divergence for Q-learning. This is cause for concern because otherwise Q-learning has the best convergence guarantees of all control methods.
It may be possible to guarantee convergence of Q-learning as long as the behavior policy (the policy used to select actions) is sufficiently close to the estimation policy (the policy used in GPI), for example, when it is the \(\varepsilon\)-greedy policy. (open?)
Stability is guaranteed for function approximation methods that do not extrapolate from the observed targets. These methods, called averagers, include nearest neighbor methods and local weighted regression, but not popular methods such as tile coding and backpropagation.
Nonbootstrapping methods can be used with function approximation more reliably and over a broader range of conditions than bootstrapping methods. We can use eligibility traces with \(\la=1\). But bootstrapping is still method of choice.
At this time it is unclear why methods that involve some bootstrapping perform so much better than pure nonbootstrapping methods. It could be that bootstrapping methods learn faster, or it could be that they actually learn something better than nonbootstrapping methods. The available results indicate that nonbootstrapping methods are better than bootstrapping methods at reducing MSE from the true value function, but reducing MSE is not necessarily the most important goal.
“AI = RL + DL”: RL defines objective, DL gives mechanism.
Use deep NN to represent value function, policy, and model.
Value: \(Q\)-network \(Q(s,a,w)\). (either accept \(a\) as input, or list out \(Q\) for all values of \(a\))
Tread \(r+\ga \max_{a'} Q(s',a',w)\) as target. Minimize \[I = (r+\ga \max_a Q(s',a',w) - Q(s,a,w))^2.\]Model - ???
Notes:
Tree search, etc.
Why not greedy?↩


"x" "1" "LEE,MS, LIN,DP AND WANG,CY, MUTAGENICITY OF THE ANTICANCER DRUG,CARACEMIDE, AND RELATED COMPOUNDS FOR SALMONELLA, MUTAT. RES. 172(3):199-209,1986"


If you are attending Build and are interested in seeing how to combine ASP.NET Core and Aurelia , you'll want to attend "Getting Started with Aurelia and ASP.NET Core" this Friday.
In this talk you’ll get a crash course on using Microsoft’s tools to build a new Aurelia ASP.NET Core app. We’ll start by creating the project from scratch and then learn how to use Aurelia’s core concepts, all while watching our application update in realtime in the browser as we develop. The session is on Friday at 12pm and is located in Tech Talk B.
We're also having an Aurelia Meetup in Seattle on Tuesday evening. If you are interested in attending, please contact @mobilemancer on Twitter.
Hope to see you at one of these events!


You can create a new company here:
Name
Website
Description
Logo (Square Image)
Upload
Create Cancel


Data Sturecture and Algorithm, (Coursera)
"This specialization is a mix of theory and practice: you will learn algorithmic techniques for solving various computational problems and will implement about 100 algorithmic coding problems in a programming language of your choice. No other online course in Algorithms even comes close to offering you a wealth of programming challenges that you may face at your next job interview. To prepare you, we invested over 3000 hours into designing our challenges as an alternative to multiple choice questions that you usually find in MOOCs".
Algorithm Part-I
"This course covers the essential information that every serious programmer needs to know about algorithms and data structures, with emphasis on applications and scientific performance analysis of Java implementations. Part I covers elementary data structures, sorting, and searching algorithms. Part II focuses on graph- and string-processing algorithms. All the features of this course are available for free. It does not offer a certificate upon completion."
Algorithm Part- II
"There is no doubt that quantum computers and the quantum internet will have a great impact on our world. But we don’t yet know quite how. As with traditional computers - we will only see the effects in the decades to come. This course will provide you with a basic understanding of quantum computing and the quantum internet. Together, we’ll peek into the fascinating world of quantum phenomena, such as qubits, superposition, and entanglement."
Algorithm Specialization
"Algorithms are the heart of computer science, and the subject has countless practical applications as well as intellectual depth. This specialization is an introduction to algorithms for learners with at least a little programming experience. The specialization is rigorous but emphasizes the big picture and conceptual understanding over low-level implementation and mathematical details. After completing this specialization, you will be well-positioned to ace your technical interviews and speak fluently about algorithms with other programmers and computer scientists."
Analysis of Algorithm
"This course teaches a calculus that enables precise quantitative predictions of large combinatorial structures. In addition, this course covers generating functions and real asymptotics and then introduces the symbolic method in the context of applications in the analysis of algorithms and basic structures such as permutations, trees, strings, words, and mappings."
Python Numpy Tutorial
This is an introductory level of Python which includes fundamentals of programming with concepts in object-oriented programming and introductory data-structures for example list, tuple and dictionary. More concepts in programming is presented in Algorithm and data structure section.
Numpy Cheat Sheet
This is an introductory level of Python which includes fundamentals of programming with concepts in object-oriented programming and introductory data-structures for example list, tuple and dictionary. More concepts in programming is presented in Algorithm and data structure section.
Pandas Cheat Sheet
This is an introductory level of Python which includes fundamentals of programming with concepts in object-oriented programming and introductory data-structures for example list, tuple and dictionary. More concepts in programming is presented in Algorithm and data structure section.
Matplotlib Cheat Sheet
This is an introductory level of Python which includes fundamentals of programming with concepts in object-oriented programming and introductory data-structures for example list, tuple and dictionary. More concepts in programming is presented in Algorithm and data structure section.


{% extends '_include/base.html' %} {% block content %}
This user will be removed from database, but all purchase made from this user will not be removed.


EasyConvert
EasyConvert is a pure JavaScript HTML parser that converts HTML into JSON directly readable by EasyPlate.
This project is a fork of Himalay destined to be integrated with EasyPlate
npm install easyconvert
Usage
var easyconvert = require('easyconvert');
var html = require('fs').readFileSync('/webpage.html');
var json = easyconvert.parse(html);
Installed globally, easyconvert can also be used from the command-line to convert HTML files to JSON files, or as a pipe transform.
easyconvert webpage.html webpage.json
# or as a pipe
echo "
Hello
" | easyconvert > hello.json
Run easyconvert --help
for more information.
Example Input/Output

Easyconvert parsed me...

{
"div_1": {
"tag": "div",
"attribute": {
"class": "post post-featured"
},
"innerHTML": "\n",
"child": {
"p_0": {
"tag": "p",
"attribute": {},
"innerHTML": "Easyconvert parsed me...",
"child": {}
},
"comment": " ...and I liked it. "
}
},
"innerHTML": "\n"
}
Note: Text nodes containing only whitespace were removed from the output for readability.
Features
Synchronous
HTML is turned into JSON, that's it. Easyplate is completely synchronous and does not require any complicated callbacks.
Parses Attributes
Easyplate does a couple things when processing attributes:
- Camel-cases attribute names
- Attributes without values are set to their names (i.e.
disabled
turns intodisabled="disabled"
) - Groups
data-*
attributes into adataset
object - Attempts to caste any value to a number if
!Nan
- Parses the
style
attribute into a hash map
Handles Weirdness
Easyplate handles a lot of HTML's fringe cases, like:
- Closes unclosed tags

...

- Ignores extra closing tags
...
- Properly handles void tags like
<meta>
and
- Properly handles self-closing tags like
<input/>
- Handles
<!doctype>
and<-- comments -->
- Does not parse the contents of


REFENESEN CHEST CONGESTION RELIEF PE- guaifenesin and phenylephrine hydrochloride tablet
REESE PHARMACEUTICAL CO.
Disclaimer: Most OTC drugs are not reviewed and approved by FDA, however they may be marketed if they comply with applicable regulations and policies. FDA has not evaluated whether this product complies.
temporarily relieves symptoms associated with a cough ,the common cold,hay fever or other upper respiratory allergies.
helps loosen phlegm;mucus
clear nasal passageways
loosens nasal congestion
drain bronchial tubes
shrinks swollen membranes
clears stuffy nose
makes coughs more productive
Do not use this product if you are now taking a prescription Monoamine Oxidase inhibitor ; MAIO,
certain drugs for depression,psychiatric or emotional conditions, or Parkinsons Disease or for 2 weeks
after stopping the MAIO drug,if you are uncertain whether your prescription contains an MAIO ,
ask a health professional.
ask a doctor before use if you have
heart disease
high blood pressure
thyroid disease
diabetes
excessive phlegm;mucus
difficulty in urination due to an enlarged prostate gland
persistent or chronic cough such as occurs with smoking,asthma,chronic bronchitis or emphysema
stop use and ask a doctor if
nervousness,dizziness or sleeplessness occurs
symptoms are accompanied by fever,rash,persistent headache or excessive phlegm;mucus.
cough and congestion do not approve within 7 days or tend to recur
these could be signs of a serious condition
directions
Adults and Children 12 years of age and over take 1 caplet every 4 hours as needed
children 6 to under 12 years of age consult a doctor
do not exceed 6 doses in a 24 hour period or as directed by a doctor.
|
REFENESEN CHEST CONGESTION RELIEF
PE guaifenesin/phenylephrine tablet | ||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||
|
| Labeler - REESE PHARMACEUTICAL CO. (004172052) |
| Registrant - REESE PHARMACEUTICAL CO. (004172052) |
| Establishment | |||
| Name | Address | ID/FEI | Business Operations |
|---|---|---|---|
| REESE PHARMACEUTICAL CO. | 004172052 | repack(10956-381), relabel(10956-381) |


REST over Servlet
The REST over Servlet mode applications runs in web container. You need to create a new servlet project to wrap the microservices, pack them into war packages, and load them into the web container to run.
Path for external access
Not like running as a standalone process, when the microservice runs in the web container, the web root and servlet url pattern will be different.
For the traditional development framework, the consumer needs to perceive the complete url of the service; for example, the web root is /mywebapp, the url pattern is /rest, and the business-level path is /application, then consumer must access the service via the url /mywebapp/rest/application.
So when the deployment pattern changes, like from web container to a standalone process, the consumer or producer have to modify the code to adapt to the changes.
It is recommended to use ServiceComb's deployment decoupling feature. Whether it is a consumer or a producer, the application don't perceive the web root and url pattern in the code, while ServiceComb will automatically adapt them for the producer instance at runtime.
For some legacy systems, if users expect to use restTemplate.getForObject("cse://serviceName/mywebapp/rest/application"...) without too many changes, then the path of the interface should be defined as /mywebapp/rest/application:
@RestSchema(schemaId = "test")
@RequestMapping(path = "/mywebapp/rest/application")
However, it is still recommended to use a deployment-independent way to write the code, which introduces less code modifications when the deployment pattern changes.
maven dependencies
<dependency>
<groupId>org.apache.servicecomb</groupId>
<artifactId>transport-rest-servlet</artifactId>
</dependency>
Configurations
When integrating with servlet, there are a few concepts involved:
-
Start spring context
Note the following startup methods cannot be used at the same time, just choose one of them. -
Without SpringMVC UI or RestController
xml
<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0">
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath*:META-INF/spring/*.bean.xml</param-value>
</context-param>
<listener>
<listener-class>org.apache.servicecomb.transport.rest.servlet.RestServletContextListener</listener-class>
</listener>
</web-app>
The classpath*:META-INF/spring/*.bean.xml
configured in contextConfigLocation is optional, because the ServiceComb will ensure that it is included in the load path.
This is just an example to indicate that the user can customize the contextConfigLocation.
- Use SpringMVC UI or RestController, and org.apache.servicecomb.transport.rest.servlet.CseDispatcherServlet exists
xml
<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0">
<servlet>
<servlet-name>SpringMVCServlet</servlet-name>
<servlet-class>org.apache.servicecomb.transport.rest.servlet.CseDispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>SpringMVCServlet</servlet-name>
<url-pattern>yourUrlPattern</url-pattern>
</servlet-mapping>
</web-app>
Note
This servlet is not the processing entry of ServiceComb, but the processing entry of UI or RestController.
-
Use SpringMVC's UI or RestController, and there is no org.apache.servicecomb.transport.rest.servlet.CseDispatcherServlet
In this case, the application class should inherit SpringMVC's DispatcherServlet, and then configure its implementation classes in CseDispatcherServlet's way.
@Override
protected WebApplicationContext createWebApplicationContext(ApplicationContext parent){
setContextClass(CseXmlWebApplicationContext.class);
return super.createWebApplicationContext(parent);
}
- ServiceComb servlet
The url pattern can be set according to the business logic. The following /rest/*
is just an example, not a fixed value.
Url pattern must end with /*
The following two declarations types can not be used at the same time.
- Standard declaration
xml
<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0">
<servlet>
<servlet-name>RestServlet</servlet-name>
<servlet-class>org.apache.servicecomb.transport.rest.servlet.RestServlet</servlet-class>
<load-on-startup>1</load-on-startup>
<async-supported>true</async-supported>
</servlet>
<servlet-mapping>
<servlet-name>RestServlet</servlet-name>
<url-pattern>/rest/*</url-pattern>
</servlet-mapping>
</web-app>
- Quick declaration
yaml
servicecomb.rest.servlet.urlPattern: /rest/*
Specify urlPattern in the microservice.yaml file. When ServiceComb starts, it will automatically create RestServlet and set the corresponding urlPattern.
Configuration example for typical scenarios
- Standard declaration in pure ServiceComb mode
web.xml:
xml
<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0">
<listener>
<listener-class>org.apache.servicecomb.transport.rest.servlet.RestServletContextListener</listener-class>
</listener>
<servlet>
<servlet-name>RestServlet</servlet-name>
<servlet-class>org.apache.servicecomb.transport.rest.servlet.RestServlet</servlet-class>
<load-on-startup>1</load-on-startup>
<async-supported>true</async-supported>
</servlet>
<servlet-mapping>
<servlet-name>RestServlet</servlet-name>
<url-pattern>/rest/*</url-pattern>
</servlet-mapping>
</web-app>
- Quick declaration in pure ServiceComb mode web.xml：
xml
<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0">
<listener>
<listener-class>org.apache.servicecomb.transport.rest.servlet.RestServletContextListener</listener-class>
</listener>
</web-app>
microservice.yaml：
yaml
servicecomb.rest.servlet.urlPattern: /rest/*
- SpringMVC or RestController provide web services, ServiceComb proxy the requests as consumer
web.xml：
xml
<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0">
<servlet>
<servlet-name>SpringMVCServlet</servlet-name>
<servlet-class>org.apache.servicecomb.transport.rest.servlet.CseDispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>SpringMVCServlet</servlet-name>
<url-pattern>yourUrlPattern</url-pattern>
</servlet-mapping>
</web-app>
microservice.yaml： Servicecomb.rest.address and servicecomb.rest.servlet.urlPattern are not configured
- SpringMVC UI/RestController and ServiceComb provide services at the same time web.xml：
xml
<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0">
<servlet>
<servlet-name>SpringMVCServlet</servlet-name>
<servlet-class>org.apache.servicecomb.transport.rest.servlet.CseDispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>SpringMVCServlet</servlet-name>
<url-pattern>yourUrlPattern</url-pattern>
</servlet-mapping>
</web-app>
microservice.yaml：
yaml
servicecomb:
rest:
servlet:
urlPattern: /rest/*
address: <IP_ADDRESS>:8080
Things to notice with servlet filter
RestServlet works in asynchronous mode. According to the servlet 3.0 standard, the entire work chain must be asynchronous. Therefore, the servlet filter should be set to be asynchronous when it's added to the chain:
<filter>
......
<async-supported>true</async-supported>
</filter>
Configuration items
The related items for REST over Servlet in the microservice.yaml are described below:
Table1-1 REST over Servlet Configuration Items
| Configuration Item | Default Value | Required | Description |
|---|---|---|---|
| servicecomb.rest.address | <IP_ADDRESS>:8080 | No | The service listening address Should be the same with the web container's listening address |
| servicecomb.rest.server.timeout | -1 | No | Server aync servlet timeout in milliseconds, suggest set to -1 |
| servicecomb.rest.server.requestWaitInPoolTimeout | 30000 | No | for sync business logic, timeout in milliseconds for waiting in executor queue |
| servicecomb.rest.servlet.urlPattern | No | Used to simplify servlet+servlet mapping config This item is used only when servlet+servlet mapping is not configured in web.xml.The format is:/* or /path/*, where path can be nested |


Creating tables in LaTeX is a hard task. Creating complex tables is an even harder one. This project consists in a free, open source, web-based, WYSIWYG (What you see is what you get) table editor for LaTeX. It will aim to support most features used in tables and management of packages (including incompatibilities and the possibility to blacklist some of them). A standalone open source JavaScript library will be released in the process to manipulate complex tables.
I'm a well experimented web developer and a proud user of LaTeX. This project is already started. However, the support from the community will allow me to work full time on this and release it sooner. The money will be used to pay for icons, a server, my rent and food while development is on the way.
Some packages from which features will be supported : array, arydshln, booktabs, colortbl, ctable, diagbox, dcolumn, hhline, longtable, lscape, makecell, multirow, rotating, slashbox, supertabular, tabularx, xcolor and more.
Thank you for your contribution and your support !
(normal, double, booktabs and dashed)
Here are some comparisons between LaTeX tables produced by the generator (at early stage) and its HTML reproduction (with inline CSS option activated)
|
Day
Time
|
Monday | Tuesday | Wednesday | Thursday | Friday |
| Morning | ✔ | ✔ | |||
| Afternoon | ✔ | ✔ | ✔ | ✔ | |
| Evening | ✔ | ✔ |
| Item | ||
| Name | Quantity | Price |
| Pencil | 100 | 1.50$ |
| Eraser | 20 | 2.50$ |


## Developer in the making
{ "WDI Projects": "CubbyLife", "ShareMyRide", "Assignment3" }
{ "WDI Assignments": "Stock Exchange", "Ruby MTA", "Ruby Movies", "Memetube", "Blog", "Butterflies", "Art Gallery", "Games", "Mountains", "Cookbook", "JA MTA", "ATM", "Carousel", "Hangman", "Paintr", "JS Movies" }


--- title: "Session 08 - Panel Data and Fixed Effects Specifications" date: '2020-10-27' output: html_document: theme: journal toc: yes toc_float: collapsed: false ---
You are hired as an outside consultant by the Organization of Economic Non-Cooperation for Development (OENCD), they are interested in studying the effect of a carbon tax on national carbon dioxide emissions per capita. You are provided with data for the twenty-members of the organization from 2009 to 2019. The data can be called a balanced panel based on the description given in the lecture (i.e. each panel member is observed every year)
set.seed(42) #for consistent results
library(dplyr) # to wrangle our data
library(tidyr) # to wrangle our data - pivot_longer()
library(ggplot2) # to render our graphs
library(readr) # for loading the .csv data
library(lmtest) # to gather our clustered standard errors - coeftest()
library(plm) # to gather our clustered standard errors - vcovHC() and plm()
library(kableExtra) # to render better formatted tables
library(stargazer) # for formatting your model output
library(lubridate) # for working with dates-times in a more intuitive manner
carbon_tax_df <- readr::read_csv("https://raw.githubusercontent.com/seramirezruiz/stats-ii-lab/master/Session%207/data/carbon_tax_df.csv") # simulated data
names(carbon_tax_df) # to check the names of the variables in our data
## [1] "country_name" "country_code" "year" "tax"
## [5] "income_class" "co2_per_capita"
Our dataset carbon_tax_df, contains the following information:
country_name
: Name of the countrycountry_code
: Three-letter country codeyear
: Yeartax
: Dummy for whether the carbon tax was in placeincome_class
: Categorical variable with income label (Low to High)co2_per_capita
: carbon dioxide emissions per capita in metric tons (T)
We can use what we have learnt about the base R table() function, to check how many countries had a tax
in place every year.
table(carbon_tax_df$tax, carbon_tax_df$year) %>%
knitr::kable() %>% # create kable table
kableExtra::kable_styling() # view kable table
| 2009 | 2010 | 2011 | 2012 | 2013 | 2014 | 2015 | 2016 | 2017 | 2018 | 2019 | |
|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | 12 | 12 | 10 | 9 | 8 | 8 | 5 | 4 | 4 | 4 | 5 |
| 1 | 0 | 0 | 2 | 3 | 4 | 4 | 7 | 8 | 8 | 8 | 7 |
ggplot(carbon_tax_df, aes(x = factor(year),
y= co2_per_capita,
color = factor(tax))) +
geom_point() + #create scatterplot
theme(legend.position="bottom") + #move legend to the bottom
labs(title = "Exploratory plot of CO2 emissions per capita",
x = "Year",
y = "CO2 emissions in metric tons (T)",
color = "Carbon tax") +
theme_minimal() +
scale_color_discrete(labels = c("No", "In place")) #change labels of the legend
carbon_tax_df %>%
dplyr::mutate(year_as_date = lubridate::ymd(year, truncated = 2L), #turning numeric to date format
income_class = factor(carbon_tax_df$income_class,
levels = c("High", "High-Middle",
"Low-Middle", "Low"))) %>% #reordering the factors
ggplot(., aes(x = year_as_date,
y= co2_per_capita,
color = factor(tax))) +
geom_point() + #create scatterplot
geom_path(aes(group = 1)) + #to render consecutive lines disregarding the tax (you will likely use geom_line() for the assignment)
facet_wrap(country_name~income_class) + #to split plot into panels based on this dimension
scale_x_date(date_labels = "%Y") + #telling ggplot that we want the ticks to be the years in the dates
labs(title = "Exploratory plot of CO2 emissions per capita",
x = "Year",
y = "CO2 emissions in metric tons (T)",
color = "Carbon tax") +
theme_bw() +
theme(legend.position="bottom") + #move legend to the bottom
scale_color_discrete(labels = c("No", "In place")) #change labels of the legend
Note: The exploratory data analysis portions of our scripts will not transfer directly to this week's assignment; however, they will be very useful for the extension portion of your final replication paper. Summarizing, graphing, and exploring your data will be critical to discover patterns, to spot anomalies, and to check assumptions
In the example at hand, we can think of unit-specific factors as characteristics of individual countries that are constant over time (e.g. a country that just loves big pick-up trucks). We can also think about time-specific factors that affect all countries (e.g. global economic shocks).
We can formulate this as:
\[Y_{it} = β_0 + β_1D_{it} + \theta_{i} + \delta_t + \upsilon_{it}\] where \(\theta_i\) reflects the time-invariant traits of the units, \(\delta_t\) reflects the time-specific factors that affect everyone and \(\upsilon_{it}\) is the idiosyncratic error
We will move forward by creating three models:
co2_per_capita
on tax
.
naive_carbon <- lm(co2_per_capita ~ tax, data = carbon_tax_df)
pooled_naive_carbon <- plm(co2_per_capita ~ tax, data = carbon_tax_df, model = "pooling")
stargazer(naive_carbon, type = "text")
=============================================== Dependent variable:
--------------------------- co2_per_capita
----------------------------------------------- tax -6.261***
(0.566)
Constant 10.627***
(0.352)
Observations 132
R2 0.485
Adjusted R2 0.481
Residual Std. Error 3.166 (df = 130)
F Statistic 122.394*** (df = 1; 130)
=============================================== Note: p<0.1; p<0.05; p<0.01
stargazer(pooled_naive_carbon, type = "text")
======================================== Dependent variable:
--------------------------- co2_per_capita
---------------------------------------- tax -6.261***
(0.566)
Constant 10.627***
(0.352)
Observations 132
R2 0.485
Adjusted R2 0.481
F Statistic 122.394*** (df = 1; 130)
======================================== Note: p<0.1; p<0.05; p<0.01
This model is telling us that on average, the \(CO_2\) emmissions per capita are reduced by 6.2 metric tons when a carbon tax is put in place. Still, after all the work we have done throughout the semester, we understand that there may be a plethora of factors that could be skewing the results of this bivariate regression.
We will learn two ways of gathering unit- and time-fixed effects in R. First, we will perform Least Squares Dummy Variables (LSDV) estimation with lm(), where we essentially get an individual estimate for each unit. Second, we will run our model with plm(), which will do the same mechanics, yet it will not estimate each of the units intercepts (because it relies on the "de-meaning" approach).
lsdv_unit_fe <- lm(co2_per_capita ~ tax + country_name, data = carbon_tax_df)
unit_fe <- plm(co2_per_capita ~ tax,
data = carbon_tax_df,
index = c("country_name","year"),
effect = "individual",
model = "within")
stargazer(lsdv_unit_fe, type = "text")
================================================== Dependent variable:
--------------------------- co2_per_capita
-------------------------------------------------- tax -4.436***
(0.474)
country_nameBorovia 1.507
(0.912)
country_nameCarpania 5.106***
(0.912)
country_nameCorinthia 6.434***
(0.887)
country_nameFreedonia 6.120***
(0.903)
country_nameGlenraven 0.372
(0.951)
country_nameKhemed -0.672
(0.951)
country_nameLaurania 1.533
(0.937)
country_nameParano 3.693***
(0.887)
country_nameRon 2.715***
(0.912)
country_nameRumekistan 7.431***
(0.887)
country_nameTransia 1.883*
(0.968)
Constant 6.912***
(0.627)
Observations 132
R2 0.797
Adjusted R2 0.776
Residual Std. Error 2.079 (df = 119)
F Statistic 38.844*** (df = 12; 119)
================================================== Note: p<0.1; p<0.05; p<0.01
stargazer(unit_fe, type = "text")
======================================== Dependent variable:
--------------------------- co2_per_capita
---------------------------------------- tax -4.436***
(0.474)
Observations 132
R2 0.424
Adjusted R2 0.366
F Statistic 87.716*** (df = 1; 119)
======================================== Note: p<0.1; p<0.05; p<0.01
Adding unit-level fixed effects to the model, i.e. accounting for unobserved, time-invariant characteristics of countries and only focusing on within-state variation, an increase in the imposition of a carbon tax reduces \(CO_2\) per capita emissions by 4.44 metric tons. Once we have captured the variation between countries, we can see that our results from the naive model were substantially biased. We can still try to capture the time-specific portion of the error.
The results from the Least Squares Dummy Variables (LSDV) estimation are read in reference to a baseline. In this case, the constant is representing the intercept for Adjikistan. We can utilize the individual slopes for each country to say that Freedonians emit on average 5.93 more metric tons of \(CO_2\) per capita than Adjikistanians.
We will perform our regressions with Least Squares Dummy Variables (LSDV) estimation with lm() and our simplified way with plm().
lsdv_unit_time_fe <- lm(co2_per_capita ~ tax + country_name + factor(year),
data = carbon_tax_df)
unit_time_fe <- plm(co2_per_capita ~ tax,
data = carbon_tax_df,
index = c("country_name", "year"),
model = "within",
effect = "twoways")
stargazer(lsdv_unit_time_fe, type = "text")
================================================== Dependent variable:
--------------------------- co2_per_capita
-------------------------------------------------- tax -3.908***
(0.280)
country_nameBorovia 1.267***
(0.418)
country_nameCarpania 4.866***
(0.418)
country_nameCorinthia 6.434***
(0.398)
country_nameFreedonia 5.928***
(0.410)
country_nameGlenraven -0.012
(0.447)
country_nameKhemed -1.056**
(0.447)
country_nameLaurania 1.196***
(0.436)
country_nameParano 3.693***
(0.398)
country_nameRon 2.474***
(0.418)
country_nameRumekistan 7.431***
(0.398)
country_nameTransia 1.450***
(0.459)
factor(year)2010 -4.697***
(0.381)
factor(year)2011 1.890***
(0.384)
factor(year)2012 -3.061***
(0.387)
factor(year)2013 0.106
(0.392)
factor(year)2014 -1.878***
(0.392)
factor(year)2015 -3.018***
(0.414)
factor(year)2016 -3.292***
(0.424)
factor(year)2017 -0.963**
(0.424)
factor(year)2018 -2.488***
(0.424)
factor(year)2019 -1.399***
(0.414)
Constant 8.621***
(0.396)
Observations 132
R2 0.963
Adjusted R2 0.955
Residual Std. Error 0.933 (df = 109)
F Statistic 127.305*** (df = 22; 109) ================================================== Note: p<0.1; p<0.05; p<0.01
stargazer(unit_time_fe, type = "text")
======================================== Dependent variable:
--------------------------- co2_per_capita
---------------------------------------- tax -3.908***
(0.280)
Observations 132
R2 0.641
Adjusted R2 0.568
F Statistic 194.229*** (df = 1; 109)
======================================== Note: p<0.1; p<0.05; p<0.01
Now in addition to adding unit-level fixed effects to the model, we control for time-specific factors that affect the global per capita \(CO_2\) emissions. The results suggest that the effect of a carbon-tax leads to a decrease \(CO_2\) emissions of 3.91 metric tons per capita.
Assumption for errors is \(υ_{it} ∼ iid(0, σ_υ^{2})\).
With longer panels, serial correlation between errors is a problem: \(Cor(υ_{it}, υ_i(t−1))≠0\).
We can test for serial correlation in our time and unit FE specification model, as such:
pbgtest(unit_time_fe, order = 2)
##
## Breusch-Godfrey/Wooldridge test for serial correlation in panel models
##
## data: co2_per_capita ~ tax
## chisq = 0.25101, df = 2, p-value = 0.8821
## alternative hypothesis: serial correlation in idiosyncratic errors
In this case, we do not find any serial correlation, so we do not need to correct our standard errors manually. If we were to find serial correlation, we could introduce robust standard errors with a similar syntax to the one used last week for clustered standard errors:
model_with_robust_se = coeftest(unit_time_fe, vcov=vcovHC(unit_time_fe, type = "sss"))
Your results are welcomed internationally and all states move forward with the measure.