The Global Object Pattern¶
Verdict
Like several other scripting languages, Python parses the outer level of each module as normal code. Un-indented assignment statements, expressions, and even loops and conditionals will execute as the module is imported. This presents an excellent opportunity to supplement a module’s classes and functions with constants and data structures that callers will find useful — but also offers dangerous temptations: mutable global objects can wind up coupling distant code, and I/O operations impose import-time expense and side effects.
Every Python module is a separate namespace.
A module like json
can offer a loads()
function
without conflicting with, replacing, or overwriting
the completely different loads()
function
defined over in the pickle
module.
Separate namespaces are crucial to making a programming language tractable. If Python modules were not separate namespaces, you would be unable to read or write Python code by keeping your attention focused on the module in front of you — a line of code might use, or accidentally conflict with, a name defined anywhere else in the Standard Library or a third-party module you have installed. Upgrading a third-party module could break your entire program if the new version defined a new global that conflicted with yours. Programmers who are forced to code in a language without namespaces soon find themselves festooning global names with prefixes, suffixes, and extra punctuation in a desperate race to keep them from conflicting.
While every function and class is, of course, an object — in Python, everything is an object — the Module Global pattern more specifically refers to normal object instances that are given names at the global level of a module.
Two patterns use Module Globals but are important enough to warrant their own articles:
- Prebound Methods are generated when a module builds an object and then assigns one or more of the object’s bound methods to names at the module’s global level. The names can be used to call the methods later without needing to find the object itself.
- While a Sentinel Object doesn’t have to live in a module’s global namespace — some sentinel objects are defined as class attributes, while others are private and live inside of a closure — many sentinels, both in the Standard Library and beyond, are defined and accessed as module globals.
This article will cover some other common cases.
The Constant Pattern¶
Modules often assign useful numbers, strings, and other values to names in their global scope. The Standard Library includes many such assignments, from which we can excerpt a few examples.
January = 1 # calendar.py
WARNING = 30 # logging.py
MAX_INTERPOLATION_DEPTH = 10 # configparser.py
SSL_HANDSHAKE_TIMEOUT = 60.0 # asyncio.constants.py
TICK = "'" # email.utils.py
CRLF = "\r\n" # smtplib.py
Remember that these are “constants” only in the sense that the objects themselves are immutable. The names can still be reassigned.
import calendar
calendar.January = 13
print(calendar.January)
13
Or deleted, for that matter.
del calendar.January
print(calendar.January)
Traceback (most recent call last):
...
AttributeError: module 'calendar' has no attribute 'January'
In addition to integers, floats, and strings, constants also include immutable containers like tuples and frozen sets:
all_errors = (Error, OSError, EOFError) # ftplib.py
bytes_types = (bytes, bytearray) # pickle.py
DIGITS = frozenset("0123456789") # sre_parse.py
More specialized immutable data types also serve as constants:
_EPOCH = datetime(1970, 1, 1, tzinfo=timezone.utc) # datetime
On rare occasions,
a module global
which the code clearly never intends to modify
uses a mutable data structure anyway.
Plain mutable sets
are common in code that pre-dates the invention of the frozenset
.
Dictionaries are still used today
because, alas, the Standard Library doesn’t offer a frozen dictionary.
# socket.py
_blocking_errnos = { EAGAIN, EWOULDBLOCK }
# locale.py
windows_locale = {
0x0436: "af_ZA", # Afrikaans
0x041c: "sq_AL", # Albanian
0x0484: "gsw_FR",# Alsatian - France
...
0x0435: "zu_ZA", # Zulu
}
Constants are often introduced as a refactoring:
the programmer notices that the same value 60.0
is appearing repeatedly in their code,
and so introduces a constant SSL_HANDSHAKE_TIMEOUT
for the value instead.
Each use of the name
will now incur the slight cost of a search into the global scope,
but this is balanced by a couple of advantages.
The constant’s name now documents the value’s meaning,
improving the code’s readability.
And the constant’s assignment statement
now provides a single location
where the value can be edited in the future
without needing to hunt through the code for each place 60.0
was used.
These advantages are weighty enough that a constant is sometimes introduced even for a value that’s used only once, hoisting a literal that was hidden deep in the code up into visibility as a global.
Some programmers place constant assignments close to the code that use them; others put all constants at the top of the file. Unless a constant is placed so close to its code that it will always be in view of human readers, it can be more friendly to put constants at the top of the module for the easy reference of readers who haven’t yet configured their editors to support jump-to-definition.
Another kind of constant is not directed inwards,
towards the code in the module itself,
but outwards as part of the module’s advertised API.
A constant like WARNING
from the logging
module
offers the advantages of a constant to the caller:
code will be more readable,
and the constant’s value could be adjusted later
without every caller needing to edit their code.
You might expect that a constant intended for the module’s own use, but not intended for callers, would always start with an underscore to mark it private. But Python programmers are not consistent in marking constants private, perhaps because the cost of needing to keep a constant around forever because a caller might have decided to start using it is smaller than the cost of having a helper function or class’s API forever locked up.
Import-time computation¶
Sometimes constants are introduced for efficiency, to avoid recomputing a value every time code is called. For example, even though math operations involving literal numbers are in fact optimized away in all modern Python implementations, developers often still feel more comfortable making it explicit that the math should be done at import time by assigning the result to a module global:
# zipfile.py
ZIP_FILECOUNT_LIMIT = (1 << 16) - 1
When the math expression is complicated, assigning a name also enhances the code’s readability.
As another example,
there exist special floating point values
that cannot be written in Python as literals;
they can only be generated by passing a string to the float type.
To avoid calling float()
with 'nan'
or 'inf'
every single time such a value is needed,
modules often build such values only once as module globals.
# encoder.py
INFINITY = float('inf')
A constant can also capture the result of a conditional to avoid re-evaluating it each time the value is needed — as long, of course, as the condition won’t be changing while the program is running.
# shutil.py
COPY_BUFSIZE = 1024 * 1024 if _WINDOWS else 16 * 1024
My favorite example of computed constants in the Standard Library
is the types
module.
I had always assumed it was implemented in C,
to gain special access to built-in type objects like FunctionType
and LambdaType
that are defined by the language implementation itself.
It turns out? I was wrong. The types
module is written in plain Python!
Without any special access to language internals, it does what anyone else would do to learn what type functions have. It creates a function, then asks its type:
# types.py
def _f(): pass
FunctionType = type(_f)
On the one hand,
this makes the types
module seem almost superfluous —
you could always use the same trick to discover FunctionType
yourself.
But on the other hand,
importing it from types
lets both major benefits of the Constant Pattern shine:
code becomes more readable
because FunctionType
will have the same name everywhere,
and more efficient
because the constant only needs to be computed once
no matter how many modules in a large system might use it.
Dunder Constants¶
A special case of constants defined at a module’s global level are “dunder” constants whose names start and end with double underscores.
Several Module Global dunder constants are set by the language itself.
For the official list,
look for the “Modules” subheading in the Python Reference’s section on
the standard type hierarchy.
The two encountered most often are __name__
,
which programs need to check because of Python’s awful design decision
to assign the fake name '__main__'
to the module invoked from the command line,
and __file__
,
the full filesystem path to the module’s Python file itself —
which is almost universally used to find data files included in a package,
even though the official recommendation these days
is to use pkgutil.get_data()
instead.
here = os.path.dirname(__file__)
Beyond the dunder constants set by the language runtime,
there is one Python recognizes if a module chooses to set it:
if __all__
is assigned a sequence of identifiers,
then only those names will be imported into another module
that does from … import *
.
You might have expected __all__
to become less popular
as import *
gained a reputation as an anti-pattern,
but it has gained a happy second career
limiting the list of symbols included
by automatic documentation engines like
Sphinx autodoc module.
Even though most modules never plan to modify __all__
,
they inexplicably specify it as a Python list.
It is more elegant to use a tuple.
Beyond these official dunder constants,
some modules —
despite unattractive how many people find dunder names —
indulge in the creation of even more.
Assignments to names like __author__
and __version__
are scattered across the Standard Library and beyond.
While they don’t appear consistently enough
for tooling can assume their presence,
occasional readers probably find them informative,
and they’re easier to get to than official package metadata.
Beware that there does not seem to be agreement,
even within the Standard Library,
about what type __author__
should have.
# bz2.py
__author__ = "Nadeem Vawda<EMAIL_ADDRESS># inspect.py
__author__ = ('Ka-Ping Yee<EMAIL_ADDRESS>'Yury Selivanov<EMAIL_ADDRESS>Why not author
and version
instead, without the dunders?
An early reader probably misunderstood dunders,
which really meant “special to the Python language runtime,”
as a vague indication
that a value was module metadata rather than module code.
A few Standard Library modules do offer their version without dunders,
but without even agreeing on the capitalization.
VERSION = "1.3.0" # etree/ElementTree.py
version = "0.20" # sax/expatreader.py
version = "0.9.0" # tarfile.py
To avoid the inconsistencies surrounding
these informal and ad-hoc metadata conventions,
a package that expects to be installed with pip
can learn the names and versions of other installed packages
directly from the Python package installation system.
More information is available in the setuptools documentation on the pkg_resources
module.
The Global Object Pattern¶
In the full-fledged Global Object pattern, as in the Constant pattern, a module instantiates an object at import time and assigns it a name in the module’s global scope. But the object does not simply serve as data; it is not merely an integer, string, or data structure. Instead, the object is made available for the sake of the methods it offers — for the actions it can perform.
The simplest Global Objects are immutable. A common example is a compiled regular expression — here are a few examples from the Standard Library:
escapesre = re.compile(r'[\\"]') # email/utils.py
magic_check = re.compile('([*?[])') # glob.py
commentclose = re.compile(r'--\s*>') # html/parser.py
HAS_UTF8 = re.compile(b'[\x80-\xff]') # json/encoder.py
Compiling a regular expression as a module global is a good example of the more general Global Object pattern. It achieves an elegant and safe transfer of expense from later in a program’s runtime to import time instead. The tradeoffs are:
- The cost of importing the module increases by the cost of compiling the regular expression (plus the tiny cost of assigning it to a global name).
- The import-time cost is now borne by every program that imports the module.
Even if a program doesn’t happen to call any code
that uses the
HAS_UTF8
regular expression shown above, it will incur the expense of compiling it whenever it imports thejson
module. (Plot twist: in Python 3, the pattern is no longer even used in the module! But its name was not marked private with a leading underscore, so I suppose it’s not safe to remove — and everyimport json
gets to pay its cost forever?) - But functions and methods that do, in fact, need to use the regular expression will no longer incur a repeated cost for its compilation. The compiled regular expression is ready to start scanning a string immediately! If the regular expression is used frequently, like in the inner loop of a costly operation like parsing, the savings can be considerable.
- The global name will make calling code more readable than if the regular expression, when used locally, is used anonymously in a larger expression. (If readability is the only concern, though, remember that you can define the regular expression’s string as a global but skip the cost of compiling it at module level.)
This list of tradeoffs is about the same, by the way, if you move a regular expression out into a class attribute instead of moving it all the way out to the global scope. When I finally get around to writing about Python and classes, I’ll link from here to further thoughts on class attributes.
Global Objects that are mutable¶
But what about Global Objects that are mutable?
They are easiest to justify when they wrap system resources
that are by their nature also global to an operating system process.
One example in the Standard Library itself is the environ
object
that gives your Python program the “environment” —
the text keys and values supplying your timezone, terminal type, so forth —
that was passed to your Python program from its parent process.
Now,
it is arguable whether your program
should really be writing new values into its environment as it runs.
If you’re launching a subprocess
that needs an environment variable adjusted,
the subprocess
routines offer an env
parameter.
But if code does need to manipulate this global resource,
then it makes sense for that access to be mediated
by a correspondingly global Python object:
# os.py
environ = _createenviron()
Through this global object, the various routines, and perhaps threads, in a Python program coordinate their access to this process-wide resource. Any change:
import os
os.environ['TERM'] = 'xterm'
— will be immediately visible to any other part of the program that reads that environment key:
>>> os.environ['TERM']
'xterm'
The problems with coupling distant parts of your codebase, and even unrelated parts of different libraries, through a unique global object are well known.
- Tests that were previously independent
are suddenly coupled through the global object
and can no longer safely be run in parallel.
If one test makes a temporary assignment to
environ['PATH']
just before another test launches a binary withsubprocess
, the binary will inherit the test value of$PATH
— possibly causing an error. - You can sometimes serialize access to a global object through a lock.
But unless you do a thorough audit
of all of the libraries your code uses,
and continue to audit them when upgrading to new versions,
it can be difficult to even know which tests call code
that ultimately touches particular global object like
environ
. - Even tests run serially, not in parallel, will now wind up coupled
if one test fails to restore
environ
to its original state before the next test runs. This can, it’s true, be mitigated with teardown routines or with mocks that automatically restore state. But unless every single test is perfectly cautious, your test suite can still suffer from exceptions that depend on random test ordering or on whether a previous test succeeded or exited early. - These dangers beset not only tests but production runs as well.
Even if your application doesn’t launch multiple threads,
there can be surprising cases
where a refactoring winds up calling code
that performs one operation on
environ
right in the middle of another routine that was also in the middle of transforming its state.
The Standard Library has more examples of the Mutable Global pattern — both public globals and private ones litter its modules. Some correspond to unique resources at the system level:
# Lib/multiprocessing/process.py
_current_process = _MainProcess()
_process_counter = itertools.count(1)
Others correspond to no outside resource but instead serve as single points of coordination for a process-wide activity like logging:
# Lib/logging/__init__.py
root = RootLogger(WARNING)
Third-party libraries can supply dozens of more examples, from global HTTP thread pools and database connections to registries of request handlers, library plugins, and third-party codecs. But in every case, the Mutable Global courts all of the dangers listed above in return for the convenience of putting a resource where every module can reach it.
My advice, to the extent that you can, is to write code that accepts arguments and returns values computed from them. Failing that, try passing database connections or open sockets to code that will need to interact with the outside world. It is a compromise for code that finds itself stranded from the resources it needs to resort to accessing a global.
The glory of Python, of course, is that it usually makes even anti-patterns and compromises read fairly elegantly in code. An assignment statement at the global level of a module is as easy to write and read as any other assignment statement, and callers can access the Mutable Global through exactly the same import statement they use for functions and classes.
Import-time I/O¶
Many of the worst Global Objects are those that perform file or network I/O at import time. They not only impose the cost of that I/O on every library, script, and test that need the module, but expose them to failure if a file or network is not available.
Library authors have an unfortunate tendency to make assumptions like
“the file /etc/hosts
will always exist”
when, in fact, they can’t know ahead of time
all the exotic environments their code will one day face —
maybe a tiny embedded system that in fact lacks that file;
maybe a continuous integration environment
spinning up containers that lack any network configuration at all.
Even when faced with this possibility,
a module author might still try to defend their import-time I/O:
“But delaying the I/O until after import time
simply postpones the inevitable —
if the system doesn’t have /etc/hosts
then the user will get exactly the same exception later anyway.”
The attempt to make this excuse reveals three misunderstandings:
- Errors at import time are far more serious than errors at runtime.
Remember that at the moment your package is imported,
the program’s main routine has probably not started running —
the caller is usually still up in the middle
of the stack of
import
statements at the top of their file. They have probably not yet set up logging and have not yet entered their application’s maintry…except
block that catches and reports failures, so any errors during import will probably print directly to the standard output instead of getting properly reported. - Applications are often written to survive the failure of some operations so that in an emergency they can still perform other functions. Even if features that need your library will now hit an exception, the application might have many others it can continue to offer — or could, if you didn’t kill it with an exception at import time.
- Finally, library authors need to keep in mind that a Python program that imports their library might not even use it! Never assume that simply because your code has been imported, it will be used. There are many situations where a module gets imported incidentally, as the dependency of yet further modules, but never happens to get called. By performing I/O at import time, you could impose expense and risk on hundreds of programs and tests that don’t even need or care about your network port, connection pool, or open file.
For all of these reasons, it’s best for your global objects to wait until they’re first called before opening files and creating sockets — because it’s at the moment of that first call that the library knows the main program is now up and running, and knows that its services are in fact definitely needed in this particular run of the program.
I’ll admit that, when my package needs to load a small data file that’s embedded in the package itself, I do sometimes break this rule.


Comparative Ecology of Ant Communities in Mediterranean Regions of California and Chile
By James Howell Hunt
B.S. (North Carolina State University) 1966 M.S. (Louisiana State University) 1969
DISSERTATION
Submitted in partial satisfaction of the requirements for the degree of DOCTOR OF PHILOSOPHY
in Zoology
in the GRADUATE DIVISION’ of the
UNIVERSITY OF CALIFORNIA, BERKELEY
Approved: ! fk KK
Cs ne
ly Bs _—
Committee in Charge
Reproduced with permission of the copyright owner. Further reproduction prohibited without permission.


| Constellation Action | Keyboard Shortcut | User Action | Menu Icon |
|---|---|---|---|
| Run Hierarchy Arrangement | Ctrl + H | Arrange -> Hierarchy |
The hierarchy arrangement arranges each component into a hierarchical structure with specified roots at the top and each subsequent level containing nodes that are the same distance away from the roots (i.e. if the root nodes are at Level 0, then Level n contains nodes that are n hops away from the root). Singleton nodes are arranged together in a grid, similarly for doublets (pairs of nodes only connected to each other).
The roots are specified via Named Selections (refer here for creating a named selection). When you run the arrangement, choose the named selection which will form the roots (the arrangement can't be run if no named selection exists). Only one component is required to have its root(s) specified in the named selection in order to run the hierarchy arrangement. Any component without a specified root will have an arbitrary node chosen to be the root.
Example Hierarchy Arrangement:


Wealth Generation Lets make some Money.
WEALTH GENERATION is a Peer to Peer mutual investment system where where members get rewarded from helping each others. This is the next big thing to liberate your financial burden.
How to use
In 3 easy steps, you can conveniently get that donation you really need.
Registration: During registration, make sure you use your correct mobile number. This is how other members can communicate with you when you are getting paid. After registration, Proceed to request for shares
Login: After your registration fee is confirmed, you will be able to login to your account, otherwise you will be stuck on the registration payment page. To login your account, you will need your username and password. Kindly chat with online support or group admins when you lose or forget Your password.
Invest: When you login to your account after registration, on your dashboard click on invest. On the box provided, input your desired investment amount. Note that minimum amount to invest is 500ksh and the maximum amount is 5000ksh.
Key Features
Timer: Immediately you are comfirmed, your timer for 2 days will start counting down. During these period, you will be allocated a receiver.
Make Payment: After your investment is allocated to a receiver, all you need to do is to login to your account, make payment and upload your proof of payment. You are also required (or not) to call the recipient for quick confirmation of your payment. Note that you will be accorded 3 hours to Make payment. Otherwise, your account will be blocked and pending investment(s) will be cancelled.
 Make sure you confirm on the site when you receive your payment.


?,?
Bad Math Among eBook Enthusiasts
The Amazon Kindle has excited a lot of comment from people who have long wanted portable electronic access to books. Amazon has put together a lot of the pieces that makes this holy grail seem reachable, even if not yet truly achieved. But in reading the commentary of some of the enthusiastic boosters of eBooks, I'm struck by just how much wishful thinking they display. For example, in an interview on Teleread with Marie Campbell of MarketIntellNow, Marie reports on a poll of 5000 "random" (actually self-selected) web surfers, and concludes: "Lower e-book prices, not gizmos like the Amazon Kindle, will be the big spur for book sales."
I agree with Marie's fundamental assertion that handheld devices are nice to have, not need to have -- the real breakthrough is just making electronic copies available at a fair price. Eventually, those electronic copies will find their way to whatever devices we are currently using, whether it's a PC or a handheld or some other future device. Our Safari Books Online joint venture with Pearson, which delivers subscription access to thousands of computer and business books (admittedly an early adopter audience with a need for professional content), generates more revenue than is normally reported for the entire downloadable ebook business. For my company, O'Reilly Media, Safari is now our third largest reseller, behind only Amazon and Barnes & Noble. This didn't take a handheld device (though handheld devices will certainly enlarge the market.) It just required making the content available with a business model and price that people were willing to pay.
But Marie's poll goes on to conclude that "over half of people surveyed expected e-book prices to be $5 or less and 1 out of every 5 expected the price to be $2.50 or less." She says:


• License Plate Recognition (2019)
Project: To perform license plate recognition, on the edge (very low power in-camera chipset), cloud, or combination of the edge and cloud.
We built tiny neural networks to achieve this task. These are End-to-End mixed-precision quantized YOLO-like models that are extremely fast, yet
very accurate. These models run on different platforms from GPU servers all the way to Nvidia JetSonTX2, Google Coral, PaspberryPi 3+, and in-
camera 3516EV300 chipsets.
Demo:
• Hand Gesture Recognition (2018)
Project: By 2018, there are already many successful models proposed for gesture recognition. This project investigated the practicallity of those
models for real-time applications. To this end, we leveraged a custom TRN (Temporal Relations Network) structure to train a model over the Jester
dataset for hand gesture recognition. This model could classify one of several designed actions in under 50 ms. Later the model outputs were
translated to a humanoid robot directions for a live demonstration:
Demo:
• Facial Attributes Recognition (2018)
Project: Facial attributes recognition for deployment on low power chips. We designed and trained a multi-task neural network with over 10
branches to recognize attributes such as age, gender, smile, makeup, facial hair, eye-glasses, etc. This model runs on JetSonTX2 under 100 ms per
frame.
Demo:
• Face Detection and Recognition (2018)
Project: To perform face detection and recognition for various applications (various speed, accuracy, and dataset size requirements; clustering,
classification, or id recognition). This involved with exploring/modifying various deep learning frameworks/models, to train/transfer-learn for
detection and recognition tasks.
Demo:
For this demo, I used the PubFig dataset (Public Figures Face Dataset) as face id candidates, LFW datset (Labeled Faces in the Wild) for training,
and tried a couple of YouTube videos for fun (watch full screen in high resolution setting to read the labels!):
• Text Detection and Recognition (2018)
Project: Detect and recognize (read) text from video/image. This involved with exploring the state-of-the-art OCR (Optical Character Recognition)
models. Various Attention-based CNN/RNN models were used for detection, recognition, or end-to-end tasks. Traditional OCR approaches fail for a
non-flat warped background with transformations.
Demo:
Using a separate detection and character level recognition framework, I trained deep learning based models, and applied them to a couple of
YouTube vidoes below. In each video, bounding boxes are first detected around the text area, then text crops are shown below the actual video
frame (sorted according to recognition confidence). For each text crop (bounding box), the title above shows what the recognition model has found.
Although the detection seems to have high precision and high recall, I believe recognition can still be further improved.
• Command Recommendation in an IDE environment (2017)
Project: Modern Integrated Development Environments (IDEs) often provide next command recommendation to the users to ease the development
process. A current approach is to use co-occurrence analysis, that has a superior performance compared to the traditional supervised learning
approaches. In this project we explored the usage of deep neural networks for this task. We trained a custom LSTM network and demonstrated it
can perform on-par with the co-occurrence method.
Amin Banitalebi Dehkordi, PhD
(Amin Banitalebi)
Links
Copyright © 2022 by "Amin Banitalebi" · All Rights reserved · E-Mail: amin[dot]banitalebi[at]gmail.com
ACADEMIC PROJECTS: click here
Visit my Google Scholar page here.
Projects
• Detecting and Analyzing Objects in a Conveyor Belt Surveillance Video:
Project: To understand and analyze the objects moving on a conveyor belt, in a dim environment
Solution: Using connected component segment analysis and contour detection to find objects
• Ultra-Accurate Image Registration:
Project: Register an image aquired by a camera on board of a satellite to a ground-truth image on the ground, accurate to half-a-pixel
Solution: A complex mathematical optimization approach based on extended Kalman filtering. The optimization is very flexible, accounts for
uncertainty in the measurements and independent variables, converges in only a few iterations in less than 10-30 seconds.
Before Registration:
Matching:
After Registration:
• Ultra-Accurate Registration of Multiple Images - Bundle Adjustment:
Project: Register multiple images obtained from different satellite cameras together, and to a ground truth image on the ground
Solution: Optimization using extended Kalman filters. The overlapping area between multiple images has a half-a-pixel registration accuracy. This
accuracy is better than the accuracy obtained by registering every image against the ground truth reference image. The figure below shows slight
misregistration remaining in an overlapping AOI.
• Video Frame Stabilization:
Project: Register a stack of video frames from a satellite camera to each other, and to a ground truth reference image
Solution: Optimization using extended Kalman filters to register each frame first. This will produce a video, with a remaining degree of
misregistration. Then, register every frame against the median of center frames. The resulting video will have a sub-pixel frame-to-frame
regostration.
Original video, before registration:
After the initial optimization (AOI):
Final video (AOI):
• Style Transfer with Variational Generative Adversarial Network (GAN):
Project: To demonstrate latent space arithmetics when using Variational GANs
Demo:
Using CelebFaces dataset, to demonstrate Male-to-Female transfer:
No-Smile to Smile transfer:
I tried my childhood picture (with no alignment) to Smile transfer. Looks like it needs alignment, but shows the concept:
• Ortho Rectification:
Project: To project images acquired by a sensor, to the ground plane. Involves with efficient resampling algorithms.
Demo:
• 2D to 3D Video Conversion:
Project: To automatically convert 2D video to 3D
Solution 1: To train a learning model that can generate depth maps from 2D video. And then use depth maps to generate additional views.
Solution 2: To estimate a depth map in an optimization problem, then perform motion segmentation to assign a depth value to each object. This
was followed by depth map post filtering for quality enhancement and flicker reduction.
• Other Projects Worth a Mention:
- Image/Video enhancement and restoration (parallel implementation using Amazon AWS EMR):
- Lightness contrast stretching
- Adaptive histogram equalization
- Saturation, color temperature adjustment, gamma correction, sharpenning
- Tone-mapping and color space conversions
- Frame-rate up/down conversion:
- Filling bad or no-data pixels
- Python implementation with C++ SWIG bindings for efficient interpolation/extrapolation
- Patch-matching to restore corrupted sections of video frames
- Compiling a huge MATLAB code base using MATLAB Compiler
• Distributed Inference / Edge-Cloud Collaboration:
- Joint bit-width assignment and neural network splitting for distributing the inference between an edge and cloud or more
- Integrated as a pipeline to HiLens (a Huawei edge device and platform)
- Implemented for a license plate recognition application (3516 arm chip)
• Model Composition:
- Combine multiple models in one, without labeled data of all tasks (tasks could be partially overlapping or non-overlapping)
• Robust Object Detection / Domain Adaptation:
- Make object detection models robust to domain shifts such as image corruptions, weather/lighting changes, etc.
- Support domain changes such as natural image to cartoon, painting, clipart
- Train on one dataset and test on another
• Joint Inference:
- Use a large & small model together to distribute inference based on the inputs characteristics
- Goal: Preserve the accuracy, but speed-up the inference
- Unsupervised & specialized extensions
- Applied to Vision (Image Classifiaction, Object Detection, ...) and NLP (Classification, Translation on BERT, T5, ...)


WATCH IT OUTSIDE BOSTON EDITION
Home
Schedule
News
Boston Public Garden
Boston News
Sign Up
Registration Form
Email Address:
Password:
Male
Female


[gecode-users] A small and simple example with tuple and extensional use
Mikael Zayenz Lagerkvist
zayenz at gmail.com
Thu Mar 18 11:11:40 CET 2010
2010/3/18 Claudio Cesar de Sá <claudio at colmeia.udesc.br>:
> Someone has an illustrative and small example that use TupleSet and
> extensional constraints?
The Black-Hole patience example uses an extensional constraint
specified using a TupleSet to implement the constraint
abs(x[i] - x[i+1]) in {1, 12}
by computing all allowable pairs of values for x[i] and x[i+1].
> Before an extensional constraints a branch is mandatory?
Not sure what you mean here. You might want to read the Modeling with
Gecode documentation [1].
Cheers,
Mikael
[1] http://www.gecode.org/documentation.html
--
Mikael Zayenz Lagerkvist, http://www.ict.kth.se/~zayenz/
More information about the users
mailing list


Build enterprise-ready web applications, responsive to all devices and running on the browser of your choice. That´s OpenUI5.
Build enterprise-ready web applications, responsive to all devices and running on the browser of your choice. That´s OpenUI5.
Build enterprise-ready web applications, responsive to all devices and running on the browser of your choice. That´s OpenUI5.
Build enterprise-ready web applications, responsive to all devices and running on the browser of your choice. That´s OpenUI5.
Build enterprise-ready web applications, responsive to all devices and running on the browser of your choice. That´s OpenUI5.
Build enterprise-ready web applications, responsive to all devices and running on the browser of your choice. That´s OpenUI5.
Build enterprise-ready web applications, responsive to all devices and running on the browser of your choice. That´s OpenUI5.
Build enterprise-ready web applications, responsive to all devices and running on the browser of your choice. That´s OpenUI5.
Build enterprise-ready web applications, responsive to all devices and running on the browser of your choice. That´s OpenUI5.
Build enterprise-ready web applications, responsive to all devices and running on the browser of your choice. That´s OpenUI5.
Build enterprise-ready web applications, responsive to all devices and running on the browser of your choice. That´s OpenUI5.
Build enterprise-ready web applications, responsive to all devices and running on the browser of your choice. That´s OpenUI5.
Build enterprise-ready web applications, responsive to all devices and running on the browser of your choice. That´s OpenUI5.
Build enterprise-ready web applications, responsive to all devices and running on the browser of your choice. That´s OpenUI5.
Build enterprise-ready web applications, responsive to all devices and running on the browser of your choice. That´s OpenUI5.
Build enterprise-ready web applications, responsive to all devices and running on the browser of your choice. That´s OpenUI5.
Build enterprise-ready web applications, responsive to all devices and running on the browser of your choice. That´s OpenUI5.
Build enterprise-ready web applications, responsive to all devices and running on the browser of your choice. That´s OpenUI5.
Build enterprise-ready web applications, responsive to all devices and running on the browser of your choice. That´s OpenUI5.
Build enterprise-ready web applications, responsive to all devices and running on the browser of your choice. That´s OpenUI5.
Build enterprise-ready web applications, responsive to all devices and running on the browser of your choice. That´s OpenUI5.
Build enterprise-ready web applications, responsive to all devices and running on the browser of your choice. That´s OpenUI5.
Build enterprise-ready web applications, responsive to all devices and running on the browser of your choice. That´s OpenUI5.
Build enterprise-ready web applications, responsive to all devices and running on the browser of your choice. That´s OpenUI5.
Build enterprise-ready web applications, responsive to all devices and running on the browser of your choice. That´s OpenUI5.
Prevent closing the dialog.
Are you sure?
That´s OpenUI5.
Build enterprise-ready web applications, responsive to all devices and running on the browser of your choice. That´s OpenUI5.
Build enterprise-ready web applications, responsive to all devices and running on the browser of your choice. That´s OpenUI5.
Build enterprise-ready web applications, responsive to all devices and running on the browser of your choice. That´s OpenUI5.
Build enterprise-ready web applications, responsive to all devices and running on the browser of your choice. That´s OpenUI5.
Build enterprise-ready web applications, responsive to all devices and running on the browser of your choice. That´s OpenUI5.
Build enterprise-ready web applications, responsive to all devices and running on the browser of your choice. That´s OpenUI5.
That´s OpenUI5.
Build enterprise-ready web applications, responsive to all devices and running on the browser of your choice. That´s OpenUI5.
Build enterprise-ready web applications, responsive to all devices and running on the browser of your choice. That´s OpenUI5.
Build enterprise-ready web applications, responsive to all devices and running on the browser of your choice. That´s OpenUI5.
Build enterprise-ready web applications, responsive to all devices and running on the browser of your choice. That´s OpenUI5.
Build enterprise-ready web applications, responsive to all devices and running on the browser of your choice. That´s OpenUI5.
Build enterprise-ready web applications, responsive to all devices and running on the browser of your choice. That´s OpenUI5.
Hint: Move this dialog around the screen by dragging it by its header or use the arrow keys.
This feature is available only on Desktop.
Hint: Resize this dialog by dragging it by its resize handle or use shift+arrow keys.
This feature is available only on Desktop.
Content
Hint: Move this dialog around the screen by dragging it by its header or use the arrow keys.
Resize this dialog by dragging it by its resize handle or use shift+arrow keys.
This feature is available only on Desktop.


Overview
Package
Class
Use
Tree
Deprecated
Index
Help
PREV LETTER
NEXT LETTER
FRAMES
NO FRAMES
All Classes
A
C
D
F
G
I
O
Q
R
S
T
U
W
S
setApplicationName(String)
- Method in class com.rallydev.rest.
RallyRestApi
Set the value of the X-RallyIntegrationName header included on all requests.
setApplicationVendor(String)
- Method in class com.rallydev.rest.
RallyRestApi
Set the value of the X-RallyIntegrationVendor header included on all requests.
setApplicationVersion(String)
- Method in class com.rallydev.rest.
RallyRestApi
Set the value of the X-RallyIntegrationVersion header included on all requests.
setFetch(Fetch)
- Method in class com.rallydev.rest.request.
CreateRequest
Set the current list of fields to be returned on the created object.
setFetch(Fetch)
- Method in class com.rallydev.rest.request.
GetRequest
Set the current list of fields to be returned on the retrieved object.
setFetch(Fetch)
- Method in class com.rallydev.rest.request.
QueryRequest
Set the current list of fields to be returned on the matching objects.
setFetch(Fetch)
- Method in class com.rallydev.rest.request.
UpdateRequest
Set the current list of fields to be returned on the updated object.
setLimit(int)
- Method in class com.rallydev.rest.request.
QueryRequest
Set the maximum number of records to be returned from the query.
setOrder(String)
- Method in class com.rallydev.rest.request.
QueryRequest
Get the order by which the result set will be sorted.
setPageSize(int)
- Method in class com.rallydev.rest.request.
QueryRequest
Set the page size of the result set.
setParams(List<NameValuePair>)
- Method in class com.rallydev.rest.request.
Request
Set the list of additional parameters included in this request.
setProject(String)
- Method in class com.rallydev.rest.request.
QueryRequest
Specify the project which the result set should be scoped to.
The default is the user's default project.
setProxy(URI)
- Method in class com.rallydev.rest.
RallyRestApi
Set the unauthenticated proxy server to use.
setProxy(URI, String, String)
- Method in class com.rallydev.rest.
RallyRestApi
Set the authenticated proxy server to use.
setQueryFilter(QueryFilter)
- Method in class com.rallydev.rest.request.
QueryRequest
Set a filter by which the result set will be narrowed down.
setScopedDown(boolean)
- Method in class com.rallydev.rest.request.
QueryRequest
If a project has been specified, set whether to include matching objects in child projects in the result set.
setScopedUp(boolean)
- Method in class com.rallydev.rest.request.
QueryRequest
If a project has been specified, set whether to include matching objects in parent projects in the result set.
setStart(int)
- Method in class com.rallydev.rest.request.
QueryRequest
Set the 1-based start index of the result set.
setWorkspace(String)
- Method in class com.rallydev.rest.request.
QueryRequest
Specify the workspace which the result set should be scoped to.
The default is the user's default workspace.
setWsapiVersion(String)
- Method in class com.rallydev.rest.
RallyRestApi
Set the current version of the WSAPI being targeted.


> Dexter Download
1. Click * Help> Install New Software menu for Dexter Installation.
2. Add "Dexter Download" in 'Work with:' tab as below.
3. Check the name of Dexter and click Next>.
4. Select I accept the terms of the license agreement and click Finish
* If check for Security is required, select Yes to install Dexter now.
* Then restart is required, select Yes to complete the setup Dexter.
Restart your eclipse after the installation.
5. You can check Dexter Icon in your eclipse as below.


|
gtsam
4.0.0
gtsam
|
Public Member Functions | |
| GaussianEliminationTree (const GaussianFactorGraph &factorGraph, const VariableIndex &structure, const Ordering &order) | |
| Build the elimination tree of a factor graph using pre-computed column structure. More... | |
| GaussianEliminationTree (const GaussianFactorGraph &factorGraph, const Ordering &order) | |
| Build the elimination tree of a factor graph. More... | |
| bool | equals (const This &other, double tol=1e-9) const |
| Test whether the tree is equal to another. | |
| Public Member Functions inherited from gtsam::EliminationTree< GaussianBayesNet, GaussianFactorGraph > | |
| std::pair< boost::shared_ptr< BayesNetType >, boost::shared_ptr< FactorGraphType > > | eliminate (Eliminate function) const |
| Eliminate the factors to a Bayes net and remaining factor graph. More... | |
| const FastVector< sharedNode > & | roots () const |
| Return the set of roots (one for a tree, multiple for a forest) | |
| const FastVector< sharedFactor > & | remainingFactors () const |
| Return the remaining factors that are not pulled into elimination. | |
| void | swap (This &other) |
| Swap the data of this tree with another one, this operation is very fast. More... | |
| void | print (const std::string &name="EliminationTree: ", const KeyFormatter &formatter=DefaultKeyFormatter) const |
| Print the tree to cout. | |
Public Types | |
| typedef EliminationTree< GaussianBayesNet, GaussianFactorGraph > | Base |
| Base class. | |
| typedef GaussianEliminationTree | This |
| This class. | |
| typedef boost::shared_ptr< This > | shared_ptr |
| Shared pointer to this class. | |
| Public Types inherited from gtsam::EliminationTree< GaussianBayesNet, GaussianFactorGraph > | |
| typedef GaussianFactorGraph | FactorGraphType |
| The factor graph type. | |
| typedef GaussianFactorGraph ::FactorType | FactorType |
| The type of factors. | |
| typedef boost::shared_ptr< FactorType > | sharedFactor |
| Shared pointer to a factor. | |
| typedef GaussianBayesNet | BayesNetType |
| The BayesNet corresponding to FACTOR. | |
| typedef BayesNetType::ConditionalType | ConditionalType |
| The type of conditionals. | |
| typedef boost::shared_ptr< ConditionalType > | sharedConditional |
| Shared pointer to a conditional. | |
| typedef GaussianFactorGraph ::Eliminate | Eliminate |
| typedef boost::shared_ptr< Node > | sharedNode |
| Shared pointer to Node. | |
Friends | |
| class | ::EliminationTreeTester |
Additional Inherited Members | |
| Protected Types inherited from gtsam::EliminationTree< GaussianBayesNet, GaussianFactorGraph > | |
| typedef EliminationTree< GaussianBayesNet, GaussianFactorGraph > | This |
| This class. | |
| typedef boost::shared_ptr< This > | shared_ptr |
| Shared pointer to this class. | |
| Protected Member Functions inherited from gtsam::EliminationTree< GaussianBayesNet, GaussianFactorGraph > | |
| GTSAM_CONCEPT_TESTABLE_TYPE (FactorType) | |
| concept check | |
| EliminationTree (const FactorGraphType &factorGraph, const VariableIndex &structure, const Ordering &order) | |
| Build the elimination tree of a factor graph using pre-computed column structure. More... | |
| EliminationTree (const FactorGraphType &factorGraph, const Ordering &order) | |
| Build the elimination tree of a factor graph. More... | |
| EliminationTree (const This &other) | |
| Copy constructor - makes a deep copy of the tree structure, but only pointers to factors are copied, factors are not cloned. More... | |
| This & | operator= (const This &other) |
| Assignment operator - makes a deep copy of the tree structure, but only pointers to factors are copied, factors are not cloned. More... | |
| EliminationTree () | |
| Protected default constructor. | |
| bool | equals (const This &other, double tol=1e-9) const |
| Test whether the tree is equal to another. | |
| Protected Attributes inherited from gtsam::EliminationTree< GaussianBayesNet, GaussianFactorGraph > | |
| FastVector< sharedNode > | roots_ |
| FastVector< sharedFactor > | remainingFactors_ |
| gtsam::GaussianEliminationTree::GaussianEliminationTree | ( | const GaussianFactorGraph & | factorGraph, |
| const VariableIndex & | structure, | ||
| const Ordering & | order | ||
| ) |
Build the elimination tree of a factor graph using pre-computed column structure.
| factorGraph | The factor graph for which to build the elimination tree |
| structure | The set of factors involving each variable. If this is not precomputed, you can call the Create(const FactorGraph<DERIVEDFACTOR>&) named constructor instead. |
| gtsam::GaussianEliminationTree::GaussianEliminationTree | ( | const GaussianFactorGraph & | factorGraph, |
| const Ordering & | order | ||
| ) |
Build the elimination tree of a factor graph.
Note that this has to compute the column structure as a VariableIndex, so if you already have this precomputed, use the other constructor instead.
| factorGraph | The factor graph for which to build the elimination tree |


Your Shopping Cart is empty. Give it purpose—fill it with vitamins, supplements, and more. If you already have an account, sign in.


About Howard
Dr. Howard Fortescue is the founder and Managing Director of HFF Ltd. which is based in South Wales.
Howard Graduated in Physics from the Heriot Watt University in Edinburgh and then studied teaching and education at Moray House College and Edinburgh University. He taught Maths and Physics in Scotland for a few years and then moved to the midlands to work in the Automotive industry and gain a PhD from Aston University.
Howard entered Optical Disc field in the early days with Philips, working on Laservision and has remained at the forefront of of Optical Disc development to the present day.
This long, varied and in depth experience with Philips, PDO, Nimbus and Technicolor has encompassed many successful projects in UK and worldwide. Howard was heavily involved in setting up the (Nimbus/Technicolor) UK, Luxembourg and Poland plants particularly the Mastering and Electroforming areas.
When Technicolor ceased its UK disc manufacturing, Howard started HFF Ltd. with a view to supporting Optical disc Manufacture wherever required and also developing products and services outside this field.
Get in touch
Philosophy
Some information on approach, style, etc.
Case Studies
Some callout successes, perhaps with links to projects or content.


public class LatentStateStatic
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
DISCOUNT_QM_COMPOUNDED_SHORT_RATE
Discount Latent State Quantification Metric - Compounded Short Rate
|
static java.lang.String |
DISCOUNT_QM_DISCOUNT_FACTOR
Discount Latent State Quantification Metric - Discount Factor
|
static java.lang.String |
DISCOUNT_QM_FORWARD_RATE
Discount Latent State Quantification Metric - Forward Rate
|
static java.lang.String |
DISCOUNT_QM_ZERO_RATE
Discount Latent State Quantification Metric - Zero Rate
|
static java.lang.String |
FORWARD_QM_CONTINUOUSLY_COMPOUNDED_FORWARD_RATE
Forward Latent State Quantification Metric - Continuously Compounded Forward Rate
|
static java.lang.String |
FORWARD_QM_FORWARD_RATE
Forward Latent State Quantification Metric - Forward Rate
|
static java.lang.String |
FORWARD_QM_INSTANTANEOUS_EFFECTIVE_FORWARD_RATE
Forward Latent State Quantification Metric - Instantaneous Effective Annual Forward Rate
|
static java.lang.String |
FORWARD_QM_INSTANTANEOUS_FORWARD_RATE
Forward Latent State Quantification Metric - Instantaneous Forward Rate
|
static java.lang.String |
FORWARD_QM_INSTANTANEOUS_NOMINAL_FORWARD_RATE
Forward Latent State Quantification Metric - Instantaneous Nominal Annual Forward Rate
|
static java.lang.String |
FORWARD_QM_LIBOR_RATE
Forward Latent State Quantification Metric - LIBOR Rate
|
static java.lang.String |
FORWARD_QM_SHIFTED_FORWARD_RATE
Forward Latent State Quantification Metric - Shifted Forward Rate
|
static java.lang.String |
FX_QM_FORWARD_OUTRIGHT
FX Latent State Quantification Metric - FX Forward Outright
|
static java.lang.String |
GOVVIE_QM_YIELD
Govvie Latent State Quantification Metric - Treasury Benchmark Yield
|
static java.lang.String |
LATENT_STATE_FORWARD
Forward Latent State
|
static java.lang.String |
LATENT_STATE_FUNDING
Funding Latent State
|
static java.lang.String |
LATENT_STATE_FX
FX Latent State
|
static java.lang.String |
LATENT_STATE_GOVVIE
Govvie Latent State
|
static java.lang.String |
LATENT_STATE_VOLATILITY
Volatility Latent State
|
static java.lang.String |
VOLATILITY_QM_LOGNORMAL_VOLATILITY
Volatility Latent State Quantification Metric - Lognormal Volatility
|
static java.lang.String |
VOLATILITY_QM_NORMAL_VOLATILITY
Volatility Latent State Quantification Metric - Normal Volatility
|
static java.lang.String |
VOLATILITY_QM_SABR_VOLATILITY
Volatility Latent State Quantification Metric - SABR Volatility
|
| Constructor and Description |
|---|
LatentStateStatic() |
public static final java.lang.String LATENT_STATE_FORWARD
public static final java.lang.String FORWARD_QM_FORWARD_RATE
public static final java.lang.String FORWARD_QM_LIBOR_RATE
public static final java.lang.String FORWARD_QM_SHIFTED_FORWARD_RATE
public static final java.lang.String FORWARD_QM_INSTANTANEOUS_FORWARD_RATE
public static final java.lang.String FORWARD_QM_CONTINUOUSLY_COMPOUNDED_FORWARD_RATE
public static final java.lang.String FORWARD_QM_INSTANTANEOUS_EFFECTIVE_FORWARD_RATE
public static final java.lang.String FORWARD_QM_INSTANTANEOUS_NOMINAL_FORWARD_RATE
public static final java.lang.String LATENT_STATE_FUNDING
public static final java.lang.String DISCOUNT_QM_DISCOUNT_FACTOR
public static final java.lang.String DISCOUNT_QM_ZERO_RATE
public static final java.lang.String DISCOUNT_QM_COMPOUNDED_SHORT_RATE
public static final java.lang.String DISCOUNT_QM_FORWARD_RATE
public static final java.lang.String LATENT_STATE_GOVVIE
public static final java.lang.String GOVVIE_QM_YIELD
public static final java.lang.String LATENT_STATE_FX
public static final java.lang.String FX_QM_FORWARD_OUTRIGHT
public static final java.lang.String LATENT_STATE_VOLATILITY
public static final java.lang.String VOLATILITY_QM_SABR_VOLATILITY
public static final java.lang.String VOLATILITY_QM_LOGNORMAL_VOLATILITY
public static final java.lang.String VOLATILITY_QM_NORMAL_VOLATILITY


Statistics
UART received bytes
-
Connected TCP clients
-
Connected UDP clients
-
Settings
Wifi SSID
Wifi Password
Wifi Channel
UART TX Pin
UART RX Pin
UART serial protocol
MSP/LTM
Transparent/MAVLink
UART baud
5000000
1500000
1000000
500000
115200
57600
38400
19200
9600
4800
2400
MSP & LTM to same port
No - MSP: 1607 LTM: 1604
Yes - all: 1607
LTM frames per packet
1
2
4
6
10
Transparent packet size
16
32
64
128
256
Gateway IP address
Save Settings
Reboot ESP32
DroneBridge for ESP32 - waiting for response from the ESP32
© Wolfgang Christl 2018 - Apache 2.0 License


rule water curves reservoir future CTSA inflow CGA optimal multi-objective using min model optimization curve operation data spill) RC-CGA existing historic shortage) store Fig. search simulation algorithm climate excess RC-CTSA results storage Ubolrat upper wet Reservoir period {border-style average spill Table px;} techniques years #ffffff;} curves. level minimize new objective shortage capacity functions Manag. Water answer change considered end finding lower management use (max Optimal SWAT genetic monthly quantity tabu (future-max (future-min (min Resour. considering developed maintained model. season situations land month order performance used Maximum higher illustrated including minimum obtained process searching stored However, Kangrang conditional connecting maximum operating research reservoir, reservoirs study synthetic term volume Average Civil Eng. PRECIS compared downstream dry function increase maximize px; shortage, technique {font-family Thailand based case conditions curve. curves, develop development font-size method months rainy result scenario set shortages situation year years) (for IPCC Rule [alt-text] addition, algorithms answers applying area demand different double; drought especially hydrological release resource respectively, spill, supply systems time ν,τ Afshar CGA, Development Multi-objective November Zhang actual application applied areas border-color border-width discharge duration effective efficiency flood flowing frequency highly impacts important large long main number problem solid; suitable various {font-style {font-weight < (): (MCM/year) (times/year) (year) Ashofteh Bozorg-Haddad Chang Change Conditional Duration Figs. Frequency Heliyon Hydrol. KSCE MCM/year MCM/year). Magnitude Plan. Prasanchum Similarly, Situations Tabu Then, Therefore, adaptive analysis bold changes compare consists courier; decision demonstrated em; engineering example, frequencies line magnitudes methods necessary newly optimum patterns points position precipitation presented problems. production, proposed pt;} reduce reservoir. resources risk shown shows simulated single solve spatial standard storage-min value variable years,


{% extends "_layouts/base.html" %} {% set id = 'developers' %} {% block main %}
Browse Ionic Framework components, api, plugins, theming, and CLI documentation and guides.
Browse service configuration, user admin, and troubleshooting docs and guides for Ionic Services.


How does Tokio schedule tasks?
https://www.reddit.com/r/rust/comments/co5uop/how_does_tokio_schedule_tasks/
Hello everyone,
I am currently working on a Certificate Transparency log scraper using HTTP2.
Now the problem that I run into is that if I create too many tasks (20+ network IO tasks) the first ones will await at some point during task but will never get called again to finish because other (newly) spawned tasks seem to be prioritized. When looking at tokio’s docs I was not able to figure out what kind of scheduling algorithm Tokio uses and if the user can somehow change this.
I hope someone would be able to give me some pointers! The code is listed in the Tokio issue mentioned below.
Thanks in advance!
References:
In a well written application, what you are describing should not be possible as the Tokio scheduler is mostly fair.
It sounds like you may have tasks that are hogging scheduler time. Tokio uses “cooperative” scheduling, so if you have a task that never yields back to the scheduler (returns Poll::Pending or awaits) then that scheduler thread cannot process other tasks.
If your app is 100% CPU saturated (there is always new work to do), then it is possible that this would lead to unfair scheduling like you are seeing as idle threads prioritize getting newly spawned tasks over stealing tasks from other workers.
Another option is that you have some bug that leads to lost wake up notifications. Again, it is hard to say.
First of all! Thanks for your attempt to help me :)
I confirmed that my tasks yield back to the scheduler (You can see the output and code on the GitHub issue I mentioned in the description).
It seems like I am suffering from the second problem (100% saturated CPU): The pseudocode looks something like this:
for 1 till 0..20
tokio::spawn
{
loop
{
// Send request.await()
// Retrieve response.await()
}
}
So there is a fixed amount of tasks but the older tasks (let’s say task 1..4), successfully send the request, but are not being scheduled anymore) while the other tasks keep looping and sending new requests successfully. If I scale down the amount of tasks, this problem does not occur.
Do you have any tips on how I should gain optimal performance (100% CPU) without this problem?


Gotta Get Back In Time
Toby Reyelts
10/2004
If you haven't done so already, you should download the latest version of Retroweaver and its associated documentation from http://retroweaver.sf.net.
Before you begin using Retroweaver, you might like to have your well-paid lawyers review the BSD-style license for use. (NB: There's nothing really fine about fine print.)
Copyright (c) February 2004, Toby Reyelts
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
Neither the name of Toby Reyelts nor the names of his contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.

Once you've downloaded retroweaver-<version>.zip, you can unzip the contents to your favorite folder. When you've finished that process, you'll be presented with the following set of folders:
docs – All of the documentation for Retroweaver (including the Developer's Guide you're reading right now).
lib – Third party libraries that Retroweaver needs in order to perform the bytecode weaving. These libraries are only required during weaving, not deployment, of your application.
release – Contains the Retroweaver runtime library, retroweaver-rt-<version>.jar, which you must deploy with your application. Contains the full Retroweaver application, retroweaver-<version>.jar, which you use to weave your application or start the Retroweaver graphical interface. Also contains retroweaver-all-<version>.jar which includes all Retroweaver classes along with the required libraries.
src – All of the Java source code for both the bytecode weaver and the runtime library. Feel free to browse through here and send some advice my way.
src/net/sourceforge/retroweaver/tests – The source for a suite of test cases that get executed against Retroweaver. If you're not sure that Retroweaver can handle a particular construct or condition, write a test case. If you're so inclined, send it my way. I'd love to include it in Retroweaver's test suite.
release/retroweaver-tests-<version>.jar – The compiled and retroweaved classes from the test suite. You can run these to give yourself warm fuzzies about Retroweaver's behavior.
Sun has just released their latest and greatest version of the Java developer's kit – JDK 1.5. There is something that really differentiates this version from earlier releases, though – new language features.
JDK 1.5 has new support for generics, autoboxing, static imports, enums, extended for loops, annotations, and varargs. The Java language has just undergone its largest change ever, and if you're anything like me, you want to take advantage of all of these new wonderful enhancements. Unfortunately, if you're anything like me, you also have some problems that are likely to get in your way:
JDK 1.5 is a new product, and you or your manager may not be very fond of relying on untested virtual machines.
Your product may rely on other 3rd party products that aren't supported on 1.5 (persistence engines, ui frameworks, and application servers are common examples).
Your clients may not be able to install the latest version of the JVM – a typical scenario for companies that deploy applets or applications via WebStart.
Retroweaver is a solution to all of these problems. Retroweaver enables you to develop your product using the new 1.5 Java language, while retaining binary compatibility with previous VMs – all the way back to JDK 1.2.
If you've bothered to read this far, you're probably interested in learning how to use Retroweaver with your own product. The process is surprisingly easy.
Download and install JDK 1.5. (Seriously – it's very tough to develop Java programs without a Java compiler).
Write your source code using all of those new powerful language features that you love in 1.5.
Compile your code and run Retroweaver against the class files. You can run Retroweaver in a few different ways.
Use the graphical interface. Just double-click on the executable jar file, retroweaver-<version>.jar, or execute java -jar release/retroweaver-<version>.jar. This is a good way to start getting used to Retroweaver.
Run
Retroweaver from the command line. That looks like:
java
-cp
release\retroweaver-<version>.jar;lib\asm-2.2.jar;lib\asm-commons-2.2.jar
net.sourceforge.retroweaver.Weaver -source classes
or when weaving a jar file:
java -cp release\retroweaver-<version>.jar;lib\asm-2.2.jar;lib\asm-commons-2.2.jar net.sourceforge.retroweaver.Weaver -jar input.jar output.jar
Add Retroweaver to your build script. This is the best way to integrate Retroweaver into your day to day development cycle. Retroweaver comes with a built-in Ant task – net.sourceforge.retroweaver.ant.RetroWeaverTask. See the Appendix for details.
Weave classes on the fly at runtime with WeaveRunner, a custom ClassLoader weaving classes at runtime:
java -cp release\retroweaver-all-<version>.jar net.sourceforge.retroweaver.WeaveRunner -cp <application class path> <Main Class> <arguments>
Deploy your application, including the Retroweaver runtime library, retroweaver-rt.jar.
While cross-compiling your code to another virtual machine, you need to make sure you don't reference runtime code that doesn't exist in your target VM. Prior to JDK 1.5, this was most easily achieved by using the switch -Xbootclasspath/p, and pointing it to the rt.jar of your target VM. The java compiler would complain if you referenced classes, methods, or fields that didn't exist in the target VM. For lack of a better name, we'll call this process, reference verification.
The bad news is that, due to the nature of Retroweaver, it is not possible to use the bootclasspath switch to perform reference verification in conjunction with Retroweaver. The good news is that Retroweaver comes with its own reference verifier. Retroweaver's reference verifier will warn you if any of your code references a class, method, or field that it can't find in your target VM. To turn on Retroweaver's reference verifier, specify the -verifyrefs switch. You'll have to pass the classpath that contains your target JDK's rt.jar, Retroweaver's runtime library, and all of the classes that your application uses. For example,
java -cp release\retroweaver-<version>.jar;lib\asm-2.2.jar;lib\asm-commons-2.2.jar net.sourceforge.retroweaver.Weaver -source classes -verifyrefs c:\java\jdk1.4\lib\rt.jar;release\retroweaver-rt-<version>.jar;compiled-classes;lib\lib1.jar;lib\lib2.jar
When Retroweaver encounters a reference to a class/method/field that can't be located on the classpath specified with -verifyrefs, it issues a warning, so you can locate and correct the issue.
 This section strives to assuage any concerns that people may have about this technique, by explaining the underlying pinnings of Retroweaver, while avoiding the tediousness of reviewing the entire source code base.
There were a set of design approaches available to achieving Retroweaver's end goal – 1.5 source code running on an earlier virtual machine. The top approaches, aside from bytecode enhancement, were:
Generate 1.4 source
code from 1.5 source code.
While this approach sounds nice,
it's simply infeasible. It's just not possible to generate 1.4
source code, for all possible language constructs in 1.5. Sun's
compiler team has confirmed this, itself.
Develop a 1.5 compiler
that can target 1.4.
This is definitely a valid approach. In
fact, given all the time in the world, this is probably the best
approach. The primary problem, here, is that developing a 1.5
compiler is a significantly complex task – much moreso than
just the development of Retroweaver. For example, to date, there are
still significant bugs in Sun's own 1.5 compiler. Eventually, I
believe we will see compilers for 1.5, that also support -target
1.4. Until then, there is Retroweaver.
The changes that Retroweaver makes to class files, can be roughly divided into two categories – format changes and runtime changes.
Format changes are changes which are required due to specification updates in the JVM. They include:
Replacement of “+”
characters with “$” characters in identifiers.
The
new JDK 1.5 specification has relaxed the rules concerning Java
language identifiers, to allow “+” characters.
Retroweaver replaces the “+” characters with “$”
characters, which are legal in earlier virtual machines. Retroweaver
also renames class files which have “+” characters in
their names.
Replacement of LDC and
LDC_W instructions which have a CONSTANT_Class target.
In
JDK 1.5, these two instructions have been updated to work on class
literals, for example, String.class. Prior to JDK 1.5, a
programmer's use of a class literal resulted in the compiler
generation of a method to execute a Class.forName. Retroweaver
preserves the older behavior.
Replacement of
Synthetic access specifiers with Synthetic attributes.
In JDK
1.5, Synthetic access specifiers were introduced to replace
Synthetic attributes and reduce the size of class files. Retroweaver
reverses the operation by replacing Synthetic access specifiers with
Synthetic attributes.
Removal of JDK 1.5 bit
assignments from access specifiers.
The JVM specification
(second edition) states that unassigned bits of the access
specifiers for classes, methods, and fields should be set to 0 by
compilers and bytecode generators. It also states that JVMs must
ignore those bits, but to be perfectly compliant, Retroweaver resets
them to 0.
Runtime
changes are changes which are required due to the addition of new
classes to the JDK runtime library. They include:
Replacement
of calls to StringBuilder with StringBuffer.
StringBuilder
is a new class introduced into 1.5 as an unsynchronized version of
StringBuffer that maintains the same interface as StringBuffer. The
JDK 1.5 compiler generates calls to StringBuilder, when you use the
“+” operator on Strings. Retroweaver replaces those
calls to StringBuilder, with calls to StringBuffer.
Replacement of calls
to <PrimitiveWrapper>.valueOf( <primitive> )
methods.
In JDK 1.5, the new autoboxing specification
prompted the introduction of new valueOf() methods to the primitive
wrapper classes, for example, Long.valueOf( long ). These methods
facilitate autoboxing, not only by boxing a primitive value, but by
supporting other features of the autoboxing specification (i.e.
mandated/optional caching behavior). Retroweaver replaces calls to
these methods with calls to its own runtime library, which
implements autoboxing according to the specification.
Replacement of
references to java.lang.Enum.
The new support for first class
enumerations in JDK 1.5 requires a base enum class, java.lang.Enum.
Retroweaver replaces references to java.lang.Enum with
net.sourceforge.retroweaver.runtime.Enum_, which is primarily a
clone of java.lang.Enum. This means that enum values are made
subclasses of Enum_, and methods which would operate on Enum,
operate on Enum_, instead. Enum_ implements the enum behavior
specified in the enumeration specification, including guaranteed
singleton behavior, even in the face of serialization.
Replacement of
references to java.lang.Iterable.
The new extended for loop
syntax in JDK 1.5 required a new interface, java.lang.Iterable.
Retroweaver replaces references to java.lang.Iterable with its own
runtime class, net.sourceforge.retroweaver.runtime.Iterable_. This
allows developers to continue to use the extended for loop and to
even create implementations of Iterable, as they would with JDK
1.5.
“Wait,”,
you say, “I thought Retroweaver also supports static imports,
varargs, and generics, but I saw no mention of them, here.”
It
is true that Retroweaver does support these features, it's just that
these features require no special support from Retroweaver.
The
new static import language feature is just a compiler directive. It
has no effect whatsoever on generated class files.
The new
varargs language feature introduces a new access specifier, but that
access specifier is used only by JDK 1.5 compilers and ignored by
earlier compilers. Vararg methods will appear as vararg under 1.5,
while appearing with array arguments under previous compilers, as you
would expect. For example,
public
void foo( String... ) {
}
would appear as
public void foo( String[] ) {
}
The addition of generics requires a new Signature attribute, which, again, is only used by JDK 1.5 compilers and ignored by earlier compilers. Generic methods appear generic under 1.5, but appear as their type-erased equivalents under previous compilers. For example,
public class Foo<T extends Comparable> {
public void foo( T t ) {
}
}
would appear as
public class Foo {
public void foo( Comparable t ) {
}
}
Why am I getting a
NoClassDefFoundError/ClassNotFoundException?
It depends.
Is
it for a class that is in net.sourceforge.retroweaver.runtime? You
should make sure you're including retroweaver-rt-<version>.jar
in your application class path.
Is it for one of the JDK
classes? If you're using a class that is new to JDK 1.5, stop.
Retroweaver has support for a few special classes (java.lang.Enum,
java.lang.Iterable, and java.lang.StringBuilder), but that's it. You
can't use any other classes that are new to JDK 1.5. You can turn on
the -verifyrefs option on Retroweaver to receive warnings when you
reference classes, fields, or methods that don't exist in the VM
that you are targetting.
Why am I getting a
NoSuchMethodException/Error or a NoSuchFieldException/Error?
Most
likely, you're using a class that did exist prior to JDK 1.5, but a
new method/field for that class that didn't exist prior to JDK 1.5.
You can't use new JDK 1.5 classes/methods/fields in an earlier JVM.
You can turn on the -verifyref option on Retroweaver to receive
warnings when you reference classes, fields, or methods that don't
exist in the VM that you are targetting.
How does serialization
for enums work?
The new enum specification requires changes
to the serialization specification, which are outside of the reach
of Retroweaver. This means that serialization of enums behaves
correctly, but differently, between 1.5 and earlier VMs. In other
words, you can't just naively exchange enums between 1.5 and earlier
VMs via serialization.
Why do I get a
java.lang.IncompatibleClassChangeError?
Does it happen when
you are using an Iterable? Currently, Retroweaver is unable to
handle an assignment of a JDK 1.5 class that implements
java.lang.Iterable to a java.lang.Iterable reference. See the test
case, ItTest.java for more details. You can workaround this problem
by wrapping the reference to the JDK 1.5 class in your own Iterable
adapter.
net.sourceforge.retroweaver.ant.RetroWeaverTask
Runs Retroweaver on a directory or set of directories to convert classes produced by a JDK 1.5 compliant compiler to a class file format supported by older JVM's.
|
Attribute |
Description |
Required |
|---|---|---|
|
srcdir |
The directory containing classes to process. |
One of either srcdir, inputjar or a nested fileset element. |
|
destdir |
The destination directory for the processed classes. |
No. If not specified, the processed classes overwrite the source classes. |
|
inputjar |
The jar file to proces. |
One of either srcdir, inputjar or a nested fileset element. |
|
outputjar |
The jar file for the processed classes. |
Yes if inputjar is specified. |
|
classpath |
The classpath for reference verification. For example, retroweaver-rt-<version>.jar;c:\java\jdk1.4\lib\rt.jar;my-classes |
No. If not specified, Retroweaver will not verify references. |
|
verify |
Indicates whether the verifier should be called. Note that the verifier is skipped if classpath is not defined. |
No. Defaults to true. |
|
target |
The target version as either "1.2", "1.3", or "1.4". |
No. Defaults to "1.4". |
|
stripSignatures |
Indicates whether the generic
signatures should be stripped. |
No. Defaults to false. |
|
stripAttributes |
Indicates whether the custom
Retroweaver attributes should be stripped. |
No. Defaults to false. |
|
lazy |
Indicates if classes that already have the target version should be skipped. If the destination directory is different from the source directory, such classes are copied to the destination with preserved timestamp. |
No. Defaults to true. |
|
failonerror |
Indicates if the build should fail if an error occurs while processing classes. If false, a warning is logged but the build continues. |
No. Defaults to true. |
|
verbose |
Indicates if the names of processed files should be logged. |
No. Defaults to false. |
One ore more filesets can be specified instead of (or in addition to) the srcdir attribute. Make sure that the fileset only includes class files.
<taskdef name="retroweaver" classname="net.sourceforge.retroweaver.ant.RetroWeaverTask"> <classpath> <fileset dir="${retroweaver.home}/lib" includes="**/*"/> <pathelement location="${retroweaver.home}/release/retroweaver-<version>.jar"/> </classpath> </taskdef>
<target name="weave" depends="compile"> <retroweaver srcdir="classes"/> </target>
<target name="weave" depends="compile"> <mkdir dir="classes-13"/> <retroweaver destdir="classes-13" target="1.3"> <fileset dir="classes"> <include name="**/*.class"/> </fileset> </retroweaver> </target>
Chapter 6: Acknowledgments
My wife, who continually puts up with my pursuit of all things arcane.
Neal Gafter, who was responsible for providing most of the information that made Retroweaver possible.
Sean Shubin, who has donated some usability improvements to Retroweaver.
Gunnar Grim, who has donated the Ant task.


Almost all classes in Torch should be a sub-class of this class.
Almost all classes in Torch should be a sub-class of this class. It provides two interesting things: first a useful interface to manage option, and second the "allocator trick".Indeed, in Torch, a class which allocate memory should desallocate this memory when it's destroyed. The idea is the following: in the constructor of Object, an Allocator object is created. You can use it in your subclasses to allocate memory. This memory will be destroyed when the Object is destroyed.
"new" operator have been defined to be used with Allocator.
Alphabetic index HTML hierarchy of classes or Java


PSALMS 51
A psalm written by David for the choir director, concerning the time when the prophet Nathan rebuked David after he had committed adultery with Bathsheba.
1 O God, act mercifully toward me
because you love me faithfully;
because you are very merciful,
erase the record of the ways that I disobeyed you!
2 Make me pure from the wrong things that I have done;
make me clean from the guilt of my sin.
3 I say that because I know the ways that I have disobeyed you;
I cannot forget them.
4 You, you only, are the one I that have really sinned against,
and you have seen the evil things that I have done.
When you say that I am guilty, you are right,
and when you judge me, you justly say that I deserve to be punished.
5 I have been a sinner since the day that I was born;
truly, I have been like that since my mother conceived me.
6 What you desire is that in my inner being I desire what is true
in order that you can teach me in my inner being how to act wisely.
7 Purify me from the guilt of my sins, and after that happens, I will be clean in my inner being;
cleanse me, and then in my inner being I will be whiter than snow.
8 Allow me again to be joyful;
you have crushed my spirit;
but now let me rejoice again.
9 Do not continue to look at the sins that I have committed;
erase the record of the evil things that I have done.
10 O God, cause my inner being to be pure.
Put a new and faithful spirit within me.
11 Do not send me away from you because of my sin,
and do not take your Holy Spirit from me.
12 Cause me to be happy again because of knowing that you have freed me from the guilt of my sin,
and make my spirit willing to obey you.
13 If you do that, I will be able to teach to other sinners what you want them to do,
and they will repent and begin to obey you.
14 O God, you are the one who saves me;
forgive me for being guilty of causing someone who was not my enemy to die.
When you do that, I will sing joyfully about your being very good and righteous.
15 O Yahweh, help me to speak
in order that I may praise you.
16 You are not pleased with only the sacrifices that people bring to you.
If that were enough to please you, I would bring you sacrifices.
You are not pleased with burnt offerings alone.
17 The sacrifice that you really want is for people to be truly humble and sorry for having sinned;
O God, you will not refuse that kind of sacrifice.
18 O God, be good to the people who live in Jerusalem;
help them to rebuild the city walls.
19 When that happens, they will bring you the proper sacrifices,
animals that they completely burn,
young bulls that they burn on your altar,
and you will be pleased.


Software Solutions
INTRALATTICE
Intralattice is a plugin for Grasshopper used to generate solid lattice structures within a 3D design space. It was developed as an extensible, open-source alternative to current commercial solutions. As an ongoing project developed at McGill’s Additive Design & Manufacturing Laboratory (ADML), it has been a valuable research tool, serving as a platform for breakthroughs in multi-scale design and optimization. By giving you full access to the source, we hope to collectively explore lattice design at a deeper level, and consequently, engineer better products.
The rise of additive manufacturing (i.e. 3D printing) has allowed engineers to integrate new orders of complexity into their designs. In that regard, this software generates lattice structures as a means to:
- Reduce volume/weight while maintaining structural integrity.
- Increase surface area as a means of maximizing heat transfer.
- Generate porosity in bone scaffolds and implants.
- Serve as a platform for structural optimization..
INTRALATTICEPRO
IntralatticePro is a newly developed generative software and database for lattice and cellular structures. It is the professional version of original Intralattice, and aims to provide more help for designers to take advantages of lattice structures for different types of functional performance. By incorporating several design and simulation tools and advanced geometric modeling algorithms, IntralatticePro is more beneficial and robust on the design of lattice structures for different functional purposes, such as structural weight reduction, vibration control, energy absorption and heat dissipation.
IntralatticeData is published on the website of IntralatticePro. It is a material database for lattice structures. It includes the lattice topologies in Intralattice. The effective elastic properties of lattice structures. As an Intralattice user, you can directly get the homogenized property of the lattice structure you are designing. Based on the information you get, you can modify the design to fulfill the functional requirement.
SIMULATTICE
SimuLattice is a MATLAB based software to support the simulaion-based design of lattice structure. Previous simulation models for lattice structure is either computational heavy or lack of accuracy. The proposed simulation scheme in SimuLattice has three simulation models that can be used in three design stages. It can help designers quickly and accurately get the mechanical property of lattice structures fabricated by additive manufacturing.
The design of lattice structures can be divided into three design stages. In each stage, a simulation model is proposed. Furthermore, a material model is established in SimuLattice to consider the manufacturing influence of AM. There are totally four modules in SimuLattice:
- Numerical homogenization models for initial design.
- Joint stiffening element model for design optimization.
- Hybrid element model for design validation.
- As-built material property model.
ConsolidDesign
ConsolidDesign is a plugin for Rhinoceros to support the identification and redesign of parts candidate for consolidation, which is specifically driven by the extremely expanded design freedoms of additive manufacturing. The design helps designers to semi-automatically identify part candidacy out of a complex product and guides them through the embodiment design step by step.
The functionality offered by this tool include:
- Interactive tool for establishing DSM-like part function interaction map.
- Automated identification of part candidates for consolidation.
- Guided steps for fusing the assembly into one single design space in preparation for structure optimization.
ACDAM
Automated Candidate Detection for Additive Manufacturing
With the rapid advancement of AM technologies, identifying parts which are eligible for AM as well as gaining insight on what value it may add to a product needs to be modelled in an objective and transferrable way. This tool aims at determining the candidacy of a part or assembly for AM based on its economic feasibility and potential for AM-specific benefits (such as lightweight, freeform shapes, and customization). This tool is also featured by its employment of machine learning algorithms with carefully sampled historical data.
Some basic functionality included:
- Several CAD format is supported (STEP, IGES, STL, CATPRODUCT, etc.)
- AM expertise is not required
- AM potentials are analyzed with regard to multiple criteria
- It also serves as a AM potential learning platform for beginners.


Summary
I designed the
Process
Once initial user testing was done for Policy Bot, there was immediate feedback that administrators would like a portal or separate database to track questions.
The website and slack bot have been both tested by internal users and admins for external customers including Facebook and Uber.
The website was designed to simplify onboarding, be intuitive and minimal in order to make it easy for clients to customize with their own branding.
Outcome
Policybot has been incorporated into Concur Assistant (beta), on the mobile app.


Pressing the button bellow will:
load jQuery from CDN
check for jQuery and alert you once it's loaded